public static ExamDatabaseDbContext Create()
        {
            var options = new DbContextOptionsBuilder <ExamDatabaseDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var context = new ExamDatabaseDbContext(options);

            context.Database.EnsureCreated();

            context.Transactions.AddRange(new[] {
                new Transaction {
                    TransactionId   = "Invoice0000001",
                    Amount          = 1000,
                    TransactionDate = Convert.ToDateTime("2019-01-23T13:45:10"),
                    CurrencyCode    = "USD", Status = "D", FileType = "xml"
                },

                new Transaction {
                    TransactionId   = "Invoice0000002",
                    Amount          = 2000,
                    TransactionDate = Convert.ToDateTime("2019-01-23T13:45:10"),
                    CurrencyCode    = "USD", Status = "D", FileType = "xml"
                },
            });


            context.SaveChanges();

            return(context);
        }
Exemple #2
0
 public static void InitializeDbForTests(ExamDatabaseDbContext context)
 {
     context.Transactions.Add(new Transaction
     {
         TransactionId   = "Invoice0000001",
         Amount          = 1000,
         TransactionDate = Convert.ToDateTime("2019-01-23T13:45:10"),
         CurrencyCode    = "USD",
         Status          = "D",
         FileType        = "xml"
     });
     context.SaveChanges();
 }