Beispiel #1
0
        public void SetValue_IfPrivateProperty_UpdatesValue()
        {
            // Arrange
            IPropertySetter <PocoStruct, PocoProperty> product = CreateProductUnderTest <PocoStruct, PocoProperty>(
                typeof(PocoStruct).GetProperty("PrivateValue", BindingFlags.NonPublic | BindingFlags.Instance));
            PocoStruct   instance = new PocoStruct();
            PocoProperty expected = new PocoProperty();

            // Act
            product.SetValue(ref instance, expected);

            // Assert
            PocoProperty actual = instance.PrivateValueAsPublic;

            Assert.Same(expected, actual);
        }
Beispiel #2
0
        public void SetValue_UpdatesValue()
        {
            // Arrange
            IPropertySetter <PocoStruct, PocoProperty> product = CreateProductUnderTest <PocoStruct, PocoProperty>(
                typeof(PocoStruct).GetProperty("Value"));
            PocoStruct   instance = new PocoStruct();
            PocoProperty expected = new PocoProperty();

            // Act
            product.SetValue(ref instance, expected);

            // Assert
            PocoProperty actual = instance.Value;

            Assert.Same(expected, actual);
        }
Beispiel #3
0
        public void GetValue_IfPrivateProperty_ReturnsValue()
        {
            // Arrange
            IPropertyGetter <PocoStruct, PocoProperty> product = CreateProductUnderTest <PocoStruct, PocoProperty>(
                typeof(PocoStruct).GetProperty("PrivateValue", BindingFlags.NonPublic | BindingFlags.Instance));
            PocoProperty expected = new PocoProperty();
            PocoStruct   instance = new PocoStruct
            {
                PrivateValueAsPublic = expected
            };

            // Act
            PocoProperty actual = product.GetValue(instance);

            // Assert
            Assert.Same(expected, actual);
        }
Beispiel #4
0
        public void GetValue_ReturnsValue()
        {
            // Arrange
            IPropertyGetter <PocoStruct, PocoProperty> product = CreateProductUnderTest <PocoStruct, PocoProperty>(
                typeof(PocoStruct).GetProperty("Value"));
            PocoProperty expected = new PocoProperty();
            PocoStruct   instance = new PocoStruct
            {
                Value = expected
            };

            // Act
            PocoProperty actual = product.GetValue(instance);

            // Assert
            Assert.Same(expected, actual);
        }