Skip to content

Commit 1a3f2a5

Browse files
committed
Merge pull request #5 from Tynamix/BREAK_CHANGE_Renaming
Break change renaming, completly fluent api refactoring
2 parents 1d18b4d + 7cac81b commit 1a3f2a5

38 files changed

+1111
-791
lines changed

ObjectFiller.Test/AddressFillingTest.cs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
22
using ObjectFiller.Test.TestPoco.Person;
33
using Tynamix.ObjectFiller;
44

@@ -10,8 +10,8 @@ public class AddressFillingTest
1010
[TestMethod]
1111
public void FillAllAddressProperties()
1212
{
13-
ObjectFiller<Address> addressFiller = new ObjectFiller<Address>();
14-
Address a = addressFiller.Fill();
13+
Filler<Address> addressFiller = new Filler<Address>();
14+
Address a = addressFiller.Create();
1515

1616
Assert.IsNotNull(a.City);
1717
Assert.IsNotNull(a.Country);
@@ -23,9 +23,10 @@ public void FillAllAddressProperties()
2323
[TestMethod]
2424
public void IgnoreCountry()
2525
{
26-
ObjectFiller<Address> addressFiller = new ObjectFiller<Address>();
27-
addressFiller.Setup().IgnoreProperties(x => x.Country);
28-
Address a = addressFiller.Fill();
26+
Filler<Address> addressFiller = new Filler<Address>();
27+
addressFiller.Setup()
28+
.OnProperty(x=>x.Country).IgnoreIt();
29+
Address a = addressFiller.Create();
2930

3031
Assert.IsNotNull(a.City);
3132
Assert.IsNull(a.Country);
@@ -37,9 +38,10 @@ public void IgnoreCountry()
3738
[TestMethod]
3839
public void IgnoreCountryAndCity()
3940
{
40-
ObjectFiller<Address> addressFiller = new ObjectFiller<Address>();
41-
addressFiller.Setup().IgnoreProperties(x => x.Country, x => x.City);
42-
Address a = addressFiller.Fill();
41+
Filler<Address> addressFiller = new Filler<Address>();
42+
addressFiller.Setup()
43+
.OnProperty(x => x.Country, x => x.City).IgnoreIt();
44+
Address a = addressFiller.Create();
4345

4446
Assert.IsNull(a.City);
4547
Assert.IsNull(a.Country);
@@ -51,9 +53,10 @@ public void IgnoreCountryAndCity()
5153
[TestMethod]
5254
public void SetupCityPropertyWithConstantValue()
5355
{
54-
ObjectFiller<Address> addressFiller = new ObjectFiller<Address>();
55-
addressFiller.Setup().RandomizerForProperty(() => "City", ad => ad.City);
56-
Address a = addressFiller.Fill();
56+
Filler<Address> addressFiller = new Filler<Address>();
57+
addressFiller.Setup()
58+
.OnProperty(ad => ad.City).Use(() => "City");
59+
Address a = addressFiller.Create();
5760

5861
Assert.AreEqual("City", a.City);
5962
Assert.IsNotNull(a.Country);
@@ -65,10 +68,10 @@ public void SetupCityPropertyWithConstantValue()
6568
[TestMethod]
6669
public void SetupCityAndCountryPropertyWithConstantValue()
6770
{
68-
ObjectFiller<Address> addressFiller = new ObjectFiller<Address>();
71+
Filler<Address> addressFiller = new Filler<Address>();
6972
addressFiller.Setup()
70-
.RandomizerForProperty(() => "CityCountry", ad => ad.City, ad => ad.Country);
71-
Address a = addressFiller.Fill();
73+
.OnProperty(ad => ad.City, ad => ad.Country).Use(() => "CityCountry");
74+
Address a = addressFiller.Create();
7275

7376
Assert.AreEqual("CityCountry", a.City);
7477
Assert.IsNotNull(a.Country);
Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using System;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
23
using ObjectFiller.Test.TestPoco.Library;
34
using Tynamix.ObjectFiller;
45

@@ -10,10 +11,10 @@ public class LibraryFillingTest
1011
[TestMethod]
1112
public void TestFillLibraryWithSimpleTypes()
1213
{
13-
ObjectFiller<LibraryConstructorWithSimple> lib = new ObjectFiller<LibraryConstructorWithSimple>();
14+
Filler<LibraryConstructorWithSimple> lib = new Filler<LibraryConstructorWithSimple>();
1415
lib.Setup()
15-
.IgnoreProperties(x => x.Books);
16-
LibraryConstructorWithSimple filledLib = lib.Fill();
16+
.OnProperty(x => x.Books).IgnoreIt();
17+
LibraryConstructorWithSimple filledLib = lib.Create();
1718

1819
Assert.IsNull(filledLib.Books);
1920
Assert.IsNotNull(filledLib);
@@ -24,12 +25,12 @@ public void TestFillLibraryWithSimpleTypes()
2425
[TestMethod]
2526
public void TestFillLibraryWithListOfBooks()
2627
{
27-
ObjectFiller<LibraryConstructorList> lib = new ObjectFiller<LibraryConstructorList>();
28+
Filler<LibraryConstructorList> lib = new Filler<LibraryConstructorList>();
2829
lib.Setup()
29-
.IgnoreProperties(x => x.Books, x => x.Name);
30+
.OnProperty(x => x.Books).IgnoreIt()
31+
.OnProperty(x => x.Name).IgnoreIt();
3032

31-
32-
LibraryConstructorList filledLib = lib.Fill();
33+
LibraryConstructorList filledLib = lib.Create();
3334

3435
Assert.IsNotNull(filledLib);
3536
Assert.IsNotNull(filledLib.Books);
@@ -39,54 +40,74 @@ public void TestFillLibraryWithListOfBooks()
3940
[TestMethod]
4041
public void TestFillLibraryWithListOfIBooks()
4142
{
42-
ObjectFiller<LibraryConstructorList> lib = new ObjectFiller<LibraryConstructorList>();
43+
Filler<LibraryConstructorList> lib = new Filler<LibraryConstructorList>();
4344
lib.Setup()
44-
.IgnoreProperties(x => x.Books)
45-
.RegisterInterface<IBook, Book>();
45+
.OnProperty(x => x.Books).IgnoreIt()
46+
.OnType<IBook>().CreateInstanceOf<Book>();
4647

47-
LibraryConstructorList filledLib = lib.Fill();
48+
LibraryConstructorList filledLib = lib.Create();
4849

4950
Assert.IsNotNull(filledLib.Books);
5051
}
5152

5253
[TestMethod]
5354
public void TestFillLibraryWithPocoOfABook()
5455
{
55-
ObjectFiller<LibraryConstructorPoco> lib = new ObjectFiller<LibraryConstructorPoco>();
56+
Filler<LibraryConstructorPoco> lib = new Filler<LibraryConstructorPoco>();
5657
lib.Setup()
57-
.IgnoreProperties(x => x.Books);
58-
58+
.OnProperty(x => x.Books).IgnoreIt();
5959

60-
LibraryConstructorPoco filledLib = lib.Fill();
60+
LibraryConstructorPoco filledLib = lib.Create();
6161
Assert.IsNotNull(filledLib.Books);
6262
Assert.AreEqual(1, filledLib.Books.Count);
6363
}
6464

6565
[TestMethod]
6666
public void TestFillLibraryWithDictionary()
6767
{
68-
ObjectFiller<LibraryConstructorDictionary> lib = new ObjectFiller<LibraryConstructorDictionary>();
68+
Filler<LibraryConstructorDictionary> lib = new Filler<LibraryConstructorDictionary>();
6969
lib.Setup()
70-
.RegisterInterface<IBook, Book>()
71-
.IgnoreProperties(x => x.Books);
72-
70+
.OnType<IBook>().CreateInstanceOf<Book>()
71+
.OnProperty(x => x.Books).IgnoreIt();
7372

74-
LibraryConstructorDictionary filledLib = lib.Fill();
73+
LibraryConstructorDictionary filledLib = lib.Create();
7574
Assert.IsNotNull(filledLib.Books);
7675
}
7776

7877
[TestMethod]
7978
public void TestFillLibraryWithDictionaryAndPoco()
8079
{
81-
ObjectFiller<LibraryConstructorDictionary> lib = new ObjectFiller<LibraryConstructorDictionary>();
80+
Filler<LibraryConstructorDictionary> lib = new Filler<LibraryConstructorDictionary>();
8281
lib.Setup()
83-
.IgnoreProperties(x => x.Books, x => x.Name);
82+
.OnProperty(x => x.Books).IgnoreIt()
83+
.OnProperty(x => x.Name).IgnoreIt();
8484

8585

86-
LibraryConstructorDictionary filledLib = lib.Fill();
86+
LibraryConstructorDictionary filledLib = lib.Create();
8787
Assert.IsNotNull(filledLib.Books);
8888
Assert.IsNotNull(filledLib.Name);
8989

9090
}
91+
92+
93+
public class Person
94+
{
95+
public string Name { get; set; }
96+
public string LastName { get; set; }
97+
public int Age { get; set; }
98+
public DateTime Birthday { get; set; }
99+
}
100+
101+
public class HelloFiller
102+
{
103+
public void FillPerson()
104+
{
105+
Person person = new Person();
106+
107+
Filler<Person> pFiller = new Filler<Person>();
108+
Person p = pFiller.Fill(person);
109+
}
110+
}
111+
91112
}
92-
}
113+
}

ObjectFiller.Test/ListFillingTest.cs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using Microsoft.VisualStudio.TestTools.UnitTesting;
33
using ObjectFiller.Test.TestPoco.ListTest;
44
using Tynamix.ObjectFiller;
@@ -11,10 +11,11 @@ public class ListFillingTest
1111
[TestMethod]
1212
public void TestFillAllListsExceptArray()
1313
{
14-
ObjectFiller<EntityCollection> eFiller = new ObjectFiller<EntityCollection>();
14+
Filler<EntityCollection> eFiller = new Filler<EntityCollection>();
1515
eFiller.Setup()
16-
.IgnoreProperties(ec => ec.EntityArray);
17-
EntityCollection entity = eFiller.Fill();
16+
.OnProperty(x => x.EntityArray).IgnoreIt();
17+
18+
EntityCollection entity = eFiller.Create();
1819

1920
Assert.IsNotNull(entity);
2021
Assert.IsNotNull(entity.EntityList);
@@ -26,10 +27,10 @@ public void TestFillAllListsExceptArray()
2627
[TestMethod]
2728
public void TestFillList()
2829
{
29-
ObjectFiller<EntityCollection> eFiller = new ObjectFiller<EntityCollection>();
30+
Filler<EntityCollection> eFiller = new Filler<EntityCollection>();
3031
eFiller.Setup()
31-
.RandomizerForProperty(GetArray, ec => ec.EntityArray);
32-
EntityCollection entity = eFiller.Fill();
32+
.OnProperty(ec => ec.EntityArray).Use(GetArray);
33+
EntityCollection entity = eFiller.Create();
3334

3435
Assert.IsNotNull(entity);
3536
Assert.IsNotNull(entity.EntityList);
@@ -42,23 +43,21 @@ public void TestFillList()
4243

4344
private Entity[] GetArray()
4445
{
45-
ObjectFiller<Entity> of = new ObjectFiller<Entity>();
46+
Filler<Entity> of = new Filler<Entity>();
4647

4748
List<Entity> entities = new List<Entity>();
48-
entities.Add(of.Fill());
49-
entities.Add(of.Fill());
50-
entities.Add(of.Fill());
51-
entities.Add(of.Fill());
52-
entities.Add(of.Fill());
53-
entities.Add(of.Fill());
54-
entities.Add(of.Fill());
55-
entities.Add(of.Fill());
56-
entities.Add(of.Fill());
49+
entities.Add(of.Create());
50+
entities.Add(of.Create());
51+
entities.Add(of.Create());
52+
entities.Add(of.Create());
53+
entities.Add(of.Create());
54+
entities.Add(of.Create());
55+
entities.Add(of.Create());
56+
entities.Add(of.Create());
57+
entities.Add(of.Create());
5758

5859

5960
return entities.ToArray();
60-
61-
6261
}
6362
}
64-
}
63+
}

ObjectFiller.Test/LoremIpsumPluginTest.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
using System;
1+
using System;
22
using Microsoft.VisualStudio.TestTools.UnitTesting;
33
using ObjectFiller.Test.TestPoco.Library;
44
using Tynamix.ObjectFiller;
5-
using Tynamix.ObjectFiller.Plugins;
65

76
namespace ObjectFiller.Test
87
{
@@ -14,12 +13,12 @@ public void TestPlugin()
1413
{
1514
int isbnWordCount = 1000;
1615
int nameWordCount = 500;
17-
ObjectFiller<Book> bookFill = new ObjectFiller<Book>();
16+
Filler<Book> bookFill = new Filler<Book>();
1817
bookFill.Setup()
19-
.RandomizerForProperty(new LoremIpsumPlugin(isbnWordCount), x => x.ISBN)
20-
.RandomizerForProperty(new LoremIpsumPlugin(nameWordCount), x => x.Name);
18+
.OnProperty(x => x.ISBN).Use(new LoremIpsum(isbnWordCount))
19+
.OnProperty(x => x.Name).Use(new LoremIpsum(nameWordCount));
2120

22-
Book book = bookFill.Fill();
21+
Book book = bookFill.Create();
2322

2423
Assert.IsNotNull(book);
2524
Assert.IsNotNull(book.ISBN);

ObjectFiller.Test/ObjectFiller.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<Compile Include="PersonFillingTest.cs" />
5353
<Compile Include="Properties\AssemblyInfo.cs" />
5454
<Compile Include="ObjectFillerTest.cs" />
55+
<Compile Include="RangePluginTest.cs" />
5556
<Compile Include="TestPoco\Library\Book.cs" />
5657
<Compile Include="TestPoco\Library\IBook.cs" />
5758
<Compile Include="TestPoco\Library\Library.cs" />
@@ -65,6 +66,8 @@
6566
<Compile Include="TestPoco\Person\IAddress.cs" />
6667
<Compile Include="TestPoco\Person\Person.cs" />
6768
<Compile Include="PatternGeneratorTest.cs" />
69+
<Compile Include="TestPoco\Person\OrderedPersonProperties.cs" />
70+
<Compile Include="TestPoco\SimpleList.cs" />
6871
</ItemGroup>
6972
<ItemGroup>
7073
<ProjectReference Include="..\ObjectFiller\ObjectFiller.csproj">

ObjectFiller.Test/ObjectFillerTest.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using Microsoft.VisualStudio.TestTools.UnitTesting;
44
using ObjectFiller.Test.TestPoco.Person;
55
using Tynamix.ObjectFiller;
6-
using Tynamix.ObjectFiller.Plugins;
76

87
namespace ObjectFiller.Test
98
{
@@ -14,17 +13,17 @@ public class ObjectFillerTest
1413
public void TestFillPerson()
1514
{
1615
Person p = new Person();
17-
ObjectFiller<Person> objectFiller = new ObjectFiller<Person>();
18-
objectFiller.Setup()
19-
.RegisterInterface<IAddress, Address>()
20-
.RandomizerForType(new MnemonicStringPlugin(10))
21-
.RandomizerForProperty(new MnemonicStringPlugin(1), person => person.FirstName)
22-
.RandomizerForProperty(new RandomListItem<string>(new List<string>() { "Maik", "Tom", "Anton" }), person => person.LastName)
23-
.RandomizerForProperty(() => new Random().Next(12, 83), person => person.Age)
16+
Filler<Person> filler = new Filler<Person>();
17+
filler.Setup()
18+
.OnType<IAddress>().CreateInstanceOf<Address>()
19+
.OnType<string>().Use(new MnemonicString(10))
20+
.OnProperty(person => person.FirstName).Use(new MnemonicString(1))
21+
.OnProperty(person => person.LastName).Use(new RandomListItem<string>(new List<string>() { "Maik", "Tom", "Anton" }))
22+
.OnProperty(person => person.Age).Use(() => new Random().Next(12, 83))
2423
.SetupFor<Address>()
25-
.IgnoreProperties(a => a.City, a => a.Country);
24+
.OnProperty(x => x.City, x => x.Country).IgnoreIt();
2625

27-
Person pFilled = objectFiller.Fill(p);
26+
Person pFilled = filler.Fill(p);
2827
}
2928
}
3029
}

0 commit comments

Comments
 (0)