public void Can_Deep_Clone() { IRelationType item = _builder .WithId(1) .WithParentObjectType(Guid.NewGuid()) .WithChildObjectType(Guid.NewGuid()) .Build(); var clone = (RelationType)item.DeepClone(); Assert.AreNotSame(clone, item); Assert.AreEqual(clone, item); Assert.AreEqual(clone.Alias, item.Alias); Assert.AreEqual(clone.ChildObjectType, item.ChildObjectType); Assert.AreEqual(clone.ParentObjectType, item.ParentObjectType); Assert.AreEqual(clone.IsBidirectional, item.IsBidirectional); Assert.AreEqual(clone.Id, item.Id); Assert.AreEqual(clone.Key, item.Key); Assert.AreEqual(clone.Name, item.Name); Assert.AreEqual(clone.CreateDate, item.CreateDate); Assert.AreEqual(clone.UpdateDate, item.UpdateDate); // This double verifies by reflection PropertyInfo[] allProps = clone.GetType().GetProperties(); foreach (PropertyInfo propertyInfo in allProps) { Assert.AreEqual(propertyInfo.GetValue(clone, null), propertyInfo.GetValue(item, null)); } }
public void Is_Built_Correctly() { // Arrange const int id = 3; const string alias = "test"; const string name = "Test"; var key = Guid.NewGuid(); var createDate = DateTime.Now.AddHours(-2); var updateDate = DateTime.Now.AddHours(-1); var deleteDate = DateTime.Now; var parentObjectType = Guid.NewGuid(); var childObjectType = Guid.NewGuid(); const bool isBidirectional = true; const bool isDependency = true; var builder = new RelationTypeBuilder(); // Act var relationType = builder .WithId(id) .WithAlias(alias) .WithName(name) .WithKey(key) .WithCreateDate(createDate) .WithUpdateDate(updateDate) .WithDeleteDate(deleteDate) .WithParentObjectType(parentObjectType) .WithChildObjectType(childObjectType) .WithIsBidirectional(isBidirectional) .WithIsDependency(isDependency) .Build(); // Assert Assert.AreEqual(id, relationType.Id); Assert.AreEqual(alias, relationType.Alias); Assert.AreEqual(name, relationType.Name); Assert.AreEqual(key, relationType.Key); Assert.AreEqual(createDate, relationType.CreateDate); Assert.AreEqual(updateDate, relationType.UpdateDate); Assert.AreEqual(deleteDate, relationType.DeleteDate); Assert.AreEqual(parentObjectType, relationType.ParentObjectType); Assert.AreEqual(childObjectType, relationType.ChildObjectType); Assert.AreEqual(isBidirectional, relationType.IsBidirectional); Assert.AreEqual(isDependency, relationType.IsDependency); }