Skip to content

Commit 6e9285e

Browse files
committed
Merge pull request #55 from Tynamix/FEATURE_MoveToNETCore
ObjectFiller moved to .NET Core
2 parents 8352190 + b7b4290 commit 6e9285e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+14686
-1432
lines changed

ObjectFiller.Test/AddressFillingTest.cs

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

55
namespace ObjectFiller.Test
66
{
77
using System.Linq;
88

9-
[TestClass]
9+
1010
public class AddressFillingTest
1111
{
12-
[TestMethod]
12+
[Fact]
1313
public void FillAllAddressProperties()
1414
{
1515
Filler<Address> addressFiller = new Filler<Address>();
1616
Address a = addressFiller.Create();
1717

18-
Assert.IsNotNull(a.City);
19-
Assert.IsNotNull(a.Country);
20-
Assert.AreNotEqual(0, a.HouseNumber);
21-
Assert.IsNotNull(a.PostalCode);
22-
Assert.IsNotNull(a.Street);
18+
Assert.NotNull(a.City);
19+
Assert.NotNull(a.Country);
20+
Assert.NotEqual(0, a.HouseNumber);
21+
Assert.NotNull(a.PostalCode);
22+
Assert.NotNull(a.Street);
2323
}
2424

25-
[TestMethod]
25+
[Fact]
2626
public void IgnoreCountry()
2727
{
2828
Filler<Address> addressFiller = new Filler<Address>();
2929
addressFiller.Setup()
3030
.OnProperty(x => x.Country).IgnoreIt();
3131
Address a = addressFiller.Create();
3232

33-
Assert.IsNotNull(a.City);
34-
Assert.IsNull(a.Country);
35-
Assert.AreNotEqual(0, a.HouseNumber);
36-
Assert.IsNotNull(a.PostalCode);
37-
Assert.IsNotNull(a.Street);
33+
Assert.NotNull(a.City);
34+
Assert.Null(a.Country);
35+
Assert.NotEqual(0, a.HouseNumber);
36+
Assert.NotNull(a.PostalCode);
37+
Assert.NotNull(a.Street);
3838
}
3939

40-
[TestMethod]
40+
[Fact]
4141
public void IgnoreCountryAndCity()
4242
{
4343
Filler<Address> addressFiller = new Filler<Address>();
4444
addressFiller.Setup()
4545
.OnProperty(x => x.Country, x => x.City).IgnoreIt();
4646
Address a = addressFiller.Create();
4747

48-
Assert.IsNull(a.City);
49-
Assert.IsNull(a.Country);
50-
Assert.AreNotEqual(0, a.HouseNumber);
51-
Assert.IsNotNull(a.PostalCode);
52-
Assert.IsNotNull(a.Street);
48+
Assert.Null(a.City);
49+
Assert.Null(a.Country);
50+
Assert.NotEqual(0, a.HouseNumber);
51+
Assert.NotNull(a.PostalCode);
52+
Assert.NotNull(a.Street);
5353
}
5454

55-
[TestMethod]
55+
[Fact]
5656
public void SetupCityPropertyWithConstantValue()
5757
{
5858
Filler<Address> addressFiller = new Filler<Address>();
5959
addressFiller.Setup()
6060
.OnProperty(ad => ad.City).Use(() => "City");
6161
Address a = addressFiller.Create();
6262

63-
Assert.AreEqual("City", a.City);
64-
Assert.IsNotNull(a.Country);
65-
Assert.AreNotEqual(0, a.HouseNumber);
66-
Assert.IsNotNull(a.PostalCode);
67-
Assert.IsNotNull(a.Street);
63+
Assert.Equal("City", a.City);
64+
Assert.NotNull(a.Country);
65+
Assert.NotEqual(0, a.HouseNumber);
66+
Assert.NotNull(a.PostalCode);
67+
Assert.NotNull(a.Street);
6868
}
6969

70-
[TestMethod]
70+
[Fact]
7171
public void SetupCityAndCountryPropertyWithConstantValue()
7272
{
7373
Filler<Address> addressFiller = new Filler<Address>();
7474
addressFiller.Setup()
7575
.OnProperty(ad => ad.City, ad => ad.Country).Use(() => "CityCountry");
7676
Address a = addressFiller.Create();
7777

78-
Assert.AreEqual("CityCountry", a.City);
79-
Assert.IsNotNull(a.Country);
80-
Assert.AreNotEqual(0, a.HouseNumber);
81-
Assert.IsNotNull(a.PostalCode);
82-
Assert.IsNotNull(a.Street);
78+
Assert.Equal("CityCountry", a.City);
79+
Assert.NotNull(a.Country);
80+
Assert.NotEqual(0, a.HouseNumber);
81+
Assert.NotNull(a.PostalCode);
82+
Assert.NotNull(a.Street);
8383
}
8484

85-
[TestMethod]
85+
[Fact]
8686
public void SetupTheAdressWithStaticValues()
8787
{
8888
Filler<Address> addressFiller = new Filler<Address>();
@@ -93,13 +93,13 @@ public void SetupTheAdressWithStaticValues()
9393
.OnProperty(x => x.PostalCode).Use(() => "0011100");
9494

9595
var address = addressFiller.Create();
96-
Assert.AreEqual("Dresden", address.City);
97-
Assert.AreEqual("Germany", address.Country);
98-
Assert.AreEqual("0011100", address.PostalCode);
99-
Assert.AreEqual(10, address.HouseNumber);
96+
Assert.Equal("Dresden", address.City);
97+
Assert.Equal("Germany", address.Country);
98+
Assert.Equal("0011100", address.PostalCode);
99+
Assert.Equal(10, address.HouseNumber);
100100
}
101101

102-
[TestMethod]
102+
[Fact]
103103
public void RandomListPluginShallReturnDifferentValues()
104104
{
105105
Filler<Address> addressFiller = new Filler<Address>();
@@ -108,15 +108,15 @@ public void RandomListPluginShallReturnDifferentValues()
108108

109109
var addresses = addressFiller.Create(1000);
110110

111-
Assert.IsTrue(addresses.Any(x => x.City == "Test2"));
111+
Assert.True(addresses.Any(x => x.City == "Test2"));
112112

113113
addressFiller = new Filler<Address>();
114114

115115
addressFiller.Setup().OnProperty(x => x.City).Use(new RandomListItem<string>("Test1"));
116116

117117
addresses = addressFiller.Create(1000);
118118

119-
Assert.IsTrue(addresses.All(x => x.City == "Test1"));
119+
Assert.True(addresses.All(x => x.City == "Test1"));
120120

121121
}
122122

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
namespace ObjectFiller.Test
22
{
3-
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using Xunit;
44

55
using Tynamix.ObjectFiller;
66

7-
[TestClass]
7+
88
public class CityNamesPluginTest
99
{
10-
[TestMethod]
10+
[Fact]
1111
public void RandomNameIsReturned()
1212
{
1313
var sut = new CityName();
1414
var value = sut.GetValue();
1515

16-
Assert.IsFalse(string.IsNullOrEmpty(value));
16+
Assert.False(string.IsNullOrEmpty(value));
1717
}
1818
}
1919
}

ObjectFiller.Test/CopyConstructorTest.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
using System;
2-
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using Xunit;
33
using Tynamix.ObjectFiller;
44

55
namespace ObjectFiller.Test
66
{
7-
[TestClass]
7+
88
public class CopyConstructorTest
99
{
1010

11-
[TestMethod]
11+
[Fact]
1212
public void WhenClassWithCopyConstructorIsCreatedNoExceptionShallBeThrown()
1313
{
1414
var f = new Filler<ClassWithCopyConstructorAndNormalConstructor>();
1515
var cc = f.Create();
1616

17-
Assert.IsNotNull(cc);
17+
Assert.NotNull(cc);
1818
}
1919

20-
[TestMethod]
21-
[ExpectedException(typeof(InvalidOperationException))]
20+
[Fact]
2221
public void WhenClassWithJustCopyConstructorIsCreatedAExceptionShallBeThrown()
2322
{
2423
var f = new Filler<ClassWithCopyConstructor>();
25-
var cc = f.Create();
24+
Assert.Throws<InvalidOperationException>(() => f.Create());
2625

2726
}
2827
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
namespace ObjectFiller.Test
22
{
3-
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using Xunit;
44

55
using Tynamix.ObjectFiller;
66

7-
[TestClass]
7+
88
public class CountryNamesPlugin
99
{
10-
[TestMethod]
10+
[Fact]
1111
public void RandomNameIsReturned()
1212
{
1313
var sut = new CountryName();
1414
var value = sut.GetValue();
1515

16-
Assert.IsFalse(string.IsNullOrEmpty(value));
16+
Assert.False(string.IsNullOrEmpty(value));
1717
}
1818
}
1919
}

ObjectFiller.Test/CreateInstanceTest.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System.Collections.Generic;
22
using System.Linq;
3-
using System.Security.Cryptography.X509Certificates;
4-
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using Xunit;
54
using Tynamix.ObjectFiller;
65

76
namespace ObjectFiller.Test
@@ -50,11 +49,11 @@ public ParentOfParent()
5049
}
5150

5251

53-
[TestClass]
52+
5453
public class CreateInstanceTest
5554
{
5655

57-
[TestMethod]
56+
[Fact]
5857
public void TestCreateInstanceOfChildOne()
5958
{
6059
Filler<ParentOfParent> p = new Filler<ParentOfParent>();
@@ -65,12 +64,12 @@ public void TestCreateInstanceOfChildOne()
6564

6665
var pop = p.Create();
6766

68-
Assert.IsNotNull(pop);
69-
Assert.IsNotNull(pop.Parents);
70-
Assert.IsTrue(pop.Parents.All(x => x is ChildOne));
71-
Assert.IsFalse(pop.Parents.Any(x => x is ChildTwo));
67+
Assert.NotNull(pop);
68+
Assert.NotNull(pop.Parents);
69+
Assert.True(pop.Parents.All(x => x is ChildOne));
70+
Assert.False(pop.Parents.Any(x => x is ChildTwo));
7271

73-
Assert.IsTrue(pop.Parents.Cast<ChildOne>().All(x => x.Name == "TEST"));
72+
Assert.True(pop.Parents.Cast<ChildOne>().All(x => x.Name == "TEST"));
7473

7574

7675
}

ObjectFiller.Test/DateTimeRangeTest.cs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System;
44
using System.Linq;
55

6-
using Microsoft.VisualStudio.TestTools.UnitTesting;
6+
using Xunit;
77

88
using Tynamix.ObjectFiller;
99

@@ -12,10 +12,10 @@ public class DateRangeTestClass
1212
public DateTime Date { get; set; }
1313
}
1414

15-
[TestClass]
15+
1616
public class DateTimeRangeTest
1717
{
18-
[TestMethod]
18+
[Fact]
1919
public void WhenGettingDatesBetweenNowAnd31DaysAgo()
2020
{
2121
Filler<DateRangeTestClass> filler = new Filler<DateRangeTestClass>();
@@ -25,10 +25,10 @@ public void WhenGettingDatesBetweenNowAnd31DaysAgo()
2525

2626
var d = filler.Create(1000);
2727

28-
Assert.IsTrue(d.All(x => x.Date < DateTime.Now && x.Date > DateTime.Now.AddDays(-31)));
28+
Assert.True(d.All(x => x.Date < DateTime.Now && x.Date > DateTime.Now.AddDays(-31)));
2929
}
3030

31-
[TestMethod]
31+
[Fact]
3232
public void WhenStartDateIsBiggerThenEndDateTheDatesShouldBeSwitched()
3333
{
3434
Filler<DateRangeTestClass> filler = new Filler<DateRangeTestClass>();
@@ -38,10 +38,10 @@ public void WhenStartDateIsBiggerThenEndDateTheDatesShouldBeSwitched()
3838

3939
var d = filler.Create(1000);
4040

41-
Assert.IsTrue(d.All(x => x.Date < DateTime.Now && x.Date > DateTime.Now.AddDays(-31)));
41+
Assert.True(d.All(x => x.Date < DateTime.Now && x.Date > DateTime.Now.AddDays(-31)));
4242
}
4343

44-
[TestMethod]
44+
[Fact]
4545
public void WhenStartDateAndEndDateIsSetItShouldFindOnlyDatesInBetweenThisTwoDates()
4646
{
4747
var startDate = new DateTime(2000, 11, 10);
@@ -53,7 +53,20 @@ public void WhenStartDateAndEndDateIsSetItShouldFindOnlyDatesInBetweenThisTwoDat
5353

5454
var d = filler.Create(1000);
5555
d.ToList().ForEach(x => Console.WriteLine(x.Date));
56-
Assert.IsTrue(d.All(x => x.Date < endDate && x.Date > startDate));
56+
Assert.True(d.All(x => x.Date < endDate && x.Date > startDate));
57+
}
58+
59+
[Fact]
60+
public void WhenConstructorWithDateTimeNowWillBeCalledNoExceptionShouldBeThrown()
61+
{
62+
Filler<DateRangeTestClass> filler = new Filler<DateRangeTestClass>();
63+
64+
filler.Setup().OnProperty(x => x.Date).Use(new DateTimeRange(DateTime.Now));
65+
66+
var dateTime = filler.Create();
67+
68+
Assert.True(dateTime.Date > DateTime.MinValue);
69+
Assert.True(dateTime.Date < DateTime.MaxValue);
5770
}
5871
}
5972
}

ObjectFiller.Test/DefaultDatatypeMappingsTest.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
using System;
22
using System.Diagnostics;
33
using System.Linq;
4-
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
using Xunit;
55
using Tynamix.ObjectFiller;
66

77
namespace ObjectFiller.Test
88
{
9-
[TestClass]
9+
1010
public class DefaultDatatypeMappingsTest
1111
{
12-
[TestMethod]
12+
[Fact]
1313
public void Ensure_that_double_does_not_return_infinity()
1414
{
1515
var filler = new Filler<MyClass>();
1616
var myClass = filler.Create();
17-
Assert.IsFalse(double.IsInfinity(myClass._double));
17+
Assert.False(double.IsInfinity(myClass._double));
1818
}
1919

20-
[TestMethod]
20+
[Fact]
2121
public void Ensure_that_each_primitive_datatype_is_mapped_by_default()
2222
{
2323
var filler = new Filler<MyClass>();
2424
var myClasses = filler.Create(100).ToArray();
2525
foreach (var myClass in myClasses)
2626
{
27-
Assert.AreNotEqual(default(Guid), myClass._Guid);
28-
Assert.AreNotEqual(default(decimal), myClass._Decimal);
27+
Assert.NotEqual(default(Guid), myClass._Guid);
28+
Assert.NotEqual(default(decimal), myClass._Decimal);
2929
}
3030
}
3131

0 commit comments

Comments
 (0)