public void StructWithOperatorsRecyclesObjectWithSameValue()
 {
     var s12 = new SomeStructWithMultipleFieldsAndOperator(1, 2);
     var v1 = ImmutableWithComplexStructField.Create(someStructFieldWithOperator: s12);
     var v2 = v1.With(someStructFieldWithOperator: s12);
     Assert.Same(v1, v2);
 }
Пример #2
0
        public void StructWithOperatorsRecyclesObjectWithSameValue()
        {
            var s12 = new SomeStructWithMultipleFieldsAndOperator(1, 2);
            var v1  = ImmutableWithComplexStructField.Create(someStructFieldWithOperator: s12);
            var v2  = v1.With(someStructFieldWithOperator: s12);

            Assert.Same(v1, v2);
        }
 public void StructWithOperatorsRecreatesObjectWithChangedValue()
 {
     var s12 = new SomeStructWithMultipleFieldsAndOperator(1, 2);
     var s13 = new SomeStructWithMultipleFieldsAndOperator(1, 3);
     var v1 = ImmutableWithComplexStructField.Create(someStructFieldWithOperator: s12);
     var v2 = v1.With(someStructFieldWithOperator: s13);
     Assert.NotSame(v1, v2);
     Assert.Equal(s13.Field2, v2.SomeStructFieldWithOperator.Field2);
 }
Пример #4
0
        public void StructWithOperatorsRecreatesObjectWithChangedValue()
        {
            var s12 = new SomeStructWithMultipleFieldsAndOperator(1, 2);
            var s13 = new SomeStructWithMultipleFieldsAndOperator(1, 3);
            var v1  = ImmutableWithComplexStructField.Create(someStructFieldWithOperator: s12);
            var v2  = v1.With(someStructFieldWithOperator: s13);

            Assert.NotSame(v1, v2);
            Assert.Equal(s13.Field2, v2.SomeStructFieldWithOperator.Field2);
        }