public void IsAdvertisementValid_WhenChangingFromFalseToTrue_CallsPropertyChangedEvent() { // Arrange var adModel = GetNewEmptyAdvertisement(); var adViewModel = GetAdvertisementViewModel(adModel); var eventAssert = new PropertyChangedEventAssert(adModel); adViewModel.HasErrors.Should().Be(false, "Populated Ad has invalid name"); adViewModel.HasErrors.Should().Be(false, "Populated Ad has invalid text"); // Act eventAssert.ExpectNothing(); adViewModel.Name = TEST_AD_NAME; adViewModel.HasErrors.Should().Be(true, "Name is now valid"); adViewModel.IsEntityValid.Should().Be(false, "Ad is still invalid."); adViewModel.Text = TEST_AD_TEXT; // Assert adViewModel.HasErrors.Should().Be(true, "Text should now be valid"); adViewModel.IsEntityValid.Should().Be(true, "If all fields are valid, the Ad is valid"); eventAssert.Expect("Name"); eventAssert.Expect("HasErrors"); eventAssert.Expect("Text"); eventAssert.Expect("HasErrors"); eventAssert.Expect("IsEntityValid"); }
public void HasErrors_WhenModified_PerformsPropertyChangedCallbackOnNameAndHasErrors() { // Arrange var adModel = GetNewPopulatedAdvertisement(); var adViewModel = GetAdvertisementViewModel(adModel); adModel.HasErrors.Should().Be(true, "Name should be valid"); var eventAssert = new PropertyChangedEventAssert(adModel); eventAssert.ExpectNothing(); // Act adViewModel.Name = null; // Assert eventAssert.Expect("Name"); eventAssert.Expect("HasErrors"); }
public void Name_WhenModified_PerformsPropertyChangedCallback() { // Arrange const string AD_NAME = "Test ad 1 name"; const string NEW_AD_NAME = "New ad name"; var testAd = new Advertisement { Name = AD_NAME }; var eventAssert = new PropertyChangedEventAssert(testAd); testAd.Name.Should().Be(AD_NAME, "Ad name set properly"); eventAssert.ExpectNothing(); testAd.Name = NEW_AD_NAME; eventAssert.Expect("Name"); }
public void Name_WhenModifiedFromValidToInvalidChangesHasErrors_PerformsPropertyChangedCallback() { // Arrange const string PAPER_NAME = "Paper 1 name"; const string NEW_PAPER_NAME = ""; var paper = new Newspaper() { Name = PAPER_NAME }; var eventAssert = new PropertyChangedEventAssert(paper); paper.Name.Should().Be(PAPER_NAME, "Ad name set properly"); eventAssert.ExpectNothing(); paper.Name = NEW_PAPER_NAME; eventAssert.Expect("Name"); }
public void Name_WhenModified_PerformsPropertyChangedCallback() { // Arrange var paper = GetPopulatedNewspaper(); var vm = GetNewspaperViewModel(paper); paper.Name.Should().Be(TEST_PAPER_NAME, "Name should be set."); // Act var eventAssert = new PropertyChangedEventAssert(paper); eventAssert.ExpectNothing(); vm.Name = NEW_PAPER_NAME; // Assert paper.Name.Should().Be(NEW_PAPER_NAME, "ViewModel should set new name in the model"); eventAssert.Expect("Name"); }
public void Name_WhenModified_PerformsPropertyChangedCallback() { // Arrange var paper = GetPopulatedNewspaper(); var vm = GetNewspaperViewModel(paper); paper.Name.Should().Be(TEST_PAPER_NAME, "Name should be set."); // Act var eventAssert = new PropertyChangedEventAssert(paper); eventAssert.ExpectNothing(); vm.Name = NEW_PAPER_NAME; // Assert paper.Name.Should().Be(NEW_PAPER_NAME, "ViewModel should set new name in the model"); eventAssert.Expect("Name"); }
public void Name_WhenModified_PerformsPropertyChangedCallback() { // Arrange const string PAPER_NAME = "Paper 1 name"; const string NEW_PAPER_NAME = "New paper 1 name"; var paper = new Newspaper() {Name = PAPER_NAME}; var eventAssert = new PropertyChangedEventAssert(paper); paper.Name.Should().Be(PAPER_NAME, "Ad name set properly"); eventAssert.ExpectNothing(); paper.Name = NEW_PAPER_NAME; eventAssert.Expect("Name"); }
public void Name_WhenModified_PerformsPropertyChangedCallback() { // Arrange const string AD_NAME = "Test ad 1 name"; const string NEW_AD_NAME = "New ad name"; var testAd = new Advertisement {Name = AD_NAME}; var eventAssert = new PropertyChangedEventAssert(testAd); testAd.Name.Should().Be(AD_NAME, "Ad name set properly"); eventAssert.ExpectNothing(); testAd.Name = NEW_AD_NAME; eventAssert.Expect("Name"); }
public void Name_WhenSettingNewValidValue_InvokesPropertyChangedOnNameProperty() { // Arrange var vm = GetValidNewspaperItemViewModel(); var newName = new String(vm.Name.ToCharArray()) + "_Changed"; var propertyChangedEvent = new PropertyChangedEventAssert(vm); propertyChangedEvent.ExpectNothing("No events should be pending."); // Act vm.Name = newName; // Assert propertyChangedEvent.Expect("Name"); }
public void Text_WhenSettingNewValidValue_InvokesPropertyChangedOnNameProperty() { // Arrange var vm = GetValidAdvertisementItemViewModel(); var newText = new String(vm.Text.ToCharArray()) + "_Changed"; var propertyChangedEvent = new PropertyChangedEventAssert(vm); propertyChangedEvent.ExpectNothing("No events should be pending."); // Act vm.Text = newText; // Assert propertyChangedEvent.Expect("Text"); }