public async Task CheckGettingTheReceiverAsync() { ApplicationDbContext db = GetDb(); var userChatGroupsRepository = new EfDeletableEntityRepository <UserChatGroup>(db); var chatGroupsRepository = new EfDeletableEntityRepository <ChatGroup>(db); var service = new ChatsService( this.chatMessagesRepository.Object, chatGroupsRepository, userChatGroupsRepository); var currentSender = new ApplicationUser() { Id = "20", UserName = "******", }; var currentReceiver = new ApplicationUser() { Id = "21", UserName = "******", }; await service.CreateUsersGroupAsync(currentSender, currentReceiver, "chat name"); var groupId = await service.GetGroupIdAsync("chat name"); var firstReceiverId = await service.GetReceiverAsync(groupId, currentSender.UserName); var secondReceiverId = await service.GetReceiverAsync(groupId, currentReceiver.UserName); Assert.Equal(currentReceiver.Id, firstReceiverId); Assert.Equal(currentSender.Id, secondReceiverId); }