示例#1
0
            public void ShouldThrowException_WhenExtractFunctionReturnsUnsupportedType()
            {
                // Arrange
                var value     = new ComplexTestClass();
                var immutable = new Immutable <ComplexTestClass>(value);

                // Act
                Action result = () => immutable.Extract(i => i.LotsOfInts.Where(l => l > 100));

                // Assert
                result.Should().Throw <InvalidOperationException>().WithMessage("*- Unable to clone interfaces. Use concrete types and implementations instead.");
            }
示例#2
0
            public void ShouldNotAffectTheImmutable_WhenExtractFunctionTriesToAssign()
            {
                // Arrange
                var value     = new ComplexTestClass();
                var immutable = new Immutable <ComplexTestClass>(value);

                // Act
                var result = immutable.Extract(i => { i.Name = "My Name"; return(i.Things); });

                // Assert
                immutable.Value("Name").As <string>().Should().BeNull();
            }
示例#3
0
            public void ShouldReturnValueOfPropertySelectByFunction_WhenCalled()
            {
                // Arrange
                var value     = new ComplexTestClass();
                var immutable = new Immutable <ComplexTestClass>(value);

                // Act
                var result = immutable.Extract(i => i.Things);

                // Assert
                result.Should().BeEquivalentTo(value.Things);
            }
示例#4
0
            public void ShouldReturnClonedValue_WhenCalled()
            {
                // Arrange
                var value     = new ComplexTestClass();
                var immutable = new Immutable <ComplexTestClass>(value);

                // Act
                var result = immutable.Extract(i => i.Things);

                result.Prop1 = 75;

                // Assert
                value.Things.Prop1.Should().NotBe(75);
            }