Exemplo n.º 1
0
        public void SaveServant_ShouldReturnOkResult_WhenTheServantIsValid()
        {
            var servant = new Servant();

            MockRepo.Setup(repo => repo.SaveServant(servant)).Verifiable();
            MockServantCreationValidator.Setup(mscv => mscv.Validate(It.IsAny <CreationCandidate <Servant> >())).Returns(new ValidationResult());

            var controller = new ServantController(MockRepo.Object, MockServantCreationValidator.Object);

            Assert.IsInstanceOf <OkObjectResult>(controller.SaveServant(servant));
        }
Exemplo n.º 2
0
        public void SaveServant_ShouldReturnErrors_WhenTheServantIsInvalid()
        {
            var servant = new Servant();

            servant.Strength = 1000;

            MockRepo.Setup(repo => repo.SaveServant(servant)).Verifiable();
            var realServantCreationValidator = new ServantCreationValidator();

            var controller = new ServantController(MockRepo.Object, realServantCreationValidator);

            Assert.IsInstanceOf <IList <ValidationFailure> >(controller.SaveServant(servant));
        }