Пример #1
0
        public void IniciarCenario()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _fakeDbContext = new FakeDbContext(connection);

            _repositorio = new NotaFiscalEmitidaRepositorioSql();

            _notaFiscalRepositorioXML = new NotaFiscalRepositorioXML();

            _destinatarioRepositorio         = new DestinatarioRepositorioSql(_fakeDbContext);
            _emitenteRepositorio             = new EmitenteRepositorioSql(_fakeDbContext);
            _transportadorRepositorio        = new TransportadorRepositorioSql(_fakeDbContext);
            _produtoNotaFiscalRepositorioSql = new ProdutoNotaFiscalRepositorioSql(_fakeDbContext);


            long idEmitenteCadastradoPorBaseSql           = 1;
            long idDestinatarioCadastradoPorBaseSql       = 1;
            long idTransportadorCadastradoPorBaseSql      = 1;
            long idProdutoNotaFiscalCadastradorPorBaseSql = 1;

            _notaFiscalValida = ObjectMother.PegarNotaFiscalValidaComIdDasDependencias(idEmitenteCadastradoPorBaseSql, idDestinatarioCadastradoPorBaseSql, idTransportadorCadastradoPorBaseSql);
            _notaFiscalValida.Destinatario  = _destinatarioRepositorio.BuscarPorId(idDestinatarioCadastradoPorBaseSql);
            _notaFiscalValida.Emitente      = _emitenteRepositorio.BuscarPorId(idEmitenteCadastradoPorBaseSql);
            _notaFiscalValida.Transportador = _transportadorRepositorio.BuscarPorId(idTransportadorCadastradoPorBaseSql);
            _notaFiscalValida.Produtos      = new List <ProdutoNotaFiscal>();
            _notaFiscalValida.Produtos.Add(_produtoNotaFiscalRepositorioSql.BuscarPorId(idProdutoNotaFiscalCadastradorPorBaseSql));

            _notaFiscalValida.CalcularValoresTotais();
            _notaFiscalValida.GerarChaveDeAcesso(new Random());
            _notaFiscalValida.DataEmissao = DateTime.Now;
        }
Пример #2
0
 public ContextoTransistente() : base(DbConnectionFactory.CreatePersistent("ContextoTransistente"))
 {
     if (Centros.Count() == 0)
     {
         Seed();
     }
 }
Пример #3
0
        public void TestController()
        {
            DbConnection effortConnection = DbConnectionFactory.CreatePersistent("MyInstanceName");
            var          context          = new CustomerModel(effortConnection);

            Transaction tr = new Transaction {
                ID = 200, Amount = 200, Currency = "USD", Datetime = new DateTime(), Status = "Success"
            };
            var transactionsList = new LinkedList <Transaction>();

            transactionsList.AddFirst(tr);
            Customer user = new Customer {
                ID = 41, Name = "us1", Email = "*****@*****.**", MobileNo = 345346364346, Transactions = transactionsList
            };

            var mockHttpContext = new Mock <HttpRequestMessage>();
            var mockRequest     = new Mock <HttpRequestMessage>();

            mockRequest.Object.Content = new StringContent("{ \"ID\" : 41 }");

            context.Customers.Add(user);
            context.SaveChanges();

            var ctrl          = new CustomersController(context);
            var contentResult = ctrl.GetCustomer(mockRequest.Object) as OkNegotiatedContentResult <Customer>;

            var returnedCustomer     = contentResult.Content;
            var returnedTransactions = returnedCustomer.Transactions;

            Assert.AreEqual(returnedCustomer, user);
            Assert.AreEqual(returnedTransactions, transactionsList);
        }
