public void Deve_Retornar_OK_Post() { var fakes = new FakeContext("LogErroControllerTest"); var fakeService = fakes.FakeLogErroService().Object; var expected = fakes.Get <LogErroDTO>().ToList(); for (int i = 0; i <= expected.Count - 1; i++) { expected[i].Id = 0; expected[i].Arquivado = false; } var controller = new LogErroController(fakeService, fakes.Mapper); var result = controller.Post(expected); Assert.IsType <OkObjectResult>(result.Result); var actual = (result.Result as OkObjectResult).Value as List <LogErroDTO>; Assert.NotNull(actual); Assert.Equal(expected.Count, actual.Count); for (int i = 0; i <= actual.Count - 1; i++) { Assert.Equal(999, actual[i].Id); Assert.Equal(expected[i].Titulo, actual[i].Titulo); Assert.Equal(expected[i].Descricao, actual[i].Descricao); Assert.Equal(expected[i].Ambiente, actual[i].Ambiente); Assert.Equal(expected[i].Nivel, actual[i].Nivel); Assert.Equal(expected[i].Evento, actual[i].Evento); Assert.Equal(expected[i].DataCriacao, actual[i].DataCriacao); Assert.Equal(expected[i].Origem, actual[i].Origem); Assert.Equal(expected[i].UsuarioOrigem, actual[i].UsuarioOrigem); } }
public void Deve_Retornar_Ok_Pesquisa_Por_Id(int id) { var fakes = new FakeContext("LogErroControllerTest"); var fakeService = fakes.FakeLogErroService().Object; var expected = fakes.Mapper.Map <LogErroDTO>(fakeService.FindById(id)); var controller = new LogErroController(fakeService, fakes.Mapper); var result = controller.Get(id); Assert.IsType <OkObjectResult>(result.Result); var actual = (result.Result as OkObjectResult).Value as LogErroDTO; Assert.NotNull(actual); Assert.Equal(expected, actual, new LogErroDTOComparer()); }
public void Deve_Retornar_Ok_Pesquisa_Por_Descricao_Ambiente(string descricao, string ambiente) { var fakes = new FakeContext("LogErroControllerTestDescricao"); var fakeService = fakes.FakeLogErroService().Object; var expected = fakes.Mapper.Map <List <LogErroDTO> >(fakeService.LocalizarPorDescricaoAmbiente(descricao, ambiente)); var controller = new LogErroController(fakeService, fakes.Mapper); var result = controller.GetDescricaoAmbiente(descricao, ambiente, false, false); Assert.IsType <OkObjectResult>(result.Result); var actual = (result.Result as OkObjectResult).Value as List <LogErroDTO>; Assert.NotEmpty(actual); Assert.Equal(expected, actual, new LogErroDTOComparer()); }
public void Deve_Retornar_Ok_Pesquisa_Por_Arquivados() { var fakes = new FakeContext("LogErroControllerTestArquivados"); var fakeService = fakes.FakeLogErroService().Object; var expected = fakes.Mapper.Map <List <LogErroDTO> >(fakeService.LocalizarArquivados()); var controller = new LogErroController(fakeService, fakes.Mapper); var result = controller.GetArquivados(); Assert.IsType <OkObjectResult>(result.Result); var actual = (result.Result as OkObjectResult).Value as List <LogErroDTO>; Assert.NotNull(actual); Assert.Equal(expected, actual, new LogErroDTOComparer()); }