public IHttpActionResult Post(ConversationDTO conversationDTO) { var messengerService = new MessengerService(); ConversationDTO convDTO = messengerService.CreateConversation(conversationDTO); if (convDTO == null) { return(NotFound()); } return(Ok(convDTO)); }
public void AddMessageTest() { SignUpAccountService signUpAccountService = new SignUpAccountService(); AccountService accountService = new AccountService(); MessengerService mesService = new MessengerService(); AdressDTO address = new AdressDTO(); address.latitude = 50; address.longitude = 30; address.address = "Beautiful city"; SignUpAccountDTO account = new SignUpAccountDTO(); account.FirstName = "Ion"; account.LastName = "Popescu"; account.UserName = "******"; account.Email = "*****@*****.**"; account.Adress = address; account.Password = "******"; SignUpAccountDTO account1 = new SignUpAccountDTO(); account1.FirstName = "Dfsadsa"; account1.LastName = "Ddsadsad"; account1.UserName = "******"; account1.Email = "*****@*****.**"; account1.Adress = address; account1.Password = "******"; AccountSimpleDTO acc = signUpAccountService.addAccount(account); AccountSimpleDTO acc1 = signUpAccountService.addAccount(account1); ConversationDTO conv = new ConversationDTO(); conv.UserOne = acc; conv.UserTwo = acc1; conv = mesService.CreateConversation(conv); MessageDTO message = new MessageDTO(); message.User = acc; message.ConversationId = conv.Id; message.Text = "Salut"; message.Date = DateTime.Now; message = mesService.addMessage(message); var messages = mesService.GetMessages(5, 1, acc.Id, acc1.Id); MessageDTO myMes = messages.FirstOrDefault(); mesService.deleteMessage(message.Id); mesService.RemoveConversation(conv.Id); accountService.deleteAccount(acc.Id); accountService.deleteAccount(acc1.Id); Assert.IsNotNull(message); Assert.IsNotNull(conv); Assert.IsNotNull(messages); Assert.AreEqual(myMes.Text, "Salut"); }