public async Task ApproveShouldWorkCorrectly() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var friendRepository = new EfDeletableEntityRepository <Friend>(dbContext); var friendRequestRepository = new EfDeletableEntityRepository <FriendRequest>(dbContext); var newFriendShipRequest = new FriendRequest { SenderId = "1", ReceiverId = "2", }; var newFriendShip = new Friend { SenderId = "1", ReceiverId = "2", }; var service = new FriendService(friendRequestRepository, friendRepository); var sendRequestResult = service.CreateFriendRequestAsync("1", "2"); var sendSecondRequestResult = service.CreateFriendRequestAsync("1", "2"); var result = service.ApproveFriendRequestAsync("1", "2"); var countResult = friendRepository.All().Count(); Assert.Equal(1, countResult); }
public async Task CreateFriendRequestAsyncShouldCreateCorrectly() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); var friendRepository = new EfDeletableEntityRepository <Friend>(dbContext); var friendRequestRepository = new EfDeletableEntityRepository <FriendRequest>(dbContext); var service = new FriendService(friendRequestRepository, friendRepository); var result = service.CreateFriendRequestAsync("1", "2"); Assert.Equal(1, friendRequestRepository.All().Count()); }