public async void TestCreate() { // Arrange var gateway = new Gateway { Name = "Asdsd", IPv4 = "192.168.4.12", SerialNumber = "sdsd" }; var options = new DbContextOptionsBuilder <GatewayDbContext>().UseInMemoryDatabase("gateway_test_db"); var db = new GatewayDbContext(options.Options); db.RemoveRange(db.Gateways); db.SaveChanges(); var repo = new GatewayRepository(db); // Act var result = await repo.Create(gateway); // Assert Assert.True(result.Status); Assert.Equal((result.Entity as Gateway).IPv4, "192.168.4.12"); }