public void TestJoinChatroom() { //Necessary to create the child chatroom before requesting its information var USER = _helper.testUsers[1]; var JOINING_USER = _helper.testUsers[0]; ChatroomController chatControllerTest = new ChatroomController(); ChatRequestModel model = new ChatRequestModel() { RawChatroomIdValue = "123402", UserHandle = USER.DefaultHandle, ChatroomName = "TestJoinChatroom", User = new UserModel() { Id = USER.Id, Username = USER.Username } }; ChatResponseTestModel chatRoom = _helper.createChatroomAndAddUser(model);//for now don't do anything with the result //Pre-sanity check amke sure only 1 user in the room before we try ad join //Create test data model GetChatroomInformationRequestModel modelInfo = new GetChatroomInformationRequestModel() { UserId = chatRoom.ChatroomModel.UserId, ChatroomId = chatRoom.ChatroomModel.ChatroomId, ParentChatroomId = chatRoom.ChatroomModel.ParentChatroomId }; //Test getting the information from the chatroom success var result = chatControllerTest.GetChatroomInformation(modelInfo) as JsonResult; Assert.AreEqual(1, ((GetChatroomInformationResponseModel)result.Data).UsersInformation.Count); Assert.AreEqual(USER.Id, ((GetChatroomInformationResponseModel)result.Data).UsersInformation[0].Id); Assert.AreEqual(USER.Username, ((GetChatroomInformationResponseModel)result.Data).UsersInformation[0].Username); //Create test data model - with all options possible since without them is easier. Do hard mode xD JoinChatroomRequestModel model2 = new JoinChatroomRequestModel() { UserId = JOINING_USER.Id, ChatroomId = chatRoom.ChatroomModel.ChatroomId, ParentChatroomId = chatRoom.ChatroomModel.ParentChatroomId, CurrentChatroomId = -1, UserHandle = JOINING_USER.DefaultHandle, Password = "", User = new UserModel() { Id = JOINING_USER.Id } }; //Test joining a chatroom success result = chatControllerTest.JoinChatroom(model2) as JsonResult; //Post-sanity check NOW there will be two users in the chatroom xD result = chatControllerTest.GetChatroomInformation(modelInfo) as JsonResult; Assert.AreEqual(2, ((GetChatroomInformationResponseModel)result.Data).UsersInformation.Count); Assert.AreEqual(USER.Id, ((GetChatroomInformationResponseModel)result.Data).UsersInformation[0].Id); Assert.AreEqual(USER.Username, ((GetChatroomInformationResponseModel)result.Data).UsersInformation[0].Username); Assert.AreEqual(JOINING_USER.Id, ((GetChatroomInformationResponseModel)result.Data).UsersInformation[1].Id); Assert.AreEqual(JOINING_USER.Username, ((GetChatroomInformationResponseModel)result.Data).UsersInformation[1].Username); }
public void TestLeaveChatroom() { //Necessary to create the child chatroom before requesting its information var USER = _helper.testUsers[1]; ChatroomController chatControllerTest = new ChatroomController(); ChatRequestModel model = new ChatRequestModel() { RawChatroomIdValue = "123403", UserHandle = USER.DefaultHandle, ChatroomName = "TestLeaveChatroom", User = new UserModel() { Id = USER.Id, Username = USER.Username } }; ChatResponseTestModel chatRoom = _helper.createChatroomAndAddUser(model);//for now don't do anything with the result //Pre-sanity check amke sure only 1 user in the room before we try ad join //Create test data model GetChatroomInformationRequestModel modelInfo = new GetChatroomInformationRequestModel() { UserId = chatRoom.ChatroomModel.UserId, ChatroomId = chatRoom.ChatroomModel.ChatroomId, ParentChatroomId = chatRoom.ChatroomModel.ParentChatroomId }; //Test getting the information from the chatroom success var result = chatControllerTest.GetChatroomInformation(modelInfo) as JsonResult; Assert.AreEqual(1, ((GetChatroomInformationResponseModel)result.Data).UsersInformation.Count); Assert.AreEqual(USER.Id, ((GetChatroomInformationResponseModel)result.Data).UsersInformation[0].Id); Assert.AreEqual(USER.Username, ((GetChatroomInformationResponseModel)result.Data).UsersInformation[0].Username); //Create test data model LeaveChatroomRequestModel model2 = new LeaveChatroomRequestModel() { ChatroomId = chatRoom.ChatroomModel.ChatroomId, ParentId = chatRoom.ChatroomModel.ParentChatroomId, UserId = USER.Id, User = new UserModel() { Id = USER.Id } }; var result2 = chatControllerTest.LeaveChatroom(model2) as EmptyResult; //nothing to assert since an empty object is returned but check below that there are no users in the room //Post-sanity check NOW there will be two users in the chatroom xD result = chatControllerTest.GetChatroomInformation(modelInfo) as JsonResult; Assert.AreEqual(0, ((GetChatroomInformationResponseModel)result.Data).UsersInformation.Count); }
public void TestGetChatroomInformation() { //Necessary to create the chatroom before requesting its information var USER = _helper.testUsers[1]; ChatroomController chatControllerTest = new ChatroomController(); ChatRequestModel model = new ChatRequestModel() { RawChatroomIdValue = "123400", UserHandle = USER.DefaultHandle, ChatroomName = "TestGetChatroomInformation", User = new UserModel() { Id = USER.Id, Username = USER.Username } }; ChatResponseTestModel chatRoom = _helper.createChatroomAndAddUser(model);//for now don't do anything with the result //Create test data model GetChatroomInformationRequestModel model2 = new GetChatroomInformationRequestModel() { UserId = chatRoom.ChatroomModel.UserId, ChatroomId = chatRoom.ChatroomModel.ChatroomId, ParentChatroomId = chatRoom.ChatroomModel.ParentChatroomId }; //Test getting the information from the chatroom success var result = chatControllerTest.GetChatroomInformation(model2) as JsonResult; Assert.AreEqual(1, ((GetChatroomInformationResponseModel)result.Data).UsersInformation.Count); Assert.AreEqual(USER.Id, ((GetChatroomInformationResponseModel)result.Data).UsersInformation[0].Id); Assert.AreEqual(USER.Username, ((GetChatroomInformationResponseModel)result.Data).UsersInformation[0].Username); }