{"id":21474853,"url":"https://github.com/cbinet/fixtures","last_synced_at":"2025-03-17T07:45:24.480Z","repository":{"id":143868156,"uuid":"102316905","full_name":"CBinet/Fixtures","owner":"CBinet","description":"Creates complete fixtures for your C# unit tests projects.","archived":false,"fork":false,"pushed_at":"2017-09-12T02:12:48.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-27T05:20:56.586Z","etag":null,"topics":["autofixture","csharp","fixture","mstest","netcore","tests"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/BetaSoftwares.Fixture/","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CBinet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-04T03:56:53.000Z","updated_at":"2018-05-09T02:40:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"95508e9b-f488-48fc-9f39-0877d2b06dab","html_url":"https://github.com/CBinet/Fixtures","commit_stats":null,"previous_names":["cbinet/betasoftwares.fixture"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CBinet%2FFixtures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CBinet%2FFixtures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CBinet%2FFixtures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CBinet%2FFixtures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CBinet","download_url":"https://codeload.github.com/CBinet/Fixtures/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243997037,"owners_count":20380980,"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":["autofixture","csharp","fixture","mstest","netcore","tests"],"created_at":"2024-11-23T10:33:23.351Z","updated_at":"2025-03-17T07:45:24.442Z","avatar_url":"https://github.com/CBinet.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# BetaSoftwares.Fixture\n\n## **Installation**\nTo install **BetaSoftwares.Fixture**, you can either browse the Package Manager or run the following command in the \u003ca href='#https://docs.microsoft.com/fr-fr/nuget/tools/package-manager-console'\u003ePackage Manager Console\u003c/a\u003e :\n\n```\nPM\u003e Install-Package BetaSoftwares.Fixture\n```\n\n\u003chr\u003e\n\n## **Usage**\n\u003cbr\u003e\nTo start using **BetaSoftwares.Fixture**, you will first need to create an instance of the Fixture class :\n\n```cs\nusing BetaSoftwares.Fixtures;\n\nFixture fixture = new Fixture();\n```\n\n ### **Create**\n To generate a new fixture of any type, use the **Fixture.Create** method :\n\n ```cs\n string random = fixture.Create\u003cstring\u003e();\n// or..\n string random = fixture.Create(typeof(string));\n ```\n\n### **CreateMany**\nTo generate many fixtures at the same time, you can use the **Fixture.CreateMany** method :\n\n```cs\nICollection random = fixture.CreateMany\u003cstring\u003e();\n// or..\nICollection random = fixture.CreateMany(typeof(string));\n```\n\n### **AddManyTo**\nTo add many fixtures an already existing list, you can use the **Fixture.AddManyTo** method :\n\n```cs\nList\u003cstring\u003e list = new List\u003cstring\u003e();\n// Add 5 fixture to the list\nfixture.AddManyTo(list, 5);\nint count = list.Count; // count = 5\n```\n\n### **Build**,  **With**, **Without** and **Do**\nYou can also customize a fixture on creation using the **Fixture.Build** with the **FixtureDefinition.With**,  **FixtureDefinition.Without** and **FixtureDefinition.Do** methods :\n\n```cs\n// With\nICollection random = fixture.Build\u003cMyClass\u003e().With(c =\u003e c.MyString, \"Hello world\").Create();\n// Without\nICollection random = fixture.Build\u003cMyClass\u003e().Without(c =\u003e c.MyString).Create();\n// Do\nICollection random = fixture.Build\u003cMyClass\u003e().Do(c =\u003e c.MyList.Clear()).Create();\n// You can mix .With, .Without and .Do\nICollection random = fixture.Build\u003cMyClass\u003e().With(c =\u003e c.MyString, \"Hello world\").Do(c =\u003e c.MyList.Clear()).Create();\n```\n\n### **Register**\nTo register a type default value, you can use the **Fixture.Register** method :\n\n```cs\n// Registers a new default value\nfixture.Register\u003cIMyInterface\u003e(() =\u003e new MyClass());\n// The instance will be of the registered type\nMyClass myClass = fixture.Create\u003cIMyInterface\u003e();\n```\n\n### **Customize**\nTo customize a complex type default properties, you can use the **Fixture.Customize** method :\n\n```cs\n// Customize the class default properties\n_fixture.Customize\u003cComplexType\u003e(c =\u003e c.With(c =\u003e c.MyInteger, 42));\n// The instance will have the custom properties\nComplexType myClass = fixture.Create\u003cComplexType\u003e();\nint value = myClass.MyInteger; // value = 42\n```\n\n## Supported types\nHere is the index of currently supported types. If the type is not supported, the property will be set to the default value of the type.\n\n### Basic types :\n- [string](https://msdn.microsoft.com/en-us/library/system.string)\n- [bool](https://msdn.microsoft.com/en-us/library/system.boolean)\n- [object](https://msdn.microsoft.com/en-us/library/system.object)\n- [char](https://msdn.microsoft.com/en-us/library/system.char)\n- [short](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/short)\n- [ushort](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/ushort)\n- [int](https://msdn.microsoft.com/fr-fr/library/system.int32(v=vs.110).aspx)\n- [uint](https://msdn.microsoft.com/en-us/library/system.uint32(v=vs.110).aspx)\n- [float](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/float)\n- [double](https://msdn.microsoft.com/en-us/library/system.double(v=vs.110).aspx)\n- [decimal](https://msdn.microsoft.com/en-us/library/system.decimal(v=vs.110).aspx)\n- [long](https://msdn.microsoft.com/en-us/library/system.int64(v=vs.110).aspx)\n- [ulong](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/ulong)\n- [byte](https://msdn.microsoft.com/fr-fr/library/system.byte(v=vs.110).aspx)\n- [sbyte](https://msdn.microsoft.com/en-us/library/system.sbyte(v=vs.110).aspx)\n\n### Data structures :\n- [ICollection](https://msdn.microsoft.com/en-us/library/92t2ye13(v=vs.110).aspx)\n- [IDictionary](https://msdn.microsoft.com/fr-fr/library/s4ys34ea(v=vs.110).aspx)\n- [Tuple](https://msdn.microsoft.com/fr-fr/library/system.tuple(v=vs.110).aspx)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbinet%2Ffixtures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcbinet%2Ffixtures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbinet%2Ffixtures/lists"}