public async Task TestCreateOrderTransaction() { var placedDate = DateTime.Now; var supplier = _context.Suppliers.First(); var order = new Order() { PartTypeId = supplier.PartTypeId, SupplierId = supplier.Id, PartCount = 10, PlacedDate = placedDate }; await Assert.ThrowsAsync <NullReferenceException>(async() => await _context.CreateOrder(order)); using (var command = new SqliteCommand( @"SELECT Count(*) FROM [Order] WHERE SupplierId=@supplierId AND PartTypeId=@partTypeId AND PlacedDate=@placedDate AND PartCount=10 AND FulfilledDate IS NULL", _fixture.Connection )) { _context.AddParameter(command, "@supplierId", order.SupplierId); _context.AddParameter(command, "@partTypeId", order.PartTypeId); _context.AddParameter(command, "@placedDate", order.PlacedDate); Assert.Equal(0, (long)await command.ExecuteScalarAsync()); } }