Пример #4
0
        public override async Task RunAllAsync()
        {
            string dbId = "EFRepoTestMySqlAsync";

            using (var uow = new MySqlFullContext(DbConnectionFactory.CreatePersistent(dbId)))
            {
                await this.BaseUnitOfWorkUnitTests_BankAccount_AddAsync(uow);
            }

            using (var uow = new MySqlFullContext(DbConnectionFactory.CreatePersistent(dbId)))
            {
                await this.BaseUnitOfWorkUnitTests_BankAccount_GetAsync(uow);
            }

            using (var uow = new MySqlFullContext(DbConnectionFactory.CreatePersistent(dbId)))
            {
                await this.BaseUnitOfWorkUnitTests_BankAccount_AnyAsync(uow);
            }

            using (var uow = new MySqlFullContext(DbConnectionFactory.CreatePersistent(dbId)))
            {
                await this.BaseUnitOfWorkUnitTests_BankAccount_FirstOrDefaultAsync(uow);
            }

            using (var uow = new MySqlFullContext(DbConnectionFactory.CreatePersistent(dbId)))
            {
                await this.BaseUnitOfWorkUnitTests_BankAccount_RemoveAsync(uow);
            }

            using (var uow = new MySqlFullContext(DbConnectionFactory.CreatePersistent(dbId)))
            {
                await this.BaseUnitOfWorkUnitTests_BankAccount_AddRangeAsync(uow, 100, 2);
            }

            using (var uow = new MySqlFullContext(DbConnectionFactory.CreatePersistent(dbId)))
            {
                await this.BaseUnitOfWorkUnitTests_BankAccount_GetAllAsync(uow);
            }

            using (var uow = new MySqlFullContext(DbConnectionFactory.CreatePersistent(dbId)))
            {
                await this.BaseUnitOfWorkUnitTests_BankAccount_AllMatchingAsync(uow);
            }

            using (var uow = new MySqlFullContext(DbConnectionFactory.CreatePersistent(dbId)))
            {
                await this.BaseUnitOfWorkUnitTests_BankAccount_MaxAsync(uow);
            }

            using (var uow = new MySqlFullContext(DbConnectionFactory.CreatePersistent(dbId)))
            {
                await this.BaseUnitOfWorkUnitTests_BankAccount_RemoveRangeAsync(uow);
            }

            using (var uow = new MySqlFullContext(DbConnectionFactory.CreatePersistent(dbId)))
            {
                await this.BaseUnitOfWorkUnitTests_BankAccount_RollbackAsync(uow);
            }
        }
        public void Setup()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _ctx        = new FakeDbContext(connection);
            _repository = new VendaRepository(_ctx);
            _venda      = ObjectMother.Venda;
        }
Пример #6
0
 public void Setup()
 {
     System.Data.Common.DbConnection connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());
     _ctx        = new FakeDbContext(connection);
     _repository = new SpendingRepository(_ctx);
     _spending   = ObjectMother.GetValidSpending();
     //Seed
     _spendingSeed = ObjectMother.GetValidSpending();
     _ctx.Spendings.Add(_spendingSeed);
     _ctx.SaveChanges();
 }
Пример #7
0
        public void IniciarCenario()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _fakeDbContext = new FakeDbContext(connection);
            _repositorio   = new NotaFiscalRepositorioSql(_fakeDbContext);

            SementeBaseSQL semeador = new SementeBaseSQL(_fakeDbContext);

            semeador.Semear();
        }
Пример #8
0
 public void Setup()
 {
     System.Data.Common.DbConnection connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());
     _ctx        = new FakeDbContext(connection);
     _repository = new EmployeeRepository(_ctx);
     _employee   = ObjectMother.GetValidEmployee();
     //Seed
     _employeeSeed = ObjectMother.GetValidEmployee();
     _ctx.Employees.Add(_employeeSeed);
     _ctx.SaveChanges();
 }
Пример #9
0
        public void Setup()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _context     = new FakeDbContext(connection);
            _repository  = new BankAccountRepository(_context);
            _bankAccount = ObjectMother.BankAccountWithClientWithId();
            //Seed
            _bankAccountSeed = ObjectMother.BankAccountWithClientWithoutId();
            _context.BankAccounts.Add(_bankAccountSeed);
            _context.SaveChanges();
        }
Пример #10
0
        public void Setup()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _ctx         = new FakeDbContext(connection);
            _repository  = new TransactionRepository(_ctx);
            _transaction = ObjectMother.GetTransactionCredit();
            //Seed
            _transactionSeed = ObjectMother.GetTransactionDebt();
            _ctx.Transactions.Add(_transactionSeed);
            _ctx.SaveChanges();
        }
