public void Subclassed_entities_should_not_equal_entities_of_a_different_type_even_if_the_Id_is_the_same() { var first = new TestSubEntity { Id = 99 }; var second = new AnotherSubEntity { Id = 99 }; first.Equals(second).ShouldBeFalse(); }
public void Subclassed_entities_should_equal_each_other_with_same_Id() { var first = new TestSubEntity {Id = 99}; var second = new TestSubEntity { Id = 99 }; first.Equals(second).ShouldBeTrue(); }
public void Deep_subclassed_entities_should_not_equal_their_parent_classed_entities_even_if_the_Id_is_the_same() { var first = new TestSubEntity { Id = 99 }; var second = new DeepSubEntity { Id = 99 }; first.Equals(second).ShouldBeFalse(); }
public void Subclassed_entities_should_equal_each_other_with_same_Id() { var first = new TestSubEntity { Id = 99 }; var second = new TestSubEntity { Id = 99 }; first.Equals(second).ShouldBeTrue(); }
public void Property_ResourceInstance_CanBeBuiltWithSelectExpandWrapperProperties() { // Arrange EdmComplexType edmType = new EdmComplexType("NS", "Name"); var edmTypeRef = new EdmComplexTypeReference(edmType, isNullable: false); edmType.AddStructuralProperty("Property", EdmPrimitiveTypeKind.Int32); edmType.AddStructuralProperty("SubEntity1", edmTypeRef); edmType.AddStructuralProperty("SubEntity2", edmTypeRef); EdmModel model = new EdmModel(); model.AddElement(edmType); model.SetAnnotationValue <ClrTypeAnnotation>(edmType, new ClrTypeAnnotation(typeof(TestSubEntity))); Mock <IEdmComplexObject> edmObject = new Mock <IEdmComplexObject>(); object propertyValue = 42; object selectExpandWrapper = new SelectExpandWrapper <TestEntity>(); object subEntity2 = new TestSubEntity { Property = 33 }; edmObject.Setup(e => e.TryGetPropertyValue("Property", out propertyValue)).Returns(true); edmObject.Setup(e => e.TryGetPropertyValue("SubEntity1", out selectExpandWrapper)).Returns(true); edmObject.Setup(e => e.TryGetPropertyValue("SubEntity2", out subEntity2)).Returns(true); edmObject.Setup(e => e.GetEdmType()).Returns(edmTypeRef); ResourceContext entityContext = new ResourceContext { EdmModel = model, EdmObject = edmObject.Object, StructuredType = edmType }; // Act object resource = entityContext.ResourceInstance; // Assert TestSubEntity testEntity = Assert.IsType <TestSubEntity>(resource); Assert.Equal(42, testEntity.Property); Assert.Null(testEntity.SubEntity1); Assert.NotNull(testEntity.SubEntity2); Assert.Equal(33, testEntity.SubEntity2.Property); }