Exemplo n.º 1
0
        public void ShallowCopyEntity_CopiesEntity_ResettingId()
        {
            // Arrange
            var original = HiveModelCreationHelper.MockTypedEntity(true);

            original.RelationProxies.LazyLoadDelegate = x => new RelationProxyBucket();

            // Guard against bad test data
            foreach (var attribute in original.Attributes)
            {
                Assert.AreNotEqual(HiveId.Empty, attribute.Id);
                Assert.NotNull(attribute.AttributeDefinition);
                Assert.AreNotEqual(HiveId.Empty, attribute.AttributeDefinition.Id);
            }

            // Act
            Thread.Sleep(250); // Ensure copy dates are newer
            var copy = EntityExtensions.CreateShallowCopy(original);

            // Assert
            DoAssertShallowCopiedEntity(original, copy);
        }
Exemplo n.º 2
0
        public void ShallowCopyAttribute_CopiesAttribute_ResettingId()
        {
            // Arrange
            var attributeType = HiveModelCreationHelper.CreateAttributeType("test", "test-name", "test-description");

            attributeType.Id = new HiveId(Guid.NewGuid());
            var attributeGroup = HiveModelCreationHelper.CreateAttributeGroup("test", "name", 0);
            var attributeDef   = HiveModelCreationHelper.CreateAttributeDefinition("alias", "name", "desc", attributeType, attributeGroup);
            var original       = HiveModelCreationHelper.CreateAttribute(attributeDef, "my value");

            original.Id = new HiveId(Guid.NewGuid());

            // Act
            Thread.Sleep(250); // Ensure copy dates are newer
            var copy = EntityExtensions.CreateShallowCopy(original);

            // Assert
            Assert.AreNotEqual(copy.Id, original.Id);
            Assert.AreEqual(HiveId.Empty, copy.Id);
            Assert.That(copy.UtcCreated, Is.GreaterThan(original.UtcCreated));
            Assert.That(copy.UtcModified, Is.EqualTo(original.UtcModified));
            Assert.That(copy.UtcStatusChanged, Is.EqualTo(original.UtcStatusChanged));
        }