public async Task GetTest() { var options = new DbContextOptionsBuilder <JanusContext>() .UseInMemoryDatabase(databaseName: "get-transaction") .Options; using (var context = new JanusContext(options)) { context.Add(new Transaction { Id = 1, Amount = 11.45, ExternalId = "externalId", Status = true, MerchantId = 1 }); context.Add(new Transaction { Id = 2, Amount = 0.55, ExternalId = "externalId2", Status = false, MerchantId = 1 }); context.SaveChanges(); } using (var newContext = new JanusContext(options)) { var paymentRepo = new PaymentRepository(newContext); var result = await paymentRepo.Get("externalId", 1); Assert.AreEqual(1, result.Id); Assert.AreEqual(11.45, result.Amount); Assert.IsTrue(result.Status); } }
public async Task GetTest() { var options = new DbContextOptionsBuilder <JanusContext>() .UseInMemoryDatabase(databaseName: "merchantDb") .Options; using (var context = new JanusContext(options)) { context.Add(new Merchant { Id = 1, Name = "MerchantA", ClientId = "123", ClientSecret = "Megasecret" }); context.SaveChanges(); } using (var newContext = new JanusContext(options)) { var merchantrepo = new MerchantRepository(newContext); var result = await merchantrepo.Get("123"); Assert.AreEqual(1, result.Id); Assert.AreEqual("MerchantA", result.Name); Assert.AreEqual("123", result.ClientId); Assert.AreEqual("Megasecret", result.ClientSecret); } }