Example #1
0
        public void Copy_ConstantExpression_ThrowsException()
        {
            //Arrange
            ComplexStruct complexStructStub = ComplexStructFactory();

            //Act, Assert
            Exception ex = Assert.Catch(() => complexStructStub.Copy(cs => MAGIC_INT, 20));
        }
Example #2
0
        public void Copy_NullExpression_Succeeds()
        {
            //Arrange
            ComplexStruct complexStructStub = ComplexStructFactory();

            //Act
            ComplexStruct copy = complexStructStub.Copy(null);

            //Assert
            Assert.IsTrue(complexStructStub.DeepEquals(copy));
        }
Example #3
0
        public void Copy_IdenticalMultipleExpressions_Fails()
        {
            //Arrange
            ComplexStruct complexStructStub = ComplexStructFactory();

            //Act, Assert
            Assert.Catch(() => complexStructStub.Copy(new Dictionary <Expression <Func <ComplexStruct, object> >, object>()
            {
                { cs => cs.Str, MAGIC_STRING },
                { cs => cs.Str, MAGIC_STRING }
            }));
        }
Example #4
0
        public void Copy_UnaryExpressions_AreIgnoredAndValueIsSet()
        {
            //Arrange
            ComplexStruct complexStructStub = ComplexStructFactory();

            //Act
            ComplexStruct copy = complexStructStub.Copy(cs => (short)(((ComplexStruct)(object)cs).SimpleStruct.Int), MAGIC_INT);

            //Assert
            Assert.IsFalse(complexStructStub.DeepEquals(copy));
            Assert.AreNotEqual(complexStructStub.SimpleStruct.Int, copy.SimpleStruct.Int);
            Assert.AreEqual(MAGIC_INT, copy.SimpleStruct.Int);
        }
Example #5
0
        public void Copy_DeepExpression_SetsValue()
        {
            //Arrange
            ComplexStruct complexStructStub = ComplexStructFactory();

            //Act
            ComplexStruct copy = complexStructStub.Copy(cs => cs.SimpleStruct.Int, MAGIC_INT);

            //Assert
            Assert.IsFalse(complexStructStub.DeepEquals(copy));
            Assert.AreNotEqual(complexStructStub.SimpleStruct.Int, copy.SimpleStruct.Int);
            Assert.AreEqual(MAGIC_INT, copy.SimpleStruct.Int);
        }
Example #6
0
        public void Copy_ShallowExpression_SetsValue()
        {
            //Arrange
            ComplexStruct complexStructStub = ComplexStructFactory();

            //Act
            ComplexStruct copy = complexStructStub.Copy(cs => cs.Str, MAGIC_STRING);

            //Assert
            Assert.IsFalse(complexStructStub.DeepEquals(copy));
            Assert.AreNotEqual(complexStructStub.Str, copy.Str);
            Assert.AreEqual(MAGIC_STRING, copy.Str);
        }
Example #7
0
        public void Copy_MultipleExpressions_SetValues()
        {
            //Arrange
            ComplexStruct complexStructStub = ComplexStructFactory();

            //Act
            ComplexStruct copy = complexStructStub.Copy(new Dictionary <Expression <Func <ComplexStruct, object> >, object>()
            {
                { cs => cs.Str, MAGIC_STRING },
                { cs => cs.SimpleStruct.Int, MAGIC_INT }
            });

            //Assert
            Assert.AreEqual(MAGIC_STRING, copy.Str);
            Assert.AreNotEqual(MAGIC_STRING, complexStructStub.Str);
            Assert.AreEqual(MAGIC_INT, copy.SimpleStruct.Int);
            Assert.AreNotEqual(MAGIC_INT, complexStructStub.SimpleStruct.Int);
        }