Beispiel #1
0
            public SomeModel()
            {
                Count = NotifyChange.Of(() => _count, x => _count = x);

                Message = NotifyChange.Of <string>();

                DetailedMessage = NotifyChange.Select(() => Message + "-" + Count, Message, Count);
            }
Beispiel #2
0
        public void Given_that_no_validation_condition_was_specified_Then_Error_propetry_should_return_null()
        {
            // Arrange
            var count = NotifyChange.Of(0);

            // Act
            // Assert
            count.Error.Should().BeNull();
        }
Beispiel #3
0
        public void Given_some_invalid_NC_When_I_validate_it_without_error_message_Then_it_should_set_NC_Error_property_to_default_error_message()
        {
            // Arrange
            var counter = NotifyChange.Of(-1);

            // Act
            counter = counter.ValidIf(i => i > 0);

            // Assert
            counter.Error.Should().Be(NotifyChange.Defaults.InvalidError);
        }
Beispiel #4
0
        public void Given_some_invalid_NC_When_I_validate_it_with_error_message_Then_it_should_set_NC_indexer_should_return_the_same_message_as_Error()
        {
            // Arrange
            var counter = NotifyChange.Of(-1);

            // Act
            counter = counter.ValidIf(i => i > 0, "Should be positive");

            // Assert
            counter["hey"].Should().Be(counter.Error);
        }
Beispiel #5
0
        public void Given_some_invalid_NC_When_I_validate_it_with_error_message_Then_it_should_set_NC_Error_property_to_specified_message()
        {
            // Arrange
            var counter = NotifyChange.Of(-1);

            // Act
            counter = counter.ValidIf(i => i > 0, "Should be positive");

            // Assert
            counter.Error.Should().Be("Should be positive");
        }
Beispiel #6
0
        public void Given_null_value_When_I_convert_wrapper_to_string_Then_it_should_not_raise_exception()
        {
            // Arrange
            var obj = NotifyChange.Of <object>(null);

            // Act
            // Assert
            var x = string.Empty;

            Assert.DoesNotThrow(() => x = obj.ToString());
            x.Should().Be("Value: Null");
        }
Beispiel #7
0
        public void Given_valid_source_NC_and_another_NC_with_source_Error_property_When_I_assign_invalid_value_to_source_Then_Error_PC_should_be_raised()
        {
            // Arrange
            var counter         = NotifyChange.Of(1).ValidIf(x => x > 0);
            var validationError = counter.GetNotifyChangeOfProperty(x => x.Error);
            var raised          = false;

            validationError.PropertyChanged += (sender, args) => raised = true;

            // Act
            counter.Value = -1;

            // Assert
            raised.Should().BeTrue();
        }