public void SaveTransactionRepository()
        {
            var options = new DbContextOptionsBuilder <StonePagamentosDataContext>()
                          .UseInMemoryDatabase("StoneTeste")
                          .Options;
            var context = new StonePagamentosDataContext(options);

            context.Database.EnsureCreated();

            var transId = Guid.NewGuid();

            context.Transaction.Add(new Transaction()
            {
                Id     = Guid.NewGuid(),
                Amount = 100.00M,
                Number = 12,
                Active = true,
                Card   = new Card()
                {
                    Id        = Guid.NewGuid(),
                    CardBrand = "VISA",
                    CardType  = 1,
                    Number    = "4539204051740520"
                }
            });

            context.SaveChanges();

            List <Transaction> transactions = context.Transaction.ToList();

            Assert.IsTrue(transactions.Count() == 1);
        }
        public void SaveCardRepository()
        {
            var cardId = Guid.NewGuid();

            var options = new DbContextOptionsBuilder <StonePagamentosDataContext>()
                          .UseInMemoryDatabase("StoneTeste")
                          .Options;
            var context = new StonePagamentosDataContext(options);

            context.Database.EnsureCreated();

            context.Card.Add(new Card()
            {
                Id        = Guid.NewGuid(),
                CardBrand = "VISA",
                CardType  = 1,
                Number    = "4539204051740520"
            });

            context.SaveChanges();

            List <Card> Cards = context.Card.ToList();

            Assert.IsTrue(Cards.Count() == 2);
        }
 public CardRepository(StonePagamentosDataContext _context)
     : base(_context)
 {
 }
Ejemplo n.º 4
0
        //   private System.Data.Entity.DbContextTransaction dbTran;
        //http://www.entityframeworktutorial.net/entityframework6/transaction-in-entity-framework.aspx


        public BaseRepository(StonePagamentosDataContext _context)
        {
            Context = _context;
            this.Db = _context;
        }
 public TransactionRepository(StonePagamentosDataContext _context)
     : base(_context)
 {
 }