public void AllShouldReturnListWithRequestSaveInDB() { var options = new DbContextOptionsBuilder <BookStoreDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; // var dbContext = new BookStoreDbContext(options); var userRequestService = new UserRequestsService(dbContext); var title = "Question"; var email = "*****@*****.**"; var content = "content"; userRequestService.Create(title, email, content); userRequestService.Create(title + 1, email, content); var isReurntallRequests = userRequestService.All().ToList(); Assert.True(isReurntallRequests != null); Assert.True(isReurntallRequests.Count == 2); }
public void AllShouldReturnAllUserRequest() { var options = new DbContextOptionsBuilder <XeonDbContext>() .UseInMemoryDatabase(databaseName: "All_UserRequests_Database") .Options; var dbContext = new XeonDbContext(options); var userRequestsService = new UserRequestsService(dbContext); dbContext.UserRequests.AddRange(new List <UserRequest> { new UserRequest { Title = "Question", Content = "content" }, new UserRequest { Title = "Request", Content = "content1" } }); dbContext.SaveChanges(); var userRequests = userRequestsService.All(); Assert.Equal(2, userRequests.Count()); }