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); }
public void TestChatView() { ChatroomController chatControllerTest = new ChatroomController(); var result = chatControllerTest.Chat() as ViewResult; Assert.AreEqual("Index", result.ViewName); }
public void TestGetFindChatroom() { ChatroomController chatControllerTest = new ChatroomController(); var result = chatControllerTest.GetFindChatroom() as PartialViewResult; Assert.AreEqual("_FindChatroom", result.ViewName); }
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 TestIndexView() { ChatroomController chatControllerTest = new ChatroomController(); var result = chatControllerTest.Index() as ViewResult; Assert.IsInstanceOfType(result.ViewData.Model, typeof(ChatRequestModel)); }
public void SetUp() { userBusinessMock = new Mock <IUserBusiness>(); chatroomBusiness = new Mock <IChatroomBusiness>(); mapperMock = new Mock <IMapper>(); chatroomController = new ChatroomController(userBusinessMock.Object, chatroomBusiness.Object, mapperMock.Object); }
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 TestComposeAndGetNewMessages() { //Necessary to create the child chatroom before requesting its information var USER = _helper.testUsers[1]; ChatroomController chatControllerTest = new ChatroomController(); ChatRequestModel model = new ChatRequestModel() { RawChatroomIdValue = "123404", UserHandle = USER.DefaultHandle, ChatroomName = "TestComposeAndGetNewMessages", User = new UserModel() { Id = USER.Id, Username = USER.Username } }; ChatResponseTestModel chatRoom = _helper.createChatroomAndAddUser(model);//for now don't do anything with the result //Right now every time we run the test another message gets added. ComposeMessageRequestModel messageModel = new ComposeMessageRequestModel() { Message = "This is a test message", ChatroomId = chatRoom.ChatroomModel.ChatroomId, UserId = USER.Id, ParentChatroomId = chatRoom.ChatroomModel.ParentChatroomId, UserHandle = USER.DefaultHandle }; var msgResult = chatControllerTest.ComposeMessage(messageModel); //Create test data model GetNewMessagesRequestModel model2 = new GetNewMessagesRequestModel() { ChatroomId = chatRoom.ChatroomModel.ChatroomId, UserId = USER.Id, ExistingMessageIds = new List <int>(), ParentChatroomId = chatRoom.ChatroomModel.ParentChatroomId, User = new UserModel() { Id = USER.Id } }; //Test that there are > 0 message results returned. var result = chatControllerTest.GetNewMessages(model2) as JsonResult; Assert.AreNotEqual(0, ((GetNewMessagesResponseModel)result.Data).MessagesInformation.Count); }
public void TestCreateChatroom() { //Necessary to create the child chatroom before requesting its information var USER = _helper.testUsers[1]; ChatroomController chatControllerTest = new ChatroomController(); ChatRequestModel model = new ChatRequestModel() { RawChatroomIdValue = "123401", UserHandle = USER.DefaultHandle, ChatroomName = "TestCreateChatroom", 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 - with all options possible since without them is easier. Do hard mode xD CreateChatroomRequestModel model2 = new CreateChatroomRequestModel() { ChatroomName = ("PRIVATE" + chatRoom.ChatroomModel.ChatroomName), ParentChatroomId = chatRoom.ChatroomModel.ChatroomId, Blacklist = "test1,test2", Password = "******", Capacity = 30, User = new UserModel() { Id = USER.Id } }; //Test creating a private chatroom success var result = chatControllerTest.CreateChatroom(model2) as JsonResult; Assert.AreEqual(0, ((CreateChatroomResponseModel)result.Data).Errors.Count); Assert.AreEqual(("PRIVATE" + chatRoom.ChatroomModel.ChatroomName), ((CreateChatroomResponseModel)result.Data).ChatroomName); Assert.AreEqual(chatRoom.ChatroomModel.ChatroomId, ((CreateChatroomResponseModel)result.Data).ParentChatroomId); Assert.AreEqual(USER.Id, ((CreateChatroomResponseModel)result.Data).UserId); //Test trying to create duplicate named private chatroom fail result = chatControllerTest.CreateChatroom(model2) as JsonResult; Assert.AreNotEqual(0, ((CreateChatroomResponseModel)result.Data).Errors.Count); Assert.AreEqual("A private chatroom with this name already exists.", ((CreateChatroomResponseModel)result.Data).Errors[0].ErrorMessage); }
public void Init() { chatroomController = new ChatroomController(); }