public void Existent_User_Can_Be_Added_To_Existent_Group() { IUserRepository userRepo = Substitute.For<IUserRepository>(); IGroupRepository groupRepo = Substitute.For<IGroupRepository>(); userRepo.UserExists("fred").Returns(true); groupRepo.GroupExists("testgroup").Returns(true); UserController controller = new UserController(userRepo, groupRepo); var result = controller.AddUserToGroup("fred", "testgroup"); groupRepo.Received().AddUserToGroup("fred", "testgroup"); }
public void User_Cannot_Be_Added_To_A_Group_Multiple_Times() { IUserRepository userRepo = Substitute.For<IUserRepository>(); IGroupRepository groupRepo = Substitute.For<IGroupRepository>(); userRepo.UserExists("fred").Returns(true); groupRepo.GroupExists("testgroup").Returns(true); groupRepo.UserIsAMember("fred", "testgroup").Returns(true); UserController controller = new UserController(userRepo, groupRepo); var result = controller.AddUserToGroup("fred", "testgroup"); groupRepo.DidNotReceive().AddUserToGroup("fred", "testgroup"); }