public void UpdateSubID_SubNotFoundInDPI_ValidateSuccessScenario()
        {
            var loc = new LocationDto();
            var sub = new SubscriberDto();

            // newSubId
            var newSubId = DateTime.Now.ToString("MMddssff");
            newSubId += new Random().Next(1000, 9999);

            try
            {
                // new sub data
                loc = DataHelper.NewLocationData();
                sub = DataHelper.NewSubscriberData();
                sub.Accounts[0].Location = loc;
                sub.CustomFields = DataHelper.DefaultCustomFields_Sub();
                sub.Accounts[0].ServiceEnabled = true;
                DataHelper.RestoreLocation1(loc, false);
                DataHelper.RestoreSubscriber1(sub, false);

                // set current subscriber
                CurrentSubscriber.SetInstance(sub);

                var updateSubIdModel = new UpdateSubIDModel
                {
                    OldSubID = sub.ID,
                    NewSubID = newSubId
                };

                // call UpdateSubID action method
                var result = SubscriberControllerForTests.UpdateSubID(updateSubIdModel) as JsonResult;

                // expected subDetailsModel after UpdateSubID
                var subDetailsModel = sub.MapToSubDetailsModel();
                subDetailsModel.USI = newSubId;

                // validate response result
                Assert.IsNotNull(result, "Json result is null");
                Assert.IsNotNull(result.Data, "Json result data is null");
                dynamic resultStatus = result.Data;
                Assert.AreEqual("valid", resultStatus.status as string, "Response status does not match!");

                // validate subID changed in db
                var actualSub = DataHelper.LoadSubscriber(newSubId);
                Assert.IsNotNull(actualSub, "Subscriber should not be null!");
                Assert.AreEqual(newSubId, actualSub.ID);
                Assert.AreEqual(sub.Name, actualSub.Name);

                // validate the current subscriber session got updated
                var currentSubscriber = CurrentSubscriber.GetInstance();
                var actualSubDetailsModel = currentSubscriber.MapToSubDetailsModel();

                // validate FoundInBilling should be false
                Assert.IsFalse(actualSubDetailsModel.FoundInBilling, "FoundInBilling should be false");

                // validate actualSubDetailsModel matches expectedSubDetailsModel
                Assert.AreEqual(subDetailsModel.USI, actualSubDetailsModel.USI, "USI does not match");
                sub.ID = actualSubDetailsModel.USI;
                Assert.AreEqual(subDetailsModel.Name, actualSubDetailsModel.Name, "Name does not match");
                Assert.AreEqual(subDetailsModel.FoundInBilling, actualSubDetailsModel.FoundInBilling, "FoundInBilling does not match");
                Assert.AreEqual(subDetailsModel.CurrentServiceStatus, actualSubDetailsModel.CurrentServiceStatus, "CurrentServiceStatus does not match");
                Assert.IsTrue(actualSubDetailsModel.ServiceStatusDisplay.Contains("Enabled"), "ServiceStatusDisplay does not match");
            }
            catch (System.Exception ex)
            {
                Assert.IsTrue(ex is AssertFailedException, ex.ToString());
                throw;
            }
            finally
            {
                // delete sub.ID in case UpdateSubID failed
                DataHelper.DeleteSubscriber(sub.ID);

                // delete newSubId if UpdateSubID succeed
                DataHelper.DeleteSubscriber(newSubId);

                // delete location
                DataHelper.DeleteLocation(loc.ID);
            }
        }
        public void UpdateSubID_ValidateUserAbleToUpdateSubscriberID()
        {
            using (ShimsContext.Create())
            {
                // Given a user that has permission to update subscriber id
                ShimCurrentUser.AsUserDto = () => new UserDto();

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

                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => subId,
                    NameGet = () => subName,
                };

                var updateSubIdModel = new UpdateSubIDModel
                {
                    NewSubID = "newsubid",
                    OldSubID = subId,
                };

                var session = new ShimHttpSessionState
                {
                    ItemGetString = s =>
                    {
                        if (s == "")
                            return null;
                        return null;
                    }
                };
                ShimHttpContext.AllInstances.SessionGet = (o) => session;
                ShimCurrentSubscriber.SessionInstanceGet = () => new ShimCurrentSubscriber();
                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;

                // When enabling the service
                var subscriberController = DependencyResolver.Current.GetService<SubscriberController>();

                ShimRosettianClient.AllInstances.RenameSubscriberStringStringUserDto =
                    (myTestClient,myOldSubId, myNewSubId, myUserDto) => { };

                var actionResponse = subscriberController.UpdateSubID(updateSubIdModel) 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
                // And the service is enabled
                var jss = new JavaScriptSerializer();
                var expectedResult = new
                {
                    status = "valid",
                    returnedPartial = "",
                }.ToJSON();
                Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResponse.Data.ToJSON()));
            }
        }