public void TryGetValue_PropertyAliased_IfAnnotationSet() { // Arrange _model.Model.SetAnnotationValue(_model.Customer, new ClrTypeAnnotation(typeof(TestEntityWithAlias))); _model.Model.SetAnnotationValue( _model.CustomerName, new ClrPropertyInfoAnnotation(typeof(TestEntityWithAlias).GetProperty("SampleProperty"))); object expectedPropertyValue = new object(); SelectExpandWrapper <TestEntityWithAlias> wrapper = new SelectExpandWrapper <TestEntityWithAlias> { Model = _model.Model }; wrapper.Instance = new TestEntityWithAlias { SampleProperty = expectedPropertyValue }; wrapper.UseInstanceForProperties = true; // Act object value; bool result = wrapper.TryGetPropertyValue("Name", out value); // Assert Assert.True(result); Assert.Same(expectedPropertyValue, value); }
public void TryGetValue_ReturnsFalse_IfPropertyNotPresentInElement() { SelectExpandWrapper <TestEntity> wrapper = new SelectExpandWrapper <TestEntity> { Model = _model.Model }; object value; bool result = wrapper.TryGetPropertyValue("SampleNotPresentProperty", out value); Assert.False(result); }
public void TryGetValue_ReturnsFalse_IfContainerAndInstanceAreNull() { SelectExpandWrapper <TestEntity> wrapper = new SelectExpandWrapper <TestEntity> { Model = _model.Model }; object value; bool result = wrapper.TryGetPropertyValue("SampleProperty", out value); Assert.False(result); }
public void TryGetValue_ReturnsValueFromInstance_IfContainerIsNull() { object expectedPropertyValue = new object(); SelectExpandWrapper <TestEntity> wrapper = new SelectExpandWrapper <TestEntity> { Model = _model.Model }; 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 TryGetValue_ReturnsValueFromPropertyContainer_IfPresent() { object expectedPropertyValue = new object(); MockPropertyContainer container = new MockPropertyContainer(); container.Properties.Add("SampleProperty", expectedPropertyValue); SelectExpandWrapper <TestEntity> wrapper = new SelectExpandWrapper <TestEntity> { Model = _model.Model, Container = container }; wrapper.Instance = new TestEntity(); object value; bool result = wrapper.TryGetPropertyValue("SampleProperty", out value); Assert.True(result); Assert.Same(expectedPropertyValue, value); }
public void TryGetValue_ReturnsValueFromPropertyContainer_IfPresent() { object expectedPropertyValue = new object(); MockPropertyContainer container = new MockPropertyContainer(); container.Properties.Add("SampleProperty", expectedPropertyValue); SelectExpandWrapper<TestEntity> wrapper = new SelectExpandWrapper<TestEntity> { ModelID = _modelID, Container = container }; wrapper.Instance = new TestEntity(); object value; bool result = wrapper.TryGetPropertyValue("SampleProperty", out value); Assert.True(result); Assert.Same(expectedPropertyValue, value); }
public void TryGetValue_ReturnsFalse_IfPropertyNotPresentInElement() { SelectExpandWrapper<TestEntity> wrapper = new SelectExpandWrapper<TestEntity> { ModelID = _modelID }; object value; bool result = wrapper.TryGetPropertyValue("SampleNotPresentProperty", out value); Assert.False(result); }
public void TryGetValue_ReturnsFalse_IfContainerAndInstanceAreNull() { SelectExpandWrapper<TestEntity> wrapper = new SelectExpandWrapper<TestEntity> { ModelID = _modelID }; object value; bool result = wrapper.TryGetPropertyValue("SampleProperty", out value); Assert.False(result); }
public void TryGetValue_PropertyAliased_IfAnnotationSet() { // Arrange _model.Model.SetAnnotationValue(_model.Customer, new ClrTypeAnnotation(typeof(TestEntityWithAlias))); _model.Model.SetAnnotationValue( _model.CustomerName, new ClrPropertyInfoAnnotation(typeof(TestEntityWithAlias).GetProperty("SampleProperty"))); object expectedPropertyValue = new object(); SelectExpandWrapper<TestEntityWithAlias> wrapper = new SelectExpandWrapper<TestEntityWithAlias> { ModelID = _modelID }; wrapper.Instance = new TestEntityWithAlias { SampleProperty = expectedPropertyValue }; // Act object value; bool result = wrapper.TryGetPropertyValue("Name", out value); // Assert Assert.True(result); Assert.Same(expectedPropertyValue, value); }
public void TryGetValue_ReturnsValueFromInstance_IfContainerIsNull() { object expectedPropertyValue = new object(); SelectExpandWrapper<TestEntity> wrapper = new SelectExpandWrapper<TestEntity> { ModelID = _modelID }; wrapper.Instance = new TestEntity { SampleProperty = expectedPropertyValue }; object value; bool result = wrapper.TryGetPropertyValue("SampleProperty", out value); Assert.True(result); Assert.Same(expectedPropertyValue, value); }
public void TryGetValue_ReturnsValueFromInstance_IfNotPresentInContainer() { object expectedPropertyValue = new object(); MockPropertyContainer container = new MockPropertyContainer(); SelectExpandWrapper<TestEntity> wrapper = new SelectExpandWrapper<TestEntity> { Container = container }; wrapper.Instance = new TestEntity { SampleProperty = expectedPropertyValue }; object value; bool result = wrapper.TryGetPropertyValue("SampleProperty", out value); Assert.True(result); Assert.Same(expectedPropertyValue, value); }