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); }
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); }
public void ObterTest() { using var context = new Context(options); IUsuarioService usuarioService = new UsuarioService(context, MapperProfile.GetMapper()); var user = usuarioService.Obter(1); Assert.IsNotNull(user); }
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); }
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); } }