public void RecursionFillingTest() { var faker = new FakerLibrary.Faker(); A test = null; test = faker.Create <A>(); Assert.IsNull(test.b.c.a); }
public void ObjectFillingTest() { var faker = new FakerLibrary.Faker(); object test = null; test = faker.Create <Test1>(); Assert.IsNotNull(test); }
public void ListFillingTest() { var list = new List <Test1> { }; var faker = new FakerLibrary.Faker(); list = faker.Create <List <Test1> >(); Assert.AreNotEqual(list.Count, 0); }
public void StructFillingTest() { var faker = new FakerLibrary.Faker(); Test2 test = faker.Create <Test2>(); Assert.AreNotEqual(test.a, 0); Assert.AreNotEqual(test.b, 0); Assert.AreNotEqual(test.c, 0.0); Assert.AreNotEqual(test.d, ""); Assert.AreNotEqual(test.ab, 0); }
public void PrimitiveTypeFillingTest() { int? i = null; long? j = null; double? k = null; DateTime?z = null; string e = null; var faker = new FakerLibrary.Faker(); i = faker.Create <int>(); j = faker.Create <long>(); k = faker.Create <double>(); z = faker.Create <DateTime>(); e = faker.Create <string>(); Assert.IsNotNull(i); Assert.IsNotNull(j); Assert.IsNotNull(k); Assert.IsNotNull(z); Assert.IsNotNull(e); }
public object Generate(Type type) { IList listinstance = (IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(type)); int listsize = _random.Next(1, 21); for (int i = 0; i < listsize; i++) { listinstance.Add(_currentFaker.Create(type)); } return(listinstance); }
static void Main(string[] args) { var faker = new FakerLibrary.Faker(); var test = faker.Create <string>(); var test1 = faker.Create <int>(); var test5 = faker.Create <Foo>(); var test6 = faker.Create <List <int> >(); var test7 = faker.Create <List <Foo> >(); var test8 = faker.Create <A>(); Console.ReadKey(); }
public static object GenerateValue(Type t) { //generate inserted DTO if need if (_DTOList.Contains(t)) { if (_cycleControlList.Contains(t)) { _cycleControlList.Remove(t); return(null); } else { //copy cycleControlList before recursive call MemoryStream tmpCycleControllListMS = _jsonSerializer.serialize(_cycleControlList); _cycleControlList.Add(t); object tmpObject = _faker.Create(t); //extract list on recursive call return _cycleControlList = _jsonSerializer.deserialize(tmpCycleControllListMS); return(tmpObject); } } //generate non-DTO field/property if (_generatorDictionary.ContainsKey(t.Name)) { //if baseClassType return(_generatorDictionary[t.Name].Generate()); } else { if (_collectionGeneratorDictionary.ContainsKey(t.Name)) { //if collectionType return(_collectionGeneratorDictionary[t.Name].Generate(t.GenericTypeArguments[0])); } else { //no generator return((t.IsValueType) ? Activator.CreateInstance(t) : null); } } }