Пример #11
0
        public void Setup()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _ctx        = new FakeDbContext(connection);
            _repository = new UserRepository(_ctx);
            _user       = ObjectMother.GetValidUser();
            //Seed
            _userSeed = ObjectMother.GetValidUser();
            _ctx.Users.Add(_userSeed);
            _ctx.SaveChanges();
        }
Пример #12
0
        public void Setup()
        {
            var conexao = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _ctx        = new FakeDbContext(conexao);
            _repository = new IssuerRepository(_ctx);
            _issuer     = ObjectMother.IssuerValidWithIdAndWithAddress();
            //Seed
            _issuerBase = ObjectMother.IssuerValidWithIdAndWithAddress();
            _ctx.Issuers.Add(_issuerBase);
            _ctx.SaveChanges();
        }
Пример #13
0
        public void Setup()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _context    = new FakeDbContext(connection);
            _repository = new ProdutoRepository(_context);
            _produto    = ObjectMother.ProdutoDefault();
            //Seed
            _produtoSeed = ObjectMother.ProdutoDefault();
            _context.Produtos.Add(_produtoSeed);
            _context.SaveChanges();
        }
Пример #14
0
        public void IniciarCenario()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _fakeDbContext = new FakeDbContext(connection);
            _fakeDbContext.Database.Initialize(true);
            _repositorio = new ProdutoRepositorioSql(_fakeDbContext);

            SementeBaseSQL semeador = new SementeBaseSQL(_fakeDbContext);

            semeador.Semear();
        }
Пример #15
0
        public void Setup()
        {
            var conexao = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _ctx             = new FakeDbContext(conexao);
            _repository      = new ShippingCompanyRepository(_ctx);
            _shippingCompany = ObjectMother.ShippingCompanyValidWithIdWithAddress();
            //Seed
            _shippingCompanyBase = ObjectMother.ShippingCompanyValidWithIdWithAddress();
            _ctx.ShippingCompanies.Add(_shippingCompanyBase);
            _ctx.SaveChanges();
        }
Пример #16
0
        public void SetUp()
        {
            var conexao = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _contexto           = new FakeDbContext(conexao);
            _contaRepositorio   = new ContaRepositorio(_contexto);
            _clienteRepositorio = new ClienteRepositorio(_contexto);
            _conta     = ObjectMother.ObtemContaValida();
            _contaSeed = ObjectMother.ObtemContaValida();
            _contexto.Contas.Add(_contaSeed);
            _contexto.SaveChanges();
        }
Пример #17
0
        public void Setup()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _context    = new FakeDbContext(connection);
            _repository = new ProductRepository(_context);
            _product    = ObjectMother.ProductValidWithId();
            //Seed
            _productBase = ObjectMother.ProductValidWithId();
            _context.Products.Add(_productBase);
            _context.SaveChanges();
        }
Пример #18
0
        public void Setup()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _context    = new FakeDbContext(connection);
            _repository = new EmitenteRepository(_context);
            _emitente   = ObjectMother.GetEmitenteValido();
            //Seed
            _emitenteSeed = ObjectMother.GetEmitenteValido();
            _context.Emitentes.Add(_emitenteSeed);
            _context.SaveChanges();
        }
Пример #19
0
        public void Setup()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _ctx        = new FakeDbContext(connection);
            _repository = new ClientRepository(_ctx);
            _client     = ObjectMother.GetClientValid();
            //Seed
            _clientSeed = ObjectMother.GetClientValid();
            _ctx.Clients.Add(_clientSeed);
            _ctx.SaveChanges();
        }
        public void Setup()
        {
            var conexao = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _ctx        = new FakeDbContext(conexao);
            _repository = new AddresseReposiotory(_ctx);
            _addressee  = ObjectMother.AddresseeValidWithIdWithAddress();
            //Seed
            _addresseeBase = ObjectMother.AddresseeValidWithIdWithAddress();
            _ctx.Addressees.Add(_addresseeBase);
            _ctx.SaveChanges();
        }
        public void SetUp()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            Context     = new FakeDbContext(connection);
            _repository = new SeatRepository(Context);
            _seat       = ObjectMother.seatDefault;

            _seatSeed = ObjectMother.seatDefault;

            Context.Seats.Add(_seatSeed);
            Context.SaveChanges();
        }
