public async Task GetLastWalletEntryAsync_SingleEntry_ReturnsTheEntry() { //// Arrange // Setup In-Memory Database at desired state DbContextOptions <WalletContext> dbContextOptions = new DbContextOptionsBuilder <WalletContext>() .UseInMemoryDatabase(databaseName: "GetLastWalletEntryAsync_SingleEntry_ReturnsTheEntry") .Options; WalletEntry expectedEntry = new WalletEntry { Id = Guid.NewGuid().ToString(), EventTime = DateTime.UtcNow, Amount = 10, BalanceBefore = 0 }; using (WalletContext context = new WalletContext(dbContextOptions)) { context.Add(expectedEntry); context.SaveChanges(); } //// Act WalletEntry actualEntry; using (WalletContext context = new WalletContext(dbContextOptions)) { IWalletRepository walletRepository = new WalletRepository(context); actualEntry = await walletRepository.GetLastWalletEntryAsync(); } //// Assert Assert.NotNull(actualEntry); actualEntry.ShouldCompare(expectedEntry); }
public async Task CreateRequestForCommandAsync <T>(Guid id) { var exists = await ExistAsync(id); var request = exists ? throw new WalletDomainException($"Request with {id} already exists") : new ClientRequest() { Id = id, Name = typeof(T).Name, Time = DateTime.UtcNow }; _context.Add(request); await _context.SaveChangesAsync(); }
public async Task <int> addWallet(WalletEntity wallet) { db.Add(wallet); return(await db.SaveChangesAsync()); }
public async Task <int> addUser(UserEntity user) { db.Add(user); return(await db.SaveChangesAsync()); }