Documentation

Did you ever played Minecraft? When you start a new world, you can choose a random number to generate the world. If you generate a new world and you take the same number again, the world will be also the same. In ObjectFiller you also have this random seed number. Sometimes you want to have random data, but always the same random data. You asking why? For example if you are using ObjectFiller.NET to generate mocked data for a distributed webservice. Imagine you have two webservices, which are round robbin distributed and each of them generates some random testdata with objectfiller. If you make your first api request you get data for the first webservice and random data from there. If you make your second api request you get data for the second webservice but with different random data. With .SetRandomSeed(int seed) you can make objectfiller generate random data, but always the same if you choose the same integer value as seed.

public class Address
{
  public string Street { get; set; }
  public string PostalCode { get; set; }
  public string City { get; set; }
  public string Country { get; set; }
  public int HouseNumber { get; set; }
}        

[TestMethod]
public void SetRandomSeedShallGenerateSameData()
{
  var filler = new Filler<Address>();
  var address1 = filler.SetRandomSeed(1234).Create();

  var filler2 = new Filler<Address>();
  var address2 = filler2.SetRandomSeed(1234).Create();

  Assert.AreEqual(address1.City, address2.City);
  Assert.AreEqual(address1.Country, address2.Country);
  Assert.AreEqual(address1.HouseNumber, address2.HouseNumber);
  Assert.AreEqual(address1.PostalCode, address2.PostalCode);
  Assert.AreEqual(address1.Street, address2.Street);
}