public void Get_CallsRepositoryPassesId() { var hero = new Hero {Name = "Captain",Id=1}; _repos.Stub(r => r.GetHero(Arg<int>.Is.Equal(1))).Return(hero); var actual = new PhoneBookController(_repos).Get(hero.Id); Assert.AreEqual(hero,actual); }
public void SaveHero(Hero hero) { _session.Contacts.Add(hero); }
public void Post_CallsRepositoryPassesHero() { var hero = new Hero {Name = "Captain"}; new PhoneBookController(_repos).Post(hero); _repos.AssertWasCalled(r=>r.SaveHero(Arg<Hero>.Matches(a=>a.Name.Equals("Captain")))); }
public void Delete_CallsRepositoryPassesHeroId() { var hero = new Hero {Name = "Captain", Id=1}; new PhoneBookController(_repos).Delete(hero.Id); _repos.AssertWasCalled(r=>r.DeleteHero(Arg<int>.Is.Equal(1))); }
// POST api/<controller> public void Post(Hero hero) { _repository.SaveHero(hero); }