public async Task AreWeFriendsTest() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "InHarmonyTestLogicDB3") .Options; using (var context = new ApplicationDbContext(options)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); Repository _repository = new Repository(context, _logger); BusinessLogicClass businessLogicClass = new BusinessLogicClass(_repository, _mapperClass, _logger); var user1 = new User(); var user2 = new User(); _repository.users.Add(user1); _repository.users.Add(user2); context.SaveChanges(); var fl = new FriendList { FriendId = user1.Id, RequestedFriendId = user2.Id, status = "accept" }; _repository.friendList.Add(fl); context.SaveChanges(); var awf = await businessLogicClass.AreWeFriends(user1.Id, user2.Id); Assert.True(awf); _repository.friendList.Remove(fl); context.SaveChanges(); awf = await businessLogicClass.AreWeFriends(user1.Id, user2.Id); Assert.False(awf); } }
public async Task <bool> AreWeFriends(int userId, int FriendId) { bool AreFriends = await _businessLogicClass.AreWeFriends(userId, FriendId); return(AreFriends); }