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_Removed_From_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(false); UserController controller = new UserController(userRepo, groupRepo); var result = controller.RemoveUserFromGroup("fred", "testgroup"); groupRepo.DidNotReceive().RemoveUserFromGroup("fred", "testgroup"); }