public async void GetCPUsFromDatabaseTest() { var options = new DbContextOptionsBuilder <CheapWareContext>() .UseInMemoryDatabase(databaseName: "GetCpusFromDatabase") .Options; var cpu = new Cpus { Name = "test name", Speed = "3.6 Ghtz", Cores = 6, Price = 413.99M }; List <Cpu> listofcpus = null; using (var context = new CheapWareContext(options)) { context.Add(cpu); context.SaveChanges(); } using (var context = new CheapWareContext(options)) { var service = new ComputerRepo(context); listofcpus = await service.GetCpus(); } using (var context = new CheapWareContext(options)) { Assert.Single(listofcpus); Assert.Equal("test name", context.Cpus.Single().Name); } }