public async Task deleteMessage_MessageSentThenDeleted_MessageDeleted(int channelId, int userId, string message) { MessageModel model = new MessageModel(); model.ChannelId = channelId; model.UserId = userId; model.Message = message; IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IMessagesRepo messagesRepo = new MessagesRepo(dataGateway, connectionString); IChannelsRepo channelsRepo = new ChannelsRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserChannelsRepo userChannelsRepo = new UserChannelsRepo(dataGateway, connectionString); IMessagingService messagingService = new MessagingService(messagesRepo, channelsRepo, userChannelsRepo, userAccountRepository); await messagingService.SendMessageAsync(model); await messagingService.DeleteMessageAsync(0); IEnumerable <MessageModel> models = await messagesRepo.GetAllMessagesByChannelIdAsync(channelId); if (models.Count() == 1) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } }
public async Task sendMessage_MessageSent_MessageCreated(int channelId, int userId, string message) { MessageModel model = new MessageModel(); model.ChannelId = channelId; model.UserId = userId; model.Message = message; IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IMessagesRepo messagesRepo = new MessagesRepo(dataGateway, connectionString); IChannelsRepo channelsRepo = new ChannelsRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserChannelsRepo userChannelsRepo = new UserChannelsRepo(dataGateway, connectionString); IMessagingService messagingService = new MessagingService(messagesRepo, channelsRepo, userChannelsRepo, userAccountRepository); try{ await messagingService.SendMessageAsync(model); } catch { Assert.IsTrue(false); } IEnumerable <MessageModel> models = await messagesRepo.GetAllMessagesByChannelIdAsync(channelId); foreach (MessageModel modelList in models) { if (modelList.Message == model.Message) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } } }