Ejemplo n.º 1
0
        public void SubscriberDetailsModel_Has_Properties_Are_True()
        {
            // Arrange - nothing to do here...

            // Act - not much to do here
            var detailsModel = new SubscriberDetailsModel
            {
               CombinedIndividualName = "Jane Doe",
                BTN = "1234567890"
            };

            // Assert - verify Has* properties are now true
            Assert.IsTrue(detailsModel.HasName);
            Assert.IsTrue(detailsModel.HasBtn);
        }
Ejemplo n.º 2
0
        public void Can_edit_a_billed_and_provisioned_subscriber_information()
        {
            using (ShimsContext.Create())
            {
                var myContext = new SIMPLTestContext();
                var currentSubscriber = new ShimCurrentSubscriber();

                //Given a user
                var fakeUserDto = myContext.GetFakeUserDtoObject();
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                //And the subscriber is billed
                currentSubscriber.FoundInBillingGet = () => true;

                //And the subscriber is provisioned
                var subModel = new SubscriberDetailsModel()
                {
                    Name = "New Name",
                    USI = "ID",
                    CBR = "CBR",
                    TriadEmail = "Email",
                };
                currentSubscriber.NameGet = () => subModel.Name;
                currentSubscriber.SubIdGet = () => subModel.USI;
                currentSubscriber.EmailGet = () => subModel.Email;
                currentSubscriber.CbrGet = () => subModel.CBR;

                //And the name needs to be changed on the provisioned account
                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;
                currentSubscriber.NameSetString = (myName) => { };
                ShimSubscriberExtension.MapToSubscriberCurrentSubscriber = (myCurrentSubscriber) => new SubscriberDto();
                ShimRosettianClient.AllInstances.UpdateSubscriberSubscriberDtoBooleanUserDto = (myRosettianClient, mySubscriber, overwrite, myUserDto) => true;
                ShimCurrentSubscriber.UpdateSubscriberDto = (mySubDto) => { };

                //When editing the subscriber
                var result = SubscriberControllerForTests.UpdateSubscriber(subModel) as JsonResult;

                //Then the user receives a response
                Assert.IsNotNull(result, "Update Subscriber test - null ActionResult");
                Assert.IsNotNull(result.Data, "Update Subscriber test - null ActionResult.Data");

                //And the response is successful
                dynamic resultStatus = result.Data;
                var status = resultStatus.status as string;
                Assert.IsNotNull(status);
                Assert.AreEqual("valid", status, "Reponse Status was error, it should have been valid.");
            }
        }
Ejemplo n.º 3
0
        public void RefreshSubscriber_ValidateSuccessScenario()
        {
            using (ShimsContext.Create())
            {
                var myContext = new SIMPLTestContext();
                var currentSubscriber = new ShimCurrentSubscriber();
                var fakeUserDto = myContext.GetFakeUserDtoObject();
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                // current sub
                currentSubscriber.FoundInBillingGet = () => true;
                var subModel = new SubscriberDetailsModel()
                {
                    Name = "JAMES SMITH",
                    USI = "123456789",
                    AccountType = AccountTypeDto.Residential,
                    CurrentServiceStatus = true
                };
                currentSubscriber.NameGet = () => subModel.Name;
                currentSubscriber.SubIdGet = () => subModel.USI;
                currentSubscriber.AccountTypeGet = () => subModel.AccountType;
                currentSubscriber.ServiceEnabledGet = () => subModel.CurrentServiceStatus;

                // fakes
                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;
                ShimSubscriberExtension.MapToSubscriberCurrentSubscriber = (myCurrentSubscriber) => new SubscriberDto();

                // fake ROZ PerformSubscriberOperation result
                ShimRosettianClient.AllInstances.PerformSubscriberOperationStringSubscriberOperationDtoUserDto =
                    (myRosettianClient, mySubId, mySubscriberOperationDto, myUserDto) => true;

                // expected json result
                var expectedJsonResult = new
                {
                    status = "valid",
                    message = string.Format("Successfully refreshed subscriber for USI [{0}]", subModel.USI)
                }.ToJSON();

                // call RefreshSubscriber action method
                var actualResult = SubscriberControllerForTests.RefreshSubscriber() as JsonResult;

                // validate result
                Assert.IsNotNull(actualResult, "JsonResult returned is null");
                Assert.IsNotNull(actualResult.Data, "JsonResult Data returned is null");
                Assert.AreEqual(expectedJsonResult, actualResult.Data.ToJSON());
            }
        }
Ejemplo n.º 4
0
        public void UpdateSubscriber_ModelStateIsInvalid_ValidateUserReceivesError()
        {
            using (ShimsContext.Create())
            {
                // Given a user that has permission to update subscriber
                ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject();

                // And a subscriber
                var subDetailModel = new SubscriberDetailsModel()
                {
                    USI = "usi",
                    Name = "name"
                };

                // And the subscriber is in invalid model state
                SubscriberControllerForTests.ModelState.AddModelError("key", "invalid model");

                // When updating the subscriber
                var actionResponse = SubscriberControllerForTests.UpdateSubscriber(subDetailModel) as JsonResult;

                // Then the user receives a response
                Assert.IsNotNull(actionResponse, "UpdateLocation action method returned null");

                // And the response is an error
                var expectedJson = new
                {
                    status = "invalid",
                    returnedPartial = string.Empty
                }.ToJSON();
                Assert.AreEqual(expectedJson, actionResponse.Data.ToJSON());
            }
        }
Ejemplo n.º 5
0
        public void RefreshSubscriber_ValidateErrorScenario()
        {
            using (ShimsContext.Create())
            {
                var myContext = new SIMPLTestContext();
                var currentSubscriber = new ShimCurrentSubscriber();
                var fakeUserDto = myContext.GetFakeUserDtoObject();
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                // current sub
                currentSubscriber.FoundInBillingGet = () => true;
                var subModel = new SubscriberDetailsModel()
                {
                    Name = "JAMES SMITH",
                    USI = "USIDOESNOTEXIST",
                    CurrentServiceStatus = true
                };
                currentSubscriber.NameGet = () => subModel.Name;
                currentSubscriber.SubIdGet = () => subModel.USI;
                currentSubscriber.AccountTypeGet = () => subModel.AccountType;
                currentSubscriber.ServiceEnabledGet = () => subModel.CurrentServiceStatus;

                // fakes
                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;
                ShimSubscriberExtension.MapToSubscriberCurrentSubscriber = (myCurrentSubscriber) => new SubscriberDto();

                // fake ROZ PerformSubscriberOperation exception
                var errorMessage = string.Format("Subscriber Id {0} does not exist", subModel.USI);
                ShimRosettianClient.AllInstances.PerformSubscriberOperationStringSubscriberOperationDtoUserDto =
                    (myRosettianClient, mySubId, mySubscriberOperationDto, myUserDto) =>
                    {
                        throw new Exception(errorMessage);
                    };

                // expected json result
                var expectedJsonResult = new
                {
                    status = "error",
                    errorMessage = string.Format("Error refreshing subscriber: {0}", errorMessage)
                }.ToJSON();

                // call RefreshSubscriber action method
                var actualResult = SubscriberControllerForTests.RefreshSubscriber() as JsonResult;

                // validate result
                Assert.IsNotNull(actualResult, "JsonResult returned is null");
                Assert.IsNotNull(actualResult.Data, "JsonResult Data returned is null");
                Assert.AreEqual(expectedJsonResult, actualResult.Data.ToJSON());
            }
        }