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); }
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); }
public void Validate_Should_Throw_Exception_When_Command_Is_Null() { FeatureCommand command = null; FeatureCommandHandlerHelper.Validate(command, this.write, this.read); }