Пример #22
0
        public void Setup()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _ctx        = new FakeDbContext(connection);
            _repository = new CheckingAccountRepository(_ctx);
            _account    = ObjectMother.GetCheckingAccountValid();
            //Seed
            _accountSeed = ObjectMother.GetCheckingAccountValid();
            _accountSeed.Transactions.Add(ObjectMother.GetTransactionCredit());
            _ctx.CheckingAccounts.Add(_accountSeed);
            _ctx.SaveChanges();
        }
        public void SetUp()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            Context     = new FakeDbContext(connection);
            _repository = new MovieRepository(Context);
            _movie      = ObjectMother.movieDefault;

            _movieSeed = ObjectMother.movieDefault;

            Context.Movies.Add(_movieSeed);
            Context.SaveChanges();
        }
Пример #24
0
        public void FilteredResultCreatedAfterTest()
        {
            using (var testDb = new TestDB(DbConnectionFactory.CreatePersistent("Test")))
            {
                var threeMonthsAgo = DateTime.UtcNow.AddMonths(-3).Ticks;
                var items          = FilteredResultHelpers.ProcessFilters <TestModel>(linqToObjects, new JObject()
                {
                    { "Created_after", threeMonthsAgo }
                });

                Assert.AreEqual(2, items.Count());
            }
        }
Пример #25
0
        public void FilteredResultCreatedBeforeTest()
        {
            using (var testDb = new TestDB(DbConnectionFactory.CreatePersistent("Test")))
            {
                var today = DateTime.UtcNow.Ticks;
                var items = FilteredResultHelpers.ProcessFilters <TestModel>(linqToObjects, new JObject()
                {
                    { "Created_before", today }
                });

                Assert.AreEqual(5, items.Count());
            }
        }
Пример #26
0
        public void Setup()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _context    = new FakeDbContext(connection);
            _repository = new UserRepository(_context);
            _user       = ObjectMother.GetDefaultUser();

            //Seed
            _userBase = ObjectMother.GetDefaultUser();
            _context.Users.Add(_userBase);
            _context.SaveChanges();
        }
        public void Setup()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _context    = new FakeDbContext(connection);
            _repository = new PurchaseRepository(_context);
            _purchase   = ObjectMother.GetDefaultPurchase();

            //Seed
            _purchaseBase = ObjectMother.GetDefaultPurchase();
            _context.Purchases.Add(_purchaseBase);
            _context.SaveChanges();
        }
Пример #28
0
        public void Setup()
        {
            var connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());

            _context    = new FakeDbContext(connection);
            _repository = new SessionRepository(_context);
            _session    = ObjectMother.GetDefaultSession();

            //Seed
            _sessionBase = ObjectMother.GetDefaultSession();
            _context.Sessions.Add(_sessionBase);
            _context.SaveChanges();
        }
 /// <summary>
 /// The search tests.
 /// </summary>
 /// <param name="dbId">
 /// The db id.
 /// </param>
 private void SearchTests(string dbId)
 {
     using (var uow = new DatabaseContext(DbConnectionFactory.CreatePersistent(dbId)))
     {
         this.Country_SearchTests(uow);
         this.Customer_SearchTests(uow);
         this.Product_SearchTests(uow);
         this.Book_SearchTests(uow);
         this.Software_SearchTests(uow);
         this.Order_SearchTests(uow);
         this.BankAccount_SearchTests(uow);
     }
 }
Пример #30
0
        public void Initialize()
        {
            System.Data.Common.DbConnection connection = DbConnectionFactory.CreatePersistent(Guid.NewGuid().ToString());
            _context       = new FakeDbContext(connection);
            userRepository = new UserRepository(_context);

            User userSeed = new User()
            {
                Password = "******", Username = "******"
            };

            _context.Users.Add(userSeed);
            _context.SaveChanges();
        }