public void Validate_Should_Throw_Exception_When_ReadRepository_Is_Null()
            {
                FeatureCommand command = FeatureCommandHandlerTestHelper.GetCommand();

                this.read = null;

                FeatureCommandHandlerHelper.Validate(command, this.write, this.read);
            }
            public void Validate_Should_Not_Add_Feature_With_Invalid_Name_Length()
            {
                FeatureCommand command = FeatureCommandHandlerTestHelper.GetCommand("a".PadLeft(101, 'a'), null, null);

                string expectedInvalid = string.Format(MessagesModel.MaxLength, "100");

                FeatureCommandResult result = FeatureCommandHandlerHelper.Validate(command, this.write, this.read);

                Assert.IsFalse(result.Valid);
                Assert.AreEqual(expectedInvalid, result.InvalidName);
            }
            public void Validate_Should_Not_Add_Feature_With_No_Name()
            {
                FeatureCommand command = FeatureCommandHandlerTestHelper.GetCommand("");

                string expectedInvalid = MessagesModel.Required;

                FeatureCommandResult result = FeatureCommandHandlerHelper.Validate(command, this.write, this.read);

                Assert.IsFalse(result.Valid);
                Assert.AreEqual(expectedInvalid, result.InvalidName);
            }
Пример #4
0
            public void Execute_Should_Not_Edit_Invalid_Feature()
            {
                EditFeatureCommandHandler sut = GetCommandHandler();

                EditFeatureCommand command = FeatureCommandHandlerTestHelper.GetEditCommand("Feature 1", "a".PadLeft(101, 'a'));

                string expectedInvalid = string.Format(MessagesModel.MaxLength, "100");

                FeatureCommandResult result = sut.Execute(command);

                var calls = sut.WriteRepository.ReceivedCalls().Count();

                Assert.AreEqual(0, calls);
            }
            public void Validate_Should_Not_Add_Feature_With_Duplicate_Name()
            {
                FeatureCommand command = FeatureCommandHandlerTestHelper.GetCommand();

                IList <Feature> features = Substitute.For <IList <Feature> >();

                features.Count.Returns(1);

                read.Where(x => x.Name == "Feature 1").ReturnsForAnyArgs(features);

                string expectedInvalid = string.Format("A feature already exists with the name {0}", command.Name);

                FeatureCommandResult result = FeatureCommandHandlerHelper.Validate(command, this.write, this.read);

                Assert.IsFalse(result.Valid);
                Assert.AreEqual(expectedInvalid, result.InvalidName);
            }