public void UpdateMaxStb_ValidateUserAbleToUpdateMaxStb()
        {
            using (ShimsContext.Create())
            {
                // Given a user that has permission to update MAXSTB
                ShimCurrentUser.AsUserDto = () => new UserDto();

                // And a valid subscriber
                const string subId = "sub12345";

                // And the subscriber has MAXSTB 2
                const string maxstb = "2";

                // And the user has loaded the subscriber
                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => subId,
                    MaxStbGet = () => maxstb
                };
                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;

                // And the new MAXSTB to update is "5"
                var updateMaxStbModel = new UpdateMaxStbModel
                {
                    NewMaxStb = "5"
                };

                // When updating MAXSTB for the subscriber
                var subscriberController = DependencyResolver.Current.GetService<SubscriberController>();

                ShimRosettianClient.AllInstances.UpdateSubscriberSubscriberDtoBooleanUserDto =
                    delegate { return true; };
                ShimCurrentSubscriber.UpdateMaxStbString = (myMaxStb) => { };

                var actionResponse = subscriberController.UpdateMaxStb(updateMaxStbModel) as JsonResult;

                // Then the user receives a response
                Assert.IsNotNull(actionResponse, "Json result is null");
                Assert.IsNotNull(actionResponse.Data, "Json result data is null");

                // And the response is successful
                var jss = new JavaScriptSerializer();
                var expectedResult = new
                {
                    status = "valid",
                    message = string.Format("Successfully updated MAXSTB to {0}", updateMaxStbModel.NewMaxStb)
                }.ToJSON();
                Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResponse.Data.ToJSON()));
            }
        }
        public void UpdateMaxStb_Failed_ValidateReceivesError()
        {
            using (ShimsContext.Create())
            {
                // Given a user that has permission to update MAXSTB
                ShimCurrentUser.AsUserDto = () => new UserDto();

                // And a valid subscriber
                const string subId = "sub12345";

                // And the subscriber has MAXSTB 2
                const string maxstb = "2";

                // And the user has loaded the subscriber
                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => subId,
                    MaxStbGet = () => maxstb
                };
                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;

                // And the new MAXSTB to update is "5"
                var updateMaxStbModel = new UpdateMaxStbModel
                {
                    NewMaxStb = "5"
                };

                // And the ROZ service is done
                const string rozError = "ROZ ERROR MESSAGE";

                // When updating MAXSTB for the subscriber
                var subscriberController = DependencyResolver.Current.GetService<SubscriberController>();

                ShimRosettianClient.AllInstances.UpdateSubscriberSubscriberDtoBooleanUserDto =
                    delegate { throw new Exception(rozError); };

                var actionResponse = subscriberController.UpdateMaxStb(updateMaxStbModel) as JsonResult;

                // Then the user receives a response
                Assert.IsNotNull(actionResponse, "Json result is null");
                Assert.IsNotNull(actionResponse.Data, "Json result data is null");

                // And the response is an error
                var jss = new JavaScriptSerializer();
                var expectedResult = new
                {
                    status = "error",
                    message = string.Format("Error updating MAXSTB: {0}", rozError)
                }.ToJSON();
                Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResponse.Data.ToJSON()));
            }
        }