示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
        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);
        }