public void if_membership_id_exists_Retrieves_GamingConsoles_of_user_branch_from_repository_and_put_them_in_ViewBag()
        {
            var membership = new Membership();
            membership.Recharge(new MembershipReCharge { Hours = 5 });
            MembershipRepositoryMock.Setup(repo => repo.FindByMembershipId(membershipId)).Returns(membership);
            SetUpRepositoryWithGamingConsoles();

            var viewResult = MembershipController.Membership(membershipId, CustomUserIdentity);

            AssertGamingConsolesInViewBag(viewResult);
        }
        public void Returns_AssignConsole_view_with_membership_assign_console_ViewModel_if_membership_id_exists()
        {
            var membership = new Membership();
            membership.Recharge(new MembershipReCharge { Hours = 5 });
            MembershipRepositoryMock.Setup(repo => repo.FindByMembershipId(membershipId)).Returns(membership);

            var viewResult = MembershipController.Membership(membershipId, CustomUserIdentity);

            viewResult.ViewName.ShouldEqual("AssignConsole");
            var membershipAssignConsoleViewModel = viewResult.Model as MembershipAssignConsoleViewModel;
            membershipAssignConsoleViewModel.Game.ShouldNotBeNull();
            membershipAssignConsoleViewModel.Game.Price.ShouldEqual(0);
            membershipAssignConsoleViewModel.Game.GamePaymentType.ShouldEqual(GamePaymentType.Membership);
            membershipAssignConsoleViewModel.Game.BranchName.ShouldEqual(CustomUserIdentity.BranchName);
            membershipAssignConsoleViewModel.Membership.ShouldEqual(membership);
        }
        public void If_model_state_is_valid_assign_console_using_game_service_and_redirect_to_game_index()
        {
            var dateTime = DateTime.UtcNow.ToIST();
            membershipAssignConsoleViewModel.Game.InTime = dateTime;
            membershipAssignConsoleViewModel.Game.OutTime = dateTime.AddHours(1.5);
            var membership = new Membership();
            membership.Recharge(new MembershipReCharge { Hours = 2 });
            MembershipRepositoryMock
                .Setup(repo => repo.FindByMembershipId(membershipAssignConsoleViewModel.Membership.MembershipId))
                .Returns(membership);
            GameServiceMock.Setup(service => service.AssignConsoleForMembership(membership, membershipAssignConsoleViewModel.Game)).Verifiable();

            var actionResult = MembershipController.AssignConsole(membershipAssignConsoleViewModel);

            GameServiceMock.Verify(service => service.AssignConsoleForMembership(membership, membershipAssignConsoleViewModel.Game));
            AssertReadirectToAction(actionResult, "Index", "Game");
            MembershipController.TempData["Message"].ShouldEqual("Game assigned to membership successfully");
        }
        public void If_game_hours_is_greater_than_membership_remaining_hours_return_Assign_Console_View_with_model_error()
        {
            var dateTime = DateTime.UtcNow.ToIST();
            membershipAssignConsoleViewModel.Game.InTime = dateTime;
            membershipAssignConsoleViewModel.Game.OutTime = dateTime.AddHours(1.5);
            var membership = new Membership();
            membership.Recharge(new MembershipReCharge { Hours = 1});
            SetUpRepositoryWithGamingConsoles();
            MembershipRepositoryMock
                .Setup(repo => repo.FindByMembershipId(membershipAssignConsoleViewModel.Membership.MembershipId))
                .Returns(membership);

            var viewResult = MembershipController.AssignConsole(membershipAssignConsoleViewModel) as ViewResult;

            AssertGamingConsolesInViewBag(viewResult);
            AssertModelError(MembershipController, "Game", "Membership has only " + membership.RemainingHours + " hours. Please recharge!");
            viewResult.ViewName.ShouldEqual(string.Empty);
        }