{"id":18708541,"url":"https://github.com/alimozdemir/datasuit","last_synced_at":"2025-04-12T10:34:27.809Z","repository":{"id":70175643,"uuid":"121604126","full_name":"alimozdemir/DataSuit","owner":"alimozdemir","description":" netstandard2.0 random data generator","archived":false,"fork":false,"pushed_at":"2018-05-19T21:53:07.000Z","size":1273,"stargazers_count":16,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-06-21T04:06:17.175Z","etag":null,"topics":["dotnet-core","netstandard20","random-generation"],"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/alimozdemir.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-15T08:00:00.000Z","updated_at":"2020-11-17T15:37:20.000Z","dependencies_parsed_at":"2023-02-24T10:30:22.456Z","dependency_job_id":null,"html_url":"https://github.com/alimozdemir/DataSuit","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alimozdemir%2FDataSuit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alimozdemir%2FDataSuit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alimozdemir%2FDataSuit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alimozdemir%2FDataSuit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alimozdemir","download_url":"https://codeload.github.com/alimozdemir/DataSuit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223511590,"owners_count":17157547,"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-core","netstandard20","random-generation"],"created_at":"2024-11-07T12:23:53.925Z","updated_at":"2024-11-07T12:23:54.808Z","avatar_url":"https://github.com/alimozdemir.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Overview\n\nData Suit is a random data generator. It generates data for primitive data types and POCO classes. At the beginning, it was an experimental project for several purposes. Later, I changed it into a formal format. It is designed with SOLID principles. Mapping fields is also supported via fluent API. \n\nBasis of the API is shown below. For more detailed examples, you can see at  [Samples](https://github.com/lyzerk/DataSuit/tree/master/samples)\n\n# Content\n1. [Build and Nuget](https://github.com/lyzerk/DataSuit#build-and-nuget)\n2. [Usage](https://github.com/lyzerk/DataSuit#usage)\n3. [Customizing](https://github.com/lyzerk/DataSuit#customizing)\n4. [Import/Export](https://github.com/lyzerk/DataSuit#importexport)\n5. [AspNetCore](https://github.com/lyzerk/DataSuit#aspnetcore)\n6. [TestSetup](https://github.com/lyzerk/DataSuit#testsetup)\n\n# Build and nuget\n\n.NET Standard library of data suit. \n\n|Build Status (travis-ci)|DataSuit Nuget|DataSuit.AspNetCore Nuget|\n|---|---|---|\n|[![Build Status](https://travis-ci.org/lyzerk/DataSuit.svg?branch=master)](https://travis-ci.org/DataSuit/DataSuit)|[![NuGet](https://img.shields.io/nuget/v/DataSuit.svg)](https://www.nuget.org/packages/DataSuit/)| [![NuGet](https://img.shields.io/nuget/v/DataSuit.AspNetCore.svg)](https://www.nuget.org/packages/DataSuit.AspNetCore/)|\n|   |   |   |\n# Usage\n\n## Suit Class\nSuit class is necessary for every operation.\n\n```csharp\nSuit suit = new Suit();\n```\n\nDataSuit comes with built-in data. If you want to enable it, you have to call:\n\n```csharp\nsuit.Load();\n```\n\nYou can see the built-in data fields on [BuiltIn.md](https://github.com/lyzerk/DataSuit/tree/master/BuiltIn.md) file.\n\n## POCO example\nFor example POCO class data generation\n\n```csharp\nvar personGenerator = suit.GeneratorOf\u003cPerson\u003e();\nvar listOfPersons = personGenerator.Generate(count: 10);\n```\nIt generates 10 person classes with respect to properties of it.\n\n```csharp\nvar person = personGenerator.Generate();\n```\n\nIt generates a Person class\n\n\n## Primitive example\n```csharp\nvar primitiveGenerator = suit.GeneratorOfPrimitives();\nvar names = primitiveGenerator.String(\"FirstName\", count: 5);\nforeach (var name in names)\n    Console.WriteLine($\"Name:{name}\");\n```\nIt generates 5 names as string list\n\n\n# Customizing\nDataSuit API supports customizing very well. A fluent API design welcomes us here.\n\n```csharp\nISettings settings = new Settings();\nSuit suit = new Suit(settings);\n\nvar barList = new List\u003cstring\u003e() { \"Foo\", \"Bar\", \"Baz\" };\n\nsuit.Build\u003cFoo\u003e()\n    .Collection(i =\u003e i.Bar, barList, ProviderType.Random)\n    .Range(i =\u003e i.Range, 10, 40)\n    .Set(i =\u003e i.Static, \"DataSuit\");\n\nvar fooGenerator = suit.GeneratorOf\u003cFoo\u003e();\nvar data = fooGenerator.Generate(count: 4);\n\nforeach (var item in data)\n    Console.WriteLine($\"{item.Bar} {item.Range} {item.Static}\");\n```\n\nResult of the foo classes\n```\nBar 19 DataSuit\nFoo 23 DataSuit\nBaz 11 DataSuit\nBaz 33 DataSuit\n```\n\n## Mapping\n\n### Collection\n```csharp\nsuit.Build\u003cT\u003e()\n    .Collection(i =\u003e i.Field, list,  ProviderType.Sequential)\n```\n\n### Static Variable\n```csharp\nsuit.Build\u003cT\u003e()\n    .Set(i =\u003e i.Field, Variable)\n```\n\n### Range\nIt requires integer or double range values\n```csharp\nsuit.Build\u003cT\u003e()\n    .Range(i =\u003e i.FieldInteger, 10, 20)\n    .Range(i =\u003e i.FieldDouble, 10.5, 20.3)\n```\n\n### Dummy\nIt gives lorem ipsum text data with given length \n\n```csharp\nsuit.Build\u003cT\u003e()\n    .Dummy(i =\u003e i.Field, 300)\n```\n\n### Incremental\nIt generates integer or long values by sequential order. Such as IDs.\n\n```csharp\nsuit.Build\u003cT\u003e()\n    .Incremental(i =\u003e i.Id)\n```\n\n### Func\nIt does run a function for every MoveNext event.\n\n```csharp\nsuit.Build\u003cT\u003e()\n    .Func(i =\u003e i.Id, () =\u003e Guid.NewGuid().ToString())\n```\n\n### Guid\n```csharp\nsuit.Build\u003cT\u003e()\n    .Guid(i =\u003e i.Id)\n```\n\n### Enum\n\nIt will give select enums as random. It uses ICollectionProvider with Random provider type.\n```csharp\nsuit.Build\u003cT\u003e()\n    .Enum(i =\u003e i.EnumData)\n```\n\n\nAlso, you can use Build method without generic type.\n\n### Non-generic type\n```csharp\nsuit.Build()\n    .Range(\"Salary\", 3000, 5000)\n    .Incremental(\"id\");\n```\n\n# Import/Export\n\nFollowing code, export settings of the current suit as JSON string.\n```csharp\nsuit.Export();\n```\nNote that: FuncProvider can't be exported. Therefore, you have to re-define the Func providers when you are importing them to a suit. \n\nFollowing code, import settings with the given JSON string.\n```csharp\nsuit.Import(data);\n```\n\nYou can see an example setting JSON file from [here](https://raw.githubusercontent.com/lyzerk/DataSuit/master/samples/DataSuit.SettingExportImport/settings.json)\n\n# AspNetCore\n\nYou can get the package DataSuit.AspNetCore from [nuget](https://www.nuget.org/packages/DataSuit.AspNetCore/).\n\nJust you need to add DataSuit to Startup.cs on ConfigureServices method.\n```csharp\nservices.AddDataSuit();\n```\n\nAlso, you can customize the API via\n```csharp\nservices.AddDataSuit(i =\u003e\n{\n    i.DefaultData = false; // disable built-in data \n    i.Build()\n        .Range(\"Salary\", 3000, 5000)\n        .Incremental(\"id\");\n\n    i.Ready();\n});\n```\n\nAt the controller, you can inject IGenerator\u003cT\u003e\n```csharp\nprivate readonly IGenerator\u003cPersonViewModel\u003e _personGenerator;\n\npublic HomeController(IGenerator\u003cModels.PersonViewModel\u003e personGenerator)\n{\n    _personGenerator = personGenerator;\n}\n\npublic IActionResult GetPersons()\n{\n    return Json(_personGenerator.Generate(count: 5));\n}\n```\n\n# TestSetup\n\nThis attribute speeding up the process of unit testing. \n\n```csharp\n[TestSetup(typeof(TestSetupExample))]\npublic void Example()\n{\n    var suit = DataSuitRunner.GetSuit();\n    var data = suit.GeneratorOfPrimitives().String(\"Singer\");\n    Assert.Equal(\"Eminem\", data);\n}\n```\n`TestSetupExample` class is a setup class for this unit test. It is derived from `IAttributeSuit` interface.\n\nTestSetupExample.cs\n```csharp\npublic class TestSetupExample : ISetupSuit\n{\n    public TestSetupExample()\n    {\n        Suit = new Suit();\n\n        Suit.Build()\n            .Set(\"Singer\", \"Eminem\");\n\n        Suit.EnsureNoPendingProviders();\n    }\n    public Suit Suit { get; }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falimozdemir%2Fdatasuit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falimozdemir%2Fdatasuit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falimozdemir%2Fdatasuit/lists"}