Exemple #1
0
        public void CadastraFabricante()
        {
            //arrange
            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();

            fabricante1 = Generator.ValidFabricante();
            context.Fabricante.Add(fabricante1);

            var f2 = Generator.ValidFabricante();

            context.Fabricante.Add(f2);

            context.SaveChanges();

            page                = new UpdateFabricantePage();
            novoFabricante      = Generator.ValidFabricanteViewModel();
            novoFabricante.CNPJ = f2.CNPJ;

            //ACT
            page.NavegaToEdit(fabricante1.Id);
            page.ModificaFabricante(novoFabricante);
        }
        public void UpdateFabricante()
        {
            //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();

            var f = Generator.ValidFabricante();

            context.Fabricante.Add(f);
            context.SaveChanges();

            fabricanteEditado      = Generator.ValidFabricanteViewModel();
            fabricanteEditado.CNPJ = f.CNPJ;
            var page = new UpdateFabricantePage();
            var id   = context.Fabricante.First().Id;

            //act
            page.NavegaToEdit(id);
            page.ModificaFabricante(fabricanteEditado);
            context = new WebCadastradorContext(builder.Options);
            fabricanteCadastrado = context.Fabricante.First();
        }