public async void GetLastChat(int roomId) { var now = DateTime.Now; var chats = new List <RoomChat>(); //Arrange chats.Add(new RoomChat() { Id = 1, RoomId = roomId, UserId = "testUser", Date = now, Content = "testChat", Type = 1, }); chats.Add(new RoomChat() { Id = 2, RoomId = roomId, UserId = "testUser", Date = now, Content = "testChat", Type = 1, }); chats.Add(new RoomChat() { Id = 3, RoomId = roomId, UserId = "testUser", Date = now, Content = "testChat", Type = 1, }); // Act foreach (var chat in chats) { await RoomChatDAO.Create(roomContext, chat); } var result = RoomChatDAO.GetLastChat(roomContext, roomId); Assert.Equal(3, result.Id); Assert.Equal(roomId, result.RoomId); Assert.Equal("testUser", result.UserId); Assert.Equal("testChat", result.Content); Assert.Equal(1, result.Type); }
public static RoomChat GetLastChat(RoomDBContext context, int roomId) { return(RoomChatDAO.GetLastChat(context, roomId)); }