public SomeModel() { Count = NotifyChange.Of(() => _count, x => _count = x); Message = NotifyChange.Of <string>(); DetailedMessage = NotifyChange.Select(() => Message + "-" + Count, Message, Count); }
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(); }
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); }
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); }
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"); }
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"); }
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(); }