Ejemplo n.º 1
0
        public void CallUserServiceSubscribeForTeamsResultsMethod_WhenPassedTeamsNamesIsNotNull()
        {
            // arrange
            var contextMock = new Mock <ControllerContext>();

            contextMock.SetupGet(p => p.HttpContext.User.Identity.Name).Returns("username");
            contextMock.SetupGet(p => p.HttpContext.Request.IsAuthenticated).Returns(true);

            var userService             = new Mock <IUserService>();
            var subscriptionsController = new SubscriptionsController(userService.Object);

            var controller = new SubscriptionsController(userService.Object);

            controller.ControllerContext = contextMock.Object;

            var teams = new List <string>()
            {
                "someName"
            };

            // act
            controller.SubscribeForTeamResults(teams);

            // assert
            userService.Verify(u => u.SubscribeUserForTeamResults("username", teams), Times.Once);
        }
Ejemplo n.º 2
0
        public void RedirectToIndexAction_WhenPassedTeamsNamesAreNull()
        {
            // arrange
            var userService             = new Mock <IUserService>();
            var subscriptionsController = new SubscriptionsController(userService.Object);

            // act
            subscriptionsController.SubscribeForTeamResults(null);

            // assert
            subscriptionsController.WithCallTo(c => c.SubscribeForTeamResults(null))
            .ShouldRedirectTo(c => c.Index());
        }