Example #1
0
        public void InserirTest()
        {
            using var context = new Context(options);
            context.Database.EnsureCreated();

            IRequisicaoService service = new RequisicaoService(context, MapperProfile.GetMapper());

            var retorno = service.Inserir(new PostRequisicaoModel
            {
                NrRequisicao      = 1,
                DsRequisicao      = "Teste",
                DtSolicitacao     = DateTime.Now,
                NmSolicitante     = "Fulano",
                OrdensDeLiberacao = new HashSet <PostOrdemDeLiberacaoModel>
                {
                    new PostOrdemDeLiberacaoModel {
                        NrOrdemDeLiberacao = 0
                    },
                    new PostOrdemDeLiberacaoModel {
                        NrOrdemDeLiberacao = 1, ProjetosAfetados = new HashSet <PostProjetoAfetadoModel>
                        {
                            new PostProjetoAfetadoModel {
                                CdProjeto = -1
                            },
                            new PostProjetoAfetadoModel {
                                CdProjeto = -2
                            },
                        }
                    },
                }
            });

            Assert.IsNotNull(retorno);
        }
Example #2
0
 public DbFixture()
 {
     this.DbContext   = new AdventureWorksContext();
     this.Mapper      = MapperProfile.GetMapper();
     this.Repo        = new Repository(this.DbContext, this.Mapper);
     this.ProductRepo = new GenericRepository <Product>(this.DbContext);
 }
Example #3
0
        public void ObterTest()
        {
            using var context = new Context(options);
            IUsuarioService usuarioService = new UsuarioService(context, MapperProfile.GetMapper());
            var             user           = usuarioService.Obter(1);

            Assert.IsNotNull(user);
        }
Example #4
0
        public void ObterTest()
        {
            using var context = new Context(options);
            context.Database.EnsureCreated();

            IRequisicaoService service = new RequisicaoService(context, MapperProfile.GetMapper());

            var req = service.Obter().Include(r => r.OrdensDeLiberacao).FirstOrDefault();

            Assert.IsNotNull(req);
        }
Example #5
0
        public void NaoInserirTest()
        {
            using var context = new Context(options);
            IRequisicaoService service = new RequisicaoService(context, MapperProfile.GetMapper());

            try
            {
                var requisicao = new PostRequisicaoModel
                {
                    NrRequisicao      = 0,
                    DsRequisicao      = "Teste",
                    DtSolicitacao     = DateTime.Now,
                    NmSolicitante     = "Fulano",
                    OrdensDeLiberacao = new HashSet <PostOrdemDeLiberacaoModel>
                    {
                        new PostOrdemDeLiberacaoModel {
                            NrOrdemDeLiberacao = 0
                        },
                        new PostOrdemDeLiberacaoModel {
                            NrOrdemDeLiberacao = 1, ProjetosAfetados = new HashSet <PostProjetoAfetadoModel>
                            {
                                new PostProjetoAfetadoModel {
                                    CdProjeto = -1
                                },
                                new PostProjetoAfetadoModel {
                                    CdProjeto = -2
                                },
                            }
                        },
                    }
                };
                var retorno = service.Inserir(requisicao);
                Assert.Fail();
            }
            catch (ApiException)
            {
                Assert.IsTrue(true);
            }
        }