示例#1
0
        public void Setup()
        {
            //arrange
            var builder = new DbContextOptionsBuilder <WebCadastradorContext>()
                          .UseLazyLoadingProxies()
                          .UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=WebCadastradorContext-dc88d854-cb2b-41f0-851e-fa57b037f7e8;Trusted_Connection=True;MultipleActiveResultSets=true");

            context = new WebCadastradorContext(builder.Options);
            context.Produto.Clear();
            context.Fabricante.Clear();
            context.SaveChanges();

            f = Generator.ValidFabricante();
            context.Add(f);
            context.SaveChanges();

            p            = Generator.ValidProduto();
            p.Fabricante = f;
            context.Add(p);
            context.SaveChanges();

            homePage           = new HomeIndex();
            carrinhoPage       = new CarrinhoIndex();
            finalizaPedidoPage = new FinalizaPedidoPage();
            //act
            homePage.DeletaCookies();
            homePage.Navigate();
            homePage.AdicionarItemAoCarrinho();
            itemCarrinho = carrinhoPage.ItensDoCarrinho.Single();
            carrinhoPage.FinalizarPedido();
        }
示例#2
0
        public async Task Setup()
        {
            var builder = new DbContextOptionsBuilder <WebCadastradorContext>()
                          .UseLazyLoadingProxies()
                          .UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=WebCadastradorContext-dc88d854-cb2b-41f0-851e-fa57b037f7e8;Trusted_Connection=True;MultipleActiveResultSets=true");

            context = new WebCadastradorContext(builder.Options);
            context.Produto.Clear();
            var controller = new ProdutosController(new ProdutoRepository(context), new FabricanteRepository(context));

            fabricante = Generator.ValidFabricante();
            context.Add(fabricante);
            context.SaveChanges();

            // act
            var content = new FormUrlEncodedContent(new Dictionary <string, string> {
                { "Nome", "abc" },
                { "Fabricante", fabricante.Id.ToString() },
                { "Preco", "9.93" }
            });

            response = await SetupGlobal.HttpClient.PostAsync("http://localhost/Produtos/Create", content);

            //assert
            context = new WebCadastradorContext(builder.Options);
            produto = context.Produto.FirstOrDefault();
        }
 public virtual async Task AddFabricanteAsync(Fabricante fabricante)
 {
     context.Add(fabricante);
     await context.SaveChangesAsync();
 }
 public async Task AddAsync(Produto produto)
 {
     context.Add(produto);
     await context.SaveChangesAsync();
 }
 public async Task AddClienteAsync(Cliente cliente)
 {
     context.Add(cliente);
     await context.SaveChangesAsync();
 }
示例#6
0
 public void AddItem(ItemPedido p)
 {
     context.Add(p);
     context.SaveChanges();
 }