Пример #1
0
        public void Create()
        {
            var controller = new PratosController();
            var result     = controller.Index() as ViewResult;

            Assert.IsNotNull(result.Model);
        }
Пример #2
0
        public async Task Buscar_OK()
        {
            //Prepara
            var ids = new[] {
                Guid.NewGuid(),
                Guid.NewGuid(),
                Guid.NewGuid(),
                Guid.NewGuid()
            };

            var response = new[] {
                new PratoPersistenciaModel
                {
                    Id   = ids[0],
                    Nome = "restaurante-a",
                },
                new PratoPersistenciaModel
                {
                    Id   = ids[1],
                    Nome = "restaurante-b",
                },
                new PratoPersistenciaModel
                {
                    Id   = ids[2],
                    Nome = "restaurante-c",
                },
                new PratoPersistenciaModel
                {
                    Id   = ids[3],
                    Nome = "restaurante-d",
                }
            };

            var servicoMock = new Mock <IServicoPersistenciaPrato>();

            servicoMock
            .Setup(s => s.Buscar())
            .ReturnsAsync(response);

            var controllerEmTeste = new PratosController(servicoMock.Object);

            //Executa
            var resp = await controllerEmTeste.buscar();

            //Verifica
            servicoMock.Verify(s => s.Buscar());
            resp.Should()
            .BeOfType <OkObjectResult>()
            .And
            .BeEquivalentTo(new OkObjectResult(response));
        }
Пример #3
0
 public void CriacaoController_OK()
 {
     //Prepara
     var servicoMock       = new Mock <IServicoPersistenciaPrato>();
     var controllerEmTeste = new PratosController(servicoMock.Object);
 }