public void Copy_ConstantExpression_ThrowsException() { //Arrange ComplexStruct complexStructStub = ComplexStructFactory(); //Act, Assert Exception ex = Assert.Catch(() => complexStructStub.Copy(cs => MAGIC_INT, 20)); }
public void Copy_NullExpression_Succeeds() { //Arrange ComplexStruct complexStructStub = ComplexStructFactory(); //Act ComplexStruct copy = complexStructStub.Copy(null); //Assert Assert.IsTrue(complexStructStub.DeepEquals(copy)); }
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 } })); }
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); }
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); }
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); }
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); }