Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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
var person = filler.Fill(personObj);
person.Address = new GenericFiller

().Fill(new Address());
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);
}
```