-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from Tynamix/develop
FI from DEV
- Loading branch information
Showing
22 changed files
with
635 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Tynamix.ObjectFiller.Test/BugfixTests/Bug129WrongDateTimeGeneration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
|
||
namespace Tynamix.ObjectFiller.Test.BugfixTests | ||
{ | ||
[TestClass] | ||
public class Bug129WrongDateTimeGeneration | ||
{ | ||
public class TestEntity | ||
{ | ||
public DateTime Date { get; set; } | ||
} | ||
|
||
[TestMethod] | ||
public void InvalidDateTimeValuesDueToDaylightSavingsTime() | ||
{ | ||
Filler<TestEntity> filler = new Filler<TestEntity>(); | ||
var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); | ||
filler.Setup().OnType<DateTime>().Use(new DateTimeRange(new DateTime(2007, 3, 11, 1, 0, 0, DateTimeKind.Unspecified), new DateTime(2007, 3, 11, 4, 00, 0, DateTimeKind.Unspecified), timeZoneInfo)); | ||
|
||
for (int i = 0; i < 1000; i++) | ||
{ | ||
var result = filler.Create(); | ||
Assert.IsFalse(timeZoneInfo.IsInvalidTime(result.Date), $"{result.Date} is invalid"); | ||
} | ||
|
||
filler = new Filler<TestEntity>(); | ||
filler.Setup().OnType<DateTime>().Use(new DateTimeRange(new DateTime(2022, 3, 27, 1, 0, 0, DateTimeKind.Unspecified), new DateTime(2022, 3, 27, 4, 00, 0, DateTimeKind.Unspecified))); | ||
|
||
for (int i = 0; i < 1000; i++) | ||
{ | ||
var result = filler.Create(); | ||
Assert.IsFalse(TimeZoneInfo.Local.IsInvalidTime(result.Date), $"{result.Date} is invalid"); | ||
} | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...x.ObjectFiller.Test/BugfixTests/Bug132PropertiesOnBaseClassesNotPopulatedBeyond2Levels.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Tynamix.ObjectFiller.Test.BugfixTests | ||
{ | ||
[TestClass] | ||
public class Bug132PropertiesOnBaseClassesNotPopulatedBeyond2Levels | ||
{ | ||
public class BaseId | ||
{ | ||
public string Id { get; set; } | ||
} | ||
|
||
public class BaseWithAudit : BaseId | ||
{ | ||
public string CreatedBy { get; set; } | ||
public string UpdatedBy { get; set; } | ||
} | ||
|
||
public class Person : BaseWithAudit | ||
{ | ||
public string Name { get; set; } | ||
public string LastName { get; set; } | ||
} | ||
[TestMethod] | ||
public void Bug132PropertiesOnBaseClassNotPopulated() | ||
{ | ||
var filler = new Filler<Person>(); | ||
var x = filler.Create(); | ||
Assert.IsFalse(string.IsNullOrWhiteSpace(x.Name)); | ||
Assert.IsFalse(string.IsNullOrWhiteSpace(x.LastName)); | ||
Assert.IsFalse(string.IsNullOrWhiteSpace(x.CreatedBy)); | ||
Assert.IsFalse(string.IsNullOrWhiteSpace(x.UpdatedBy)); | ||
Assert.IsFalse(string.IsNullOrWhiteSpace(x.Id)); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Tynamix.ObjectFiller.Test/BugfixTests/Bug136RecordsObjectReferenceException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
#if NET6_0_OR_GREATER | ||
namespace Tynamix.ObjectFiller.Test.BugfixTests | ||
{ | ||
public record Product | ||
{ | ||
public string Name { get; init; } | ||
public int CategoryId { get; set; } | ||
} | ||
|
||
public record Person(string Name, string Username); | ||
|
||
[TestClass] | ||
public class Bug136RecordsObjectReferenceException | ||
{ | ||
[TestMethod] | ||
public void RecordsShouldBeFilled() | ||
{ | ||
Filler<Product> filler = new Filler<Product>(); | ||
var product = filler.Create(); | ||
Assert.IsNotNull(product); | ||
Assert.IsFalse(string.IsNullOrWhiteSpace(product.Name)); | ||
|
||
var filler2 = new Filler<Person>(); | ||
var person = filler2.Create(); | ||
Assert.IsNotNull(person); | ||
Assert.IsFalse(string.IsNullOrWhiteSpace(person.Name)); | ||
Assert.IsFalse(string.IsNullOrWhiteSpace(person.Username)); | ||
} | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Tynamix.ObjectFiller.Test | ||
{ | ||
[TestClass] | ||
public class DictionaryFillingTest | ||
{ | ||
public class EntityA | ||
{ | ||
public string Name { get; set; } | ||
public int ID { get; set; } | ||
public IDictionary<string, string> InterfaceDictionary { get; set; } | ||
public Dictionary<string, string> ConcreteDictionary { get; set; } | ||
|
||
public NestedEntity NestedEntity { get; set; } | ||
} | ||
|
||
public class NestedEntity | ||
{ | ||
public IDictionary<string, string> InterfaceDictionary { get; set; } | ||
public Dictionary<string, string> ConcreteDictionary { get; set; } | ||
} | ||
|
||
|
||
[TestMethod] | ||
public void TestDictionaryType() | ||
{ | ||
Filler<EntityA> filler = new Filler<EntityA>(); | ||
|
||
var result = filler.Create(); | ||
|
||
Assert.IsNotNull(result.Name); | ||
Assert.IsNotNull(result.ID); | ||
Assert.IsNotNull(result.InterfaceDictionary); | ||
Assert.IsTrue(result.InterfaceDictionary.Any()); | ||
Assert.IsNotNull(result.ConcreteDictionary); | ||
Assert.IsTrue(result.ConcreteDictionary.Any()); | ||
|
||
Assert.IsNotNull(result.NestedEntity); | ||
Assert.IsNotNull(result.NestedEntity.InterfaceDictionary); | ||
Assert.IsTrue(result.NestedEntity.InterfaceDictionary.Any()); | ||
Assert.IsNotNull(result.NestedEntity.ConcreteDictionary); | ||
Assert.IsTrue(result.NestedEntity.ConcreteDictionary.Any()); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.