{"id":17255584,"url":"https://github.com/ffmathy/fluffyspoon.testing","last_synced_at":"2026-02-24T09:03:09.895Z","repository":{"id":48689502,"uuid":"88411980","full_name":"ffMathy/FluffySpoon.Testing","owner":"ffMathy","description":null,"archived":false,"fork":false,"pushed_at":"2021-07-14T04:44:22.000Z","size":52,"stargazers_count":1,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-22T21:59:14.781Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ffMathy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-16T12:32:56.000Z","updated_at":"2021-07-14T04:44:24.000Z","dependencies_parsed_at":"2022-09-08T08:10:57.621Z","dependency_job_id":null,"html_url":"https://github.com/ffMathy/FluffySpoon.Testing","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffMathy%2FFluffySpoon.Testing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffMathy%2FFluffySpoon.Testing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffMathy%2FFluffySpoon.Testing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffMathy%2FFluffySpoon.Testing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ffMathy","download_url":"https://codeload.github.com/ffMathy/FluffySpoon.Testing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230472690,"owners_count":18231484,"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":[],"created_at":"2024-10-15T07:12:06.647Z","updated_at":"2025-10-15T07:28:27.440Z","avatar_url":"https://github.com/ffMathy.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Need practise in making a system testable and writing tests? See: https://github.com/ffMathy/testability-kata\n\n# FluffySpoon.Testing.Autofake\nThe `FluffySpoon.Testing.Autofake` package makes it easy for you to automatically register all your class dependencies as fakes, resulting in a setup that is easier to use with Test Driven Development (TDD) and more flexible to change in your code.\n\n## Sample using `Autofac` for IOC/DI and `NSubstitute` for faking\n```csharp\nvar containerBuilder = new ContainerBuilder();\n\nvar faker = new Autofaker();\nfaker.UseNSubstitute();\nfaker.UseAutofac(builder);\n\n//MyClassThatIWantToTest contains two constructor parameters of types IDependency1 \n//and IDependency2 respectively. these two dependencies will be registered as \n//single-instance fakes in the IOC container.\nfaker.RegisterFakesForConstructorParameterTypesOf\u003cMyClassThatIWantToTest\u003e();\n\nvar container = builder.Build();\n\n//this instance is not faked out, because it is the class that we want to test\nvar myClassThatIWantToTest = container.Resolve\u003cMyClassThatIWantToTest\u003e();\n\n//these instances are fakes and single-instance, because they are constructor \n//parameters of MyClassThatIWantToTest.\nvar fakeDependency1 = container.Resolve\u003cIDependency1\u003e();\nvar fakeDependency2 = container.Resolve\u003cIDependency2\u003e();\n```\n\n## Dependency Injection and Inversion of Control systems\n\n### Autofac\n**Package:** `FluffySpoon.Testing.Autofake.Autofac`\n\n```csharp\nvar builder = new ContainerBuilder();\n\nvar faker = new Autofaker();\nfaker.UseAutofac(builder);\n\nfaker.RegisterFakesForConstructorParameterTypesOf\u003cMyClassThatIWantToTest\u003e();\n\nvar container = builder.Build();\n```\n\n### Microsoft's Dependency Injection (used in ASP .NET Core and .NET Core)\n**Package:** `FluffySpoon.Testing.Autofake.MicrosoftDependencyInjection`\n\n```csharp\nvar serviceCollection = new ServiceCollection();\n\nvar faker = new Autofaker();\nfaker.UseMicrosoftDependencyInjection(serviceCollection);\n\nfaker.RegisterFakesForConstructorParameterTypesOf\u003cMyClassThatIWantToTest\u003e();\n\nvar serviceProvider = serviceCollection.BuildServiceProvider();\n```\n\n### StructureMap\n**Package:** `FluffySpoon.Testing.Autofake.StructureMap`\n\n```csharp\nvar container = new Container();\n\nvar faker = new Autofaker();\nfaker.UseStructureMap(container);\n\nfaker.RegisterFakesForConstructorParameterTypesOf\u003cMyClassThatIWantToTest\u003e();\n```\n\n### Lamar\n**Package:** `FluffySpoon.Testing.Autofake.Lamar`\n\n```csharp\nvar container = new Container(serviceRegistry =\u003e {\n\tvar faker = new Autofaker();\n\tfaker.UseLamar(serviceRegistry);\n\n\tfaker.RegisterFakesForConstructorParameterTypesOf\u003cMyClassThatIWantToTest\u003e();\n});\n```\n\n## Faking frameworks\n\n### NSubstitute\n**Package:** `FluffySpoon.Testing.Autofake.NSubstitute`\n\n```csharp\nvar faker = new Autofaker();\nfaker.UseNSubstitute();\n\n...\n\nvar fakeClassDependency = container.Resolve\u003cIFakeClassDependency\u003e();\nfakeClassDependency.SayFoo().Returns(\"fakefoo\");\n\nfakeClassDependency.SayFoo(); //returns \"fakefoo\"\n```\n\n### FakeItEasy\n**Package:** `FluffySpoon.Testing.Autofake.FakeItEasy`\n\n```csharp\nvar faker = new Autofaker();\nfaker.UseFakeItEasy();\n\n...\n\nvar fakeClassDependency = container.Resolve\u003cIFakeClassDependency\u003e();\nA.CallTo(() =\u003e fakeClassDependency.SayFoo()).Returns(\"fakefoo\");\n\nfakeClassDependency.SayFoo(); //returns \"fakefoo\"\n```\n\n### Moq\n**Package:** `FluffySpoon.Testing.Autofake.Moq`\n\n```csharp\nvar faker = new Autofaker();\nfaker.UseMoq();\n\n...\n\nvar fakeClassDependencyMock = container.Resolve\u003cIMock\u003cIFakeClassDependency\u003e\u003e();\nfakeClassDependencyMock.Setup(x =\u003e x.SayFoo()).Returns(\"fakefoo\");\n\nvar fakeClassDependency = container.Resolve\u003cIFakeClassDependency\u003e();\nfakeClassDependency.SayFoo(); //returns \"fakefoo\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fffmathy%2Ffluffyspoon.testing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fffmathy%2Ffluffyspoon.testing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fffmathy%2Ffluffyspoon.testing/lists"}