public void Input_CannotBe_ShorterThan_Minima() { const int minima = 12; var tooShortContent = StringGenerator.GenerateDesiredLengthString(minima - 1); var encapsulatedStringMock = Mock.Of <IEncapsulatedValue <string> >(m => m.Value == tooShortContent); Check.ThatCode(() => new MinimalLengthStringDecorator(minima, tooShortContent)) .Throws <FormatException>() .WithMessage(MinimalLengthStringDecorator.TooShortMessage(minima)); Check.ThatCode(() => new MinimalLengthStringDecorator(minima, encapsulatedStringMock)) .Throws <FormatException>() .WithMessage(MinimalLengthStringDecorator.TooShortMessage(minima)); }
public void StringInput_CannotExceed_LengthLimit() { const int limit = 12; var tooLongContent = StringGenerator.GenerateDesiredLengthString(limit + 1); var encapsulatedStringMock = Mock.Of <IEncapsulatedValue <string> >(m => m.Value == tooLongContent); Check.ThatCode(() => new MaximalLengthStringDecorator(limit, encapsulatedStringMock)) .Throws <FormatException>() .WithMessage(MaximalLengthStringDecorator.LengthExceededMessage(limit)); Check.ThatCode(() => new MaximalLengthStringDecorator(limit, tooLongContent)) .Throws <FormatException>() .WithMessage(MaximalLengthStringDecorator.LengthExceededMessage(limit)); }