public void RootController_Get_WillReturnString()
        {
            var controller = new RootController();
            var message    = controller.Get();

            Assert.AreEqual("API is ready to receive requests", message);
        }
        public async Task SiUsuarioNoEsAdmin_Obtenemos2Links_UsandoMoq()
        {
            // Preparación
            var mockAuthorizationService = new Mock <IAuthorizationService>();

            mockAuthorizationService.Setup(x => x.AuthorizeAsync(
                                               It.IsAny <ClaimsPrincipal>(),
                                               It.IsAny <object>(),
                                               It.IsAny <IEnumerable <IAuthorizationRequirement> >()
                                               )).Returns(Task.FromResult(AuthorizationResult.Failed()));

            mockAuthorizationService.Setup(x => x.AuthorizeAsync(
                                               It.IsAny <ClaimsPrincipal>(),
                                               It.IsAny <object>(),
                                               It.IsAny <string>()
                                               )).Returns(Task.FromResult(AuthorizationResult.Failed()));

            var mockURLHelper = new Mock <IUrlHelper>();

            mockURLHelper.Setup(x =>
                                x.Link(It.IsAny <string>(),
                                       It.IsAny <object>()))
            .Returns(string.Empty);

            var rootController = new RootController(mockAuthorizationService.Object);

            rootController.Url = mockURLHelper.Object;

            // Ejecución
            var resultado = await rootController.Get();

            // Verificación
            Assert.AreEqual(2, resultado.Value.Count());
        }
Example #3
0
        public void RootController_ShouldReturnPlaceholder()
        {
            var controller = new RootController(mockILoggerRootController());
            var result     = controller.Get() as ContentResult;

            Assert.Equal("This is a placeholder response for RootController", result.Content);
        }
        public async Task SiUsuarioNoEsAdmin_Obtenemos2Links()
        {
            // Preparación
            var authorizationService = new AuthorizationServiceMock();

            authorizationService.Resultado = AuthorizationResult.Failed();
            var rootController = new RootController(authorizationService);

            rootController.Url = new URLHelperMock();

            // Ejecución
            var resultado = await rootController.Get();

            // Verificación
            Assert.AreEqual(2, resultado.Value.Count());
        }