public void JoinRoom_NonExistingRoom_Ignore_ReturnToIndexAction() { var mockDal = new Mock <IRoomDAL>(); var controller = new RoomsController(mockDal.Object, null); var result = controller.Join("test-room", "test-user") as RedirectToRouteResult; Assert.IsNotNull(result); Assert.AreEqual("Index", result.RouteValues["action"]); Assert.AreEqual("Rooms", result.RouteValues["controller"]); }
public void JoinRoom_ExistingRoom_LeavesRooms_AddsUsernameToRoom_ReturnToViewAction() { var mockDal = new Mock <IRoomDAL>(); mockDal.Setup(m => m.GetChatRoom("test-room")).Returns(new RoomModel() { Id = 1 }); var controller = new RoomsController(mockDal.Object, null); var result = controller.Join("test-room", "test-user") as RedirectToRouteResult; Assert.IsNotNull(result); Assert.AreEqual("View", result.RouteValues["action"]); Assert.AreEqual("Rooms", result.RouteValues["controller"]); Assert.AreEqual(1, result.RouteValues["id"]); mockDal.Verify(m => m.LeaveChatRooms("test-user")); mockDal.Verify(m => m.JoinChatRoom(1, "test-user")); }