public void HeroRepository_Add_True() { //Arrange var hero = new Hero() { HeroName = "test", HeroPrice = 15, HeroType = new HeroType() { HeroTypeName = "test" } }; //Act var repo = MockRepository.GenerateStub <IHeroRepository>(); repo.Stub(s => s.GetByName(hero.HeroName)).Return(null); var repoType = MockRepository.GenerateStub <IHeroTypeRepository>(); repoType.Stub(s => s.GetByName("test")).Return(new HeroType()); var validationResult = new CreateAndUpdateHeroValidation(repo, repoType).Validate(hero); //Assert Assert.IsTrue(validationResult.IsValid); }
public void HeroRepository_AddAndUpdate_False() { //Arrange var hero = new Hero() { HeroName = "test", HeroPrice = 15 }; //Act var repo = MockRepository.GenerateStub <IHeroRepository>(); repo.Stub(s => s.GetByName(hero.HeroName)).Return(new Hero()); var validationResult = new CreateAndUpdateHeroValidation(repo).Validate(hero); //Assert Assert.IsFalse(validationResult.IsValid); Assert.IsTrue(validationResult.Erros.Any(a => a.Message == "This name was already chosen. Please chose another.")); }