Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ashrafsada/dynafill
Dynamic object filler for Unit Testing
https://github.com/ashrafsada/dynafill
Last synced: about 1 month ago
JSON representation
Dynamic object filler for Unit Testing
- Host: GitHub
- URL: https://github.com/ashrafsada/dynafill
- Owner: AshrafSada
- Created: 2022-01-06T15:25:55.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-11-05T18:31:53.000Z (2 months ago)
- Last Synced: 2024-12-05T23:35:46.424Z (about 1 month ago)
- Language: HTML
- Size: 2.46 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DynaFill Dynamic Object Filler
DynaFill is a dynamic object filler that can be used to fill objects with dynamic data. It can be used to fill objects with random data, for mocking, testing, and more.
## Usage Example
```csharp
using DynaFill.Filler;public class Person
{
public string Name { get; set; }
public int Age { get; set; }
public bool IsMarried { get; set; }
public Address Address { get; set; }
public List PhoneNumbers { get; set; }
}public class Address
{
public string Street { get; set; } = null!;
public string City { get; set; } = null!;
public string State { get; set; } = null!;
public string ZipCode { get; set; } = null!;
}// using XUnit
public class PersonTests
{
// Arrange
var personObj = new Person();
var filler = new GenericFiller();// Act
().Fill(new Address());
var person = filler.Fill(personObj);
person.Address = new GenericFiller
person.PhoneNumbers = new List() { "123-456-7890", "123-456-7888" };// Assert
Assert.NotNull(person);
Assert.NotEqual(0, person.Id);
Assert.NotEmpty(person.Name);
Assert.NotEmpty(person.LastName);
Assert.NotEmpty(person.Email);
Assert.NotEmpty(person.PhoneNumbers);
Assert.NotEqual(DateTime.MinValue, person.BirthDate);
Assert.True(person.IsActive);
Assert.NotNull(person.Address);
Assert.NotEmpty(person.Address.Street);
Assert.NotEmpty(person.Address.City);
Assert.NotEmpty(person.Address.State);
Assert.NotEmpty(person.Address.ZipCode);
}
```