Пример #1
0
        public void Snack_Service_Should_Verify_Snack_Name_Sucessfully()
        {
            //Arrange
            var snack = ObjectMother.GetDefaultSnack();

            _mockSnackRepository.Setup(r => r.IsNameAlreadyInUse(It.IsAny <string>(), It.IsAny <long>())).Returns(false);

            //Action
            var result = _snackService.IsNameAlreadyInUse(snack.Name, snack.Id);

            //Assert
            _mockSnackRepository.Verify(r => r.IsNameAlreadyInUse(snack.Name, snack.Id), Times.Once);
            result.Should().BeFalse();
        }
Пример #2
0
 public Validator(ISnackService service)
 {
     RuleFor(c => c.Name).NotNull().NotEmpty().Must((c, name) => !service.IsNameAlreadyInUse(name, c.Id)).WithMessage("O nome já está em uso");
     RuleFor(c => c.Image).NotNull().NotEmpty().WithMessage("É necessário inserir uma imagem.");
     RuleFor(c => c.Id).GreaterThan(0);
 }
Пример #3
0
 public IHttpActionResult CheckName(SnackCheckNameQuery query)
 {
     return(HandleCallback(_service.IsNameAlreadyInUse(query.Name, query.Id)));
 }