Пример #1
0
        public async Task Get_com_id_inexistente_deverá_retornar_NOTFOUND()
        {
            //Arrange
            var id         = 4;
            var repo       = new EmpresaRepositorioStub();
            var controller = new EmpresasController(repo);

            //Action
            var result = await controller.Get(id) as NotFoundResult;

            //Assert
            Assert.IsNotNull(result);

            controller.Dispose();
            repo.Dispose();
        }
Пример #2
0
        public async Task Get_deverá_retornar_todos_as_empresas()
        {
            //Arrange
            var repo       = new EmpresaRepositorioStub();
            var controller = new EmpresasController(repo);

            //Action
            var result = await controller.Get() as OkNegotiatedContentResult <List <Empresa> >;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(repo.Todos().Count(), result.Content.Count);

            controller.Dispose();
            repo.Dispose();
        }
Пример #3
0
        public async Task Get_com_id_deverá_retornar_a_empresa_desejada()
        {
            //Arrange
            var id         = 1;
            var repo       = new EmpresaRepositorioStub();
            var controller = new EmpresasController(repo);

            //Action
            var result = await controller.Get(id) as OkNegotiatedContentResult <Empresa>;

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(repo.ObterPorId(id), result.Content);

            controller.Dispose();
            repo.Dispose();
        }