public void CheckPassedPublisher_WithoutPublisher_ValidCall() { var model = new AddEditPublisherViewModel(null, null); model.CheckPassedPublisherAsync(null); Assert.Null(model.Publisher); Assert.Null(model.InputModel.Name); Assert.Null(model.InputModel.Description); Assert.NotEqual(DateTime.MinValue, model.InputModel.CreationDateTime); }
public void CanExecuteChanged_CreationDateTimeIsMin_CanSaveIsFalse() { var model = new AddEditPublisherViewModel(null, null); var publisher = TestData.GetPublishersSample().First(); model.CheckPassedPublisherAsync(publisher); model.SetErrorsChangedEventAsync(); model.Publisher.CreationDateTime = DateTime.MinValue; Assert.False(model.CanSave); }
public void CanExecuteChanged_NameIsEmpty_CanSaveIsFalse() { var model = new AddEditPublisherViewModel(null, null); var publisher = TestData.GetPublishersSample().First(); model.CheckPassedPublisherAsync(publisher); model.SetErrorsChangedEventAsync(); model.InputModel.Name = ""; Assert.False(model.CanSave); }
public void CanExecuteChanged_WithoutErrors_CanSaveIsTrue() { var model = new AddEditPublisherViewModel(null, null); var publisher = TestData.GetPublishersSample().First(); model.CheckPassedPublisherAsync(publisher); model.SetErrorsChangedEventAsync(); model.InputModel.CreationDateTime = new DateTime(2010, 01, 01); Assert.True(model.CanSave); }
public void DateErrorMessage_DisplaysProperMessage() { var model = new AddEditPublisherViewModel(null, null); model.CheckPassedPublisherAsync(null); model.SetErrorsChangedEventAsync(); model.InputModel.CreationDateTime = DateTime.MaxValue; var expectedMessage = "You have to choose a date between 01.01.1900 and today"; var actualMessage = model.DateErrorMessage; Assert.True(model.InputModel.HasErrors); Assert.Equal(expectedMessage, actualMessage); }
public void NameErrorsMessage_DisplaysProperMessage() { var model = new AddEditPublisherViewModel(null, null); model.CheckPassedPublisherAsync(null); model.SetErrorsChangedEventAsync(); model.InputModel.Name = ""; var expectedMessage = "Publisher name cannot be empty."; var actualMessage = model.NameErrorMessage; Assert.True(model.InputModel.HasErrors); Assert.False(model.CanSave); Assert.Equal(expectedMessage, actualMessage); }