Ejemplo n.º 1
0
 public Validator(ILoungeService service)
 {
     RuleFor(c => c.Id).GreaterThan(0);
     RuleFor(c => c.Name).NotNull().NotEmpty().Must((c, name) => !service.IsNameAlreadyInUse(name, c.Id)).WithMessage("O nome já está em uso");
     RuleFor(c => c.Rows).GreaterThanOrEqualTo(5).LessThanOrEqualTo(10);
     RuleFor(c => c.Columns).GreaterThanOrEqualTo(4).LessThanOrEqualTo(10);
 }
Ejemplo n.º 2
0
        public void Lounge_Service_Should_Verify_Lounge_Name_Sucessfully()
        {
            //Arrange
            var lounge = ObjectMother.GetDefaultLounge();

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

            //Action
            var result = _loungeService.IsNameAlreadyInUse(lounge.Name, lounge.Id);

            //Assert
            _mockLoungeRepository.Verify(r => r.IsNameAlreadyInUse(lounge.Name, lounge.Id), Times.Once);
            result.Should().BeFalse();
        }
Ejemplo n.º 3
0
 public IHttpActionResult CheckName(LoungeCheckNameQuery query)
 {
     return(HandleCallback(_service.IsNameAlreadyInUse(query.Name, query.Id)));
 }