{"id":25522234,"url":"https://github.com/dotnet-labs/unittestingwithilogger","last_synced_at":"2025-04-11T01:32:20.149Z","repository":{"id":56076253,"uuid":"278091928","full_name":"dotnet-labs/UnitTestingWithILogger","owner":"dotnet-labs","description":"Unit Testing with .NET Core ILogger\u003cT\u003e","archived":false,"fork":false,"pushed_at":"2023-12-08T18:05:56.000Z","size":13,"stargazers_count":11,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-24T22:40:49.145Z","etag":null,"topics":["dotnet","dotnet5","dotnet6","dotnetcore","dotnetcore3","logging","mock","moq","testing","unit-testing","unittest"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotnet-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"changhuixu","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-07-08T13:07:10.000Z","updated_at":"2024-04-23T10:12:53.000Z","dependencies_parsed_at":"2022-08-15T12:40:48.275Z","dependency_job_id":null,"html_url":"https://github.com/dotnet-labs/UnitTestingWithILogger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FUnitTestingWithILogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FUnitTestingWithILogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FUnitTestingWithILogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FUnitTestingWithILogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotnet-labs","download_url":"https://codeload.github.com/dotnet-labs/UnitTestingWithILogger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248325042,"owners_count":21084858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet","dotnet5","dotnet6","dotnetcore","dotnetcore3","logging","mock","moq","testing","unit-testing","unittest"],"created_at":"2025-02-19T18:18:54.696Z","updated_at":"2025-04-11T01:32:20.130Z","avatar_url":"https://github.com/dotnet-labs.png","language":"C#","funding_links":["https://ko-fi.com/changhuixu","https://ko-fi.com/changhuixu'"],"categories":[],"sub_categories":[],"readme":"# Unit Testing with .NET Core `ILogger\u003cT\u003e`\n\n\u003ca href='https://ko-fi.com/changhuixu' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi3.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n\n## [Medium Article](https://codeburst.io/unit-testing-with-net-core-ilogger-t-e8c16c503a80)\n\nBecause `ILogger\u003cT\u003e` objects are frequently used in controllers and service classes, we cannot avoid them in unit tests. In this post, we will go over some common ways to work with `ILogger\u003cT\u003e` objects in unit testing.\n\n1. Replace `ILogger\u003cT\u003e` with `NullLogger\u003cT\u003e`\n2. Create a Real `ILogger\u003cT\u003e` that Logs to Console\n3. Mock an `ILogger\u003cT\u003e` Object\n\n## License\n\nFeel free to use the code in this repository as it is under MIT license.\n\n\u003ca href='https://ko-fi.com/changhuixu' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi3.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet-labs%2Funittestingwithilogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotnet-labs%2Funittestingwithilogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet-labs%2Funittestingwithilogger/lists"}