Ejemplo n.º 1
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();
            }
Ejemplo n.º 2
0
            public void ShouldThrowException_WhenPropertyIsNotAValueType()
            {
                // Arrange
                var value     = new ComplexTestClass();
                var immutable = new Immutable <ComplexTestClass>(value);

                // Act
                Action result = () => immutable.Value("Things");

                // Assert
                result.Should().Throw <ArgumentException>().WithMessage("Property 'Things' is not a immutable value type.");
            }
Ejemplo n.º 3
0
            public void ShouldReturnValue_WhenPropertyExistsAndIsAValueType()
            {
                // Arrange
                var value     = new ComplexTestClass();
                var immutable = new Immutable <ComplexTestClass>(value);

                // Act
                var result = immutable.Value("Id");

                // Assert
                result.Should().Be(value.Id);
            }
Ejemplo n.º 4
0
            public void ShouldThrowException_WhenPropertyDoesNotExist()
            {
                // Arrange
                var value     = new ComplexTestClass();
                var immutable = new Immutable <ComplexTestClass>(value);

                // Act
                Action result = () => immutable.Value("Thing");

                // Assert
                result.Should().Throw <ArgumentException>().WithMessage("Property 'Thing' does not exist on this object.");
            }
 public async Task Do(Immutable <RequestProcessingAction> action)
 {
     await action.Value();
 }