Ejemplo n.º 1
0
        public void PassValidObject()
        {
            AddToCartCommand command = new AddToCartCommand
            {
                AuthenticatedUserId = Guid.NewGuid(),
                ProductId           = Guid.NewGuid(),
                Quantity            = 1
            };
            AddToCartCommandValidator testSubject = new AddToCartCommandValidator();

            ValidationResult result = testSubject.Validate(command);

            Assert.True(result.IsValid);
        }
Ejemplo n.º 2
0
        public void FailOnMissingProductId()
        {
            AddToCartCommand command = new AddToCartCommand
            {
                AuthenticatedUserId = Guid.NewGuid(),
                ProductId           = Guid.Empty,
                Quantity            = 1
            };
            AddToCartCommandValidator testSubject = new AddToCartCommandValidator();

            ValidationResult result = testSubject.Validate(command);

            Assert.False(result.IsValid);
            Assert.Equal("ProductId", result.Errors.Single().PropertyName);
        }