public void TryGetValue_ReturnsValueFromInstance_IfNotPresentInContainer() { object expectedPropertyValue = new object(); MockPropertyContainer container = new MockPropertyContainer(); SelectExpandWrapper <TestEntity> wrapper = new SelectExpandWrapper <TestEntity> { ModelID = _modelID, Container = container }; wrapper.Instance = new TestEntity { SampleProperty = expectedPropertyValue }; wrapper.UseInstanceForProperties = true; object value; bool result = wrapper.TryGetPropertyValue("SampleProperty", out value); Assert.True(result); Assert.Same(expectedPropertyValue, value); }
public void ToDictionary_ContainsAllProperties_FromContainer() { // Arrange EdmModel model = new EdmModel(); EdmEntityType entityType = new EdmEntityType("NS", "Name"); model.AddElement(entityType); model.SetAnnotationValue(entityType, new ClrTypeAnnotation(typeof(TestEntity))); entityType.AddStructuralProperty("SampleProperty", EdmPrimitiveTypeKind.Int32); MockPropertyContainer container = new MockPropertyContainer(); container.Properties.Add("Property", 42); SelectExpandWrapper <TestEntity> wrapper = new SelectExpandWrapper <TestEntity> { Container = container, ModelID = ModelContainer.GetModelID(model) }; // Act var result = wrapper.ToDictionary(); // Assert Assert.Equal(42, result["Property"]); }
public void TryGetValue_ReturnsValueFromPropertyContainer_IfPresent() { object expectedPropertyValue = new object(); MockPropertyContainer container = new MockPropertyContainer(); container.Properties.Add("SampleProperty", expectedPropertyValue); SelectExpandWrapper<TestEntity> wrapper = new SelectExpandWrapper<TestEntity> { Container = container }; wrapper.Instance = new TestEntity(); object value; bool result = wrapper.TryGetValue("SampleProperty", out value); Assert.True(result); Assert.Same(expectedPropertyValue, value); }
public void ToDictionary_ContainsAllProperties_FromContainer() { // Arrange MockPropertyContainer container = new MockPropertyContainer(); container.Properties.Add("Property", 42); SelectExpandWrapper<TestEntity> wrapper = new SelectExpandWrapper<TestEntity> { Container = container }; // Act var result = wrapper.ToDictionary(); // Assert Assert.Equal(42, result["Property"]); }
public void TryGetValue_ReturnsValueFromInstance_IfNotPresentInContainer() { object expectedPropertyValue = new object(); MockPropertyContainer container = new MockPropertyContainer(); SelectExpandWrapper<TestEntity> wrapper = new SelectExpandWrapper<TestEntity> { ModelID = _modelID, Container = container }; wrapper.Instance = new TestEntity { SampleProperty = expectedPropertyValue }; object value; bool result = wrapper.TryGetPropertyValue("SampleProperty", out value); Assert.True(result); Assert.Same(expectedPropertyValue, value); }
public void ToDictionary_ContainsAllProperties_FromContainer() { // Arrange EdmEntityType entityType = new EdmEntityType("NS", "Name"); entityType.AddStructuralProperty("SampleProperty", EdmPrimitiveTypeKind.Int32); EdmModel model = new EdmModel(); model.AddElement(entityType); model.SetAnnotationValue(entityType, new ClrTypeAnnotation(typeof(TestEntity))); MockPropertyContainer container = new MockPropertyContainer(); container.Properties.Add("Property", 42); SelectExpandWrapper<TestEntity> wrapper = new SelectExpandWrapper<TestEntity> { Container = container, ModelID = ModelContainer.GetModelID(model) }; // Act var result = wrapper.ToDictionary(); // Assert Assert.Equal(42, result["Property"]); }