Beispiel #1
0
        public void CreateDrinkRequest_NullRequest_ShouldThrowException()
        {
            // Arrange
            CreateDrink request = null;

            var validator = new CreateDrinkValidator();

            // Act
            var exception = Should.Throw <ValidationException>(() => validator.Validate(request));

            // Arrange
            exception.Message.ShouldNotBeNullOrWhiteSpace();
            exception.ValidationResult.HasFailures.ShouldBeTrue();
        }
Beispiel #2
0
        public void CreateDrinkRequest_LongName_ShouldFail()
        {
            // Arrange
            var request = new CreateDrink()
            {
                Name = RandomHelper.StringOfLength(101)
            };

            var validator = new CreateDrinkValidator();

            // Act
            var result = validator.Validate(request);

            // Arrange
            result.HasFailures.ShouldBeTrue();
        }
Beispiel #3
0
        public void CreateDrinkRequest_ShortName_ShouldFail()
        {
            // Arrange
            var request = new CreateDrink()
            {
                Name = "A"
            };

            var validator = new CreateDrinkValidator();

            // Act
            var result = validator.Validate(request);

            // Arrange
            result.HasFailures.ShouldBeTrue();
        }
Beispiel #4
0
        public void CreateDrinkRequest_NameFilled_ShouldPass()
        {
            // Arrange
            var request = new CreateDrink()
            {
                Name = "Wisky"
            };

            var validator = new CreateDrinkValidator();

            // Act
            var result = validator.Validate(request);

            // Assert
            result.HasFailures.ShouldBeFalse();
        }