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.");
            }
        }
        public void ReloadRGDetailsPartial_HappyPath()
        {
            using (ShimsContext.Create())
            {
                const string expectedSubscriberId = "Sub_01";
                const string expectedLocationId = "Loc_01";
                const string expectedWanIp = "192.168.1.1";
                const string expectedViewName = "RGDetails_Partial";

                var myContext = new SIMPLTestContext();

                // Shim current subscriber
                var shimSubscriber = new ShimCurrentSubscriber()
                {
                    LocationIdGet = () => expectedLocationId,
                    SubIdGet = () => expectedSubscriberId,
                    WanIpAddressGet = () => expectedWanIp
                };
                ShimCurrentSubscriber.GetInstance = () => shimSubscriber;
                ShimCurrentSubscriber.UpdateWanIpAddressString = o => { };

                // Shim Rosettian calls
                ShimRosettianClient.AllInstances.LoadSubscriberStringUserDto =
                    (client, subId, userDto) => new SubscriberDto();
                ShimRosettianClient.AllInstances.LoadSubscriberPhonesStringUserDto =
                    (client, subId, userDto) => new List<PhoneDto>();

                // Shim business facade
                ShimBusinessFacade.AllInstances.LoadCompositeEquipmentSearchFieldsDtoUserDto =
                    (client, searchFieldsDto, userDto) => new CompositeEquipment();

                // Shim current user
                ShimCurrentUser.AsUserDto = () => myContext.GetFakeUserDtoObject();

                // Fake the HttpContext
                ShimHttpContext.CurrentGet = () => new ShimHttpContext();

                // Fake the session state for HttpContext
                ShimHttpContext.AllInstances.SessionGet = (o) => new ShimHttpSessionState
                {
                    ItemGetString = s => s == "Subscriber" ? shimSubscriber : null
                };

                // Act
                var _controller = DependencyResolver.Current.GetService<ResidentialGatewayController>();
                var actionResult = _controller.ReloadRGDetailsPartial();

                Assert.IsNotNull(actionResult, "Expected ActionResult to not be null.");
                Assert.IsTrue(
                    actionResult is PartialViewResult,
                    string.Format("Expected ActionResult to be a PartialViewResult but got '{0}'.", actionResult.GetType())
                );

                // Act
                var partialView = actionResult as PartialViewResult;

                Assert.IsNotNull(partialView, "Expected ActionResult typecast to PartialViewResult to not be null");
                Assert.AreEqual(
                    expectedViewName,
                    partialView.ViewName,
                    string.Format("Expected ViewName to be '{0}' but got '{1}'", expectedViewName, partialView.ViewName)
                );
                Assert.IsTrue(partialView.Model is ResidentialGatewayModel);
            }
        }
        public void SyncPlantData_SadPath()
        {
            using (ShimsContext.Create())
            {
                //Arrange
                var myContext = new SIMPLTestContext();
                var fakeUserDto = myContext.GetFakeUserDtoObject();
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                //Fake the HttpContext
                var context = new ShimHttpContext();
                ShimHttpContext.CurrentGet = () => context;

                ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject();

                // Fake the session state for HttpContext
                var session = new ShimHttpSessionState
                {
                    ItemGetString = s =>
                    {
                        if (s == "")
                            return null;
                        return null;
                    }
                };
                ShimHttpContext.AllInstances.SessionGet = (o) => session;

                ShimErrorLoggingService.AllInstances.LogErrorException = (myClient, myException) => { };

                // Expected Result
                var expectedResult = new
                {
                    status = "error",
                    errorMessage = "There was an error while updating the data -- please try again"
                };

                var fakeCurrentSubscriber = new ShimCurrentSubscriber
                {
                    DpiRegionGet = () => "CT"
                };

                ShimCurrentSubscriber.SessionInstanceGet = () => fakeCurrentSubscriber;

                // Call FacilitiesController SyncPlantData
                var actualResult = FacilitiesControllerForTests.SyncPlantData() as JsonResult;

                // Test Validation
                Assert.IsNotNull(actualResult, "JsonResult returned is null");
                Assert.IsNotNull(actualResult, "JsonResult Data returned is null");
                Assert.AreEqual(expectedResult.ToString(), actualResult.Data.ToString());
            }
        }
        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 UpdateSubscriberServiceStatus_EnableService_ValidateUserAbleToEnableService()
        {
            using (ShimsContext.Create())
            {
                // Given a user that has permission to enable subscriber service
                ShimCurrentUser.AsUserDto = () => new UserDto();

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

                // And the subscriber has a valid provisioned location
                const string locId = "locId";

                // And the subscriber has service disenabled
                const bool serviceEnabled = false;

                // And the subscriber is not found in billing
                const bool foundInBilling = false;

                // And the user has loaded the subscriber
                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => subId,
                    NameGet = () => subName,
                    LocationIdGet = () => locId,
                    ServiceEnabledGet = () => serviceEnabled,
                    FoundInBillingGet = () => foundInBilling,
                    AccountTypeGet = () => AccountTypeDto.Residential,
                    CbrGet = () => "4250010001",
                    EmailGet = () => "*****@*****.**",
                    PINGet = () => "subpin",
                    PPVCapGet = () => "150.00",
                    PPVResetDayGet = () => "15",
                    PPVPrivilegeGet = () => SubscriberEnums.PPVPrivilegeEnum.Capped,
                    ProvisionedServicesListGet = () => new List<ServiceDto>()
                };

                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.UpdateSubscriberSubscriberDtoBooleanUserDto =
                    (myTestClient, mySubscriberDto, overriteService, myUserDto) => true;

                ShimSubscriberExtension.MapToSubDetailsModelCurrentSubscriber =
                    (myCurrentSubscriber) => new SubscriberDetailsModel
                    {
                        USI = subId,
                        Name = subName,
                        CurrentServiceStatus = true,
                        FoundInBilling = false,
                    };

                var actionResponse = subscriberController.UpdateSubscriberServiceStatus(true) 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",
                    message = @"The customer's account was <span class=""active"">Enabled</span>",
                    returnedPartial = "",
                }.ToJSON();
                Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResponse.Data.ToJSON()));
            }
        }
        public void LoadEditSubContent()
        {
            using (ShimsContext.Create())
            {
                // Arrange
                const string subscriberId = "1234567890";
                const string subscriberContactPhone = "4250010001";
                const string firstName = "JAMES";
                const string lastName = "SMITH";
                const AccountTypeDto accountType = AccountTypeDto.Business;
                var myContext = new SIMPLTestContext();

                // Build Fake UserDto
                var fakeUserDto = myContext.GetFakeUserDtoObject();

                // Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => fakeUserDto;
                ShimCurrentUser.GetInstance = () => new ShimCurrentUser
                {
                    UniqueIdGet = () => "abc123"
                };

                // Build Fake AccountDto
                var fakeAccountDto = myContext.GetFakeAccountDtoObject();
                fakeAccountDto.AccountType = accountType;

                // Build Fake CustomFieldDto
                var fakeCustomFieldDto = myContext.GetFakeCustomFieldDto();

                // Build Fake SubscriberDto
                var fakeSubscriberDto = myContext.GetFakeSubscriberDto(subscriberId, firstName, lastName, subscriberContactPhone, fakeCustomFieldDto, fakeAccountDto);

                // Build Fake PhoneNumberAsIdDto (internally builds the Fake TelephoneNumberDto)
                var fakePhoneNumberAsIdDto = myContext.GetFakePhoneNumberAsIdDto(subscriberContactPhone);

                // Build Fake BillingAccountIdDto
                var fakeBillingAccountIdDto = myContext.GetFakeBillingAccountIdDto(subscriberId, fakePhoneNumberAsIdDto);

                // Build Fake CustomerAccountIdDto
                var fakeCustomerAccountIdDto = myContext.GetFakeCustomerAccountIdDto(subscriberId, fakePhoneNumberAsIdDto);

                // Build Fake CustomerAccountDto (internaly builds the Fake IndividualNameDto,
                // the Fake IndividualDto, and the Fake CustomerDto)
                var fakeCustomerAccountDto = myContext.GetFakeCustomerAccountDto(firstName, lastName, subscriberId, fakeBillingAccountIdDto, fakeCustomerAccountIdDto);

                // Build Fake CompositeSubscriber
                var fakeCompositeSubscriber = new CompositeSubscriber()
                {
                    SubscriberTriad = fakeSubscriberDto,
                    SubscriberDpi = fakeCustomerAccountDto
                };

                // Fake the BusinessFacade.LoadCompositeSubscriber call
                ShimBusinessFacade.AllInstances.LoadCompositeSubscriberStringStringUserDto =
                    delegate { return fakeCompositeSubscriber; };

                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => "SubId",
                    ProvisionedServicesListGet = () => new List<ServiceDto>()
                };
                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;

                // Fake the CurrentSubscriber.SetInstance call
                ShimCurrentSubscriber.SetInstanceCompositeSubscriberSubscriberModel = (myCompositeSubscriber, mySubscriberModel) => { };

                // Fake the CurrentSubscriber.DataProductType call
                ShimCurrentSubscriber.AllInstances.StateGet = (myResult) => "CT";

                ShimCurrentUser.RetrieveUserRolesString = (myUniqueId) => new List<int>() { 1 };

                // Expected subscriber details model
                var expectedSubDetailsModel =
                    (fakeCompositeSubscriber.MapToSubscriberModel() ?? new SubscriberModel()).SubDetailsModel;
                Assert.IsNotNull(expectedSubDetailsModel, "Expected SubscriberDetailsModel is null");
                Assert.AreEqual(subscriberId, expectedSubDetailsModel.USI, "Expected USI does not match");
                Assert.AreEqual(accountType, expectedSubDetailsModel.AccountType, "Expected AccountType does not match");

                // Call LoadEditSubContent Action Method
                var result = SubscriberControllerForTests.LoadEditSubContent(expectedSubDetailsModel) as PartialViewResult;

                // Validate Action Method result
                Assert.IsNotNull(result, "LoadEditSubContent returned partial view is null");
                Assert.AreEqual("EditSub_Partial", result.ViewName, "LoadEditSubContent ViewName does not match!");

                // Validate returned subscriber details model
                var actualSubDetailsModel = result.Model as SubscriberDetailsModel;
                Assert.IsNotNull(actualSubDetailsModel, "Actual SubscriberDetailsModel is null");
                var jss = new JavaScriptSerializer();
                Assert.AreEqual(jss.Serialize(expectedSubDetailsModel), jss.Serialize(actualSubDetailsModel),
                    "SubscriberDetailsModel does not match");
            }
        }
        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());
            }
        }
예제 #8
0
        public void Suspend_Rf_Video_Service_HappyPath()
        {
            using (ShimsContext.Create())
            {
                //Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject();

                // Fake the HttpContext
                ShimHttpContext.CurrentGet = () => new ShimHttpContext();

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = delegate
                {
                    return new ShimHttpSessionState
                    {
                        ItemGetString = s => null
                    };
                };

                // Fake CurrentSubscriber
                var fakeProvisioningServiceList = new List<ServiceDto>();
                var fakeCurrentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => "test_subscriber",
                    VideoEnabledGet = () => true
                };
                ShimCurrentSubscriber.SessionInstanceGet = () => fakeCurrentSubscriber;
                ShimCurrentSubscriber.RefreshServicesData = () => { };
                fakeCurrentSubscriber.ProvisionedServicesListSetListOfServiceDto = (servicesParameter) =>
                {
                    fakeProvisioningServiceList = servicesParameter;
                };
                fakeCurrentSubscriber.ProvisionedServicesListGet = () => fakeProvisioningServiceList;

                // Fake RosettianClient
                ShimRosettianClient.AllInstances.SuspendServiceStringServiceClassTypeCollectionDtoUserDto = delegate
                {
                    return new ServiceCollectionDto
                    {
                        new ServiceDto
                        {
                            ClassName = "OVERRIDE",
                            Name = "NOVIDEO",
                            Description = "SUSPENDED VOICE"
                        },
                        new ServiceDto
                        {
                            ClassName = "RF - BASICS",
                            Name = "FIOS",
                            Description = "FIOS VIDEO SERVICE"
                        }
                    };
                };

                var servicesController = DependencyResolver.Current.GetService<ServicesController>();

                var result = servicesController.SuspendRestoreService(ServiceClassTypeDto.Video);
                Assert.IsNotNull(result, "Partial view result returned is null.");
                Assert.IsTrue(result is PartialViewResult, "Result is of type PartialViewResult");

                var viewResult = result as PartialViewResult;
                Assert.IsNotNull(viewResult, "PartialViewResult returned is null.");
                Assert.IsNotNull(viewResult.Model, "PartialViewResult.Model is null.");
                Assert.AreEqual(ServiceStatus.Suspended, ((ServiceStatusViewModel)viewResult.Model).VideoServiceStatus, "Video service is not suspended");
            }
        }
예제 #9
0
        public void Bug_16354_When_Restore_button_is_clicked_for_Voice_Service_and_a_generic_error_happens_that_has_an_error_message_longer_than_512_characters_the_return_will_include_the_first_512_characters_of_the_error_message()
        {
            using (ShimsContext.Create())
            {
                //Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject();

                // Fake the HttpContext
                ShimHttpContext.CurrentGet = () => new ShimHttpContext();

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = delegate
                {
                    return new ShimHttpSessionState
                    {
                        ItemGetString = s => null
                    };
                };

                // Fake CurrentSubscriber
                var fakeProvisioningServiceList = new List<ServiceDto>();
                var fakeCurrentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => "test_subscriber",
                    VoiceEnabledGet = () => false,
                };
                ShimCurrentSubscriber.SessionInstanceGet = () => fakeCurrentSubscriber;
                ShimCurrentSubscriber.RefreshServicesData = () => { };
                fakeCurrentSubscriber.ProvisionedServicesListSetListOfServiceDto = (servicesParameter) =>
                {
                    fakeProvisioningServiceList = servicesParameter;
                };
                fakeCurrentSubscriber.ProvisionedServicesListGet = () => fakeProvisioningServiceList;

                const string veryLongExceptionMessage = "Provisioning error: details follow, ErrorMessage: random text so that we have the same length of error message that was coming back in Bug 16354, but not the exact error message as we are going to add additional logic to handle that specific error message. abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abcdefghijklmnopqrstuvwxyz 0123456789 abc";
                const string messageEnding = " ... (message truncated)";
                var substringLength = 512 - messageEnding.Length;
                //var shortenedMessage = string.Format("{0}{1}", veryLongExceptionMessage.Substring(0, substringLength), messageEnding);
                var shortenedMessage = "Provisioning error: details follow, ErrorMessage: random text so that we have the same length of err...";

                // Fake RosettianClient
                ShimRosettianClient.AllInstances.RestoreServiceStringServiceClassTypeCollectionDtoUserDto = delegate
                {
                    throw new Exception(veryLongExceptionMessage);
                };

                ShimErrorLoggingService.AllInstances.LogErrorException = (myClient, myException) => { };

                var servicesController = DependencyResolver.Current.GetService<ServicesController>();

                var result = servicesController.SuspendRestoreService(ServiceClassTypeDto.Voice);
                Assert.IsNotNull(result, "result returned is null.");
                Assert.IsTrue(result is HttpStatusCodeResult, "Result was expected to be of type HttpStatusCodeResult");

                var viewResult = result as HttpStatusCodeResult;
                Assert.IsNotNull(viewResult, "HttpStatusCodeResult returned is null.");
                Assert.AreEqual(500, viewResult.StatusCode, "StatusCode doesn't match the expected value");
                Assert.AreEqual(shortenedMessage, viewResult.StatusDescription, "StatusDescription doesn't match the expected value");
            }
        }
예제 #10
0
        public void Remove_General_Terms_of_Service_Block_Success()
        {
            using (ShimsContext.Create())
            {
                //Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject();

                // Fake the HttpContext
                ShimHttpContext.CurrentGet = () => new ShimHttpContext();

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = delegate
                {
                    return new ShimHttpSessionState
                    {
                        ItemGetString = s => null
                    };
                };

                // Fake CurrentSubscriber
                var cfmtosService = new ServiceDto
                {
                    ClassName = "OVERRIDE",
                    Name = "CFMTOS",
                    Description = "CONFIRM TERMS"
                };
                var fakeProvisioningServiceList = new List<ServiceDto>
                {
                    cfmtosService,
                    new ServiceDto
                    {
                        ClassName = "DATA - DSL SPEED",
                        Name = "D24M3M",
                        Description = "24MBPS / 3MBPS"
                    }
                };
                var fakeCurrentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => "test_subscriber",
                    DataProductTypeGet = () => SubscriberEnums.DataProductType.XDsl,
                    DataEnabledGet = () => true,
                    GeneralTermsOfServiceStatusGet = () => TOSStatus.None,
                    E911TermsOfServiceStatusGet = () => TOSStatus.None
                };
                ShimCurrentSubscriber.SessionInstanceGet = () => fakeCurrentSubscriber;
                ShimCurrentSubscriber.UpdateSubscriberDto = delegate
                {
                    fakeProvisioningServiceList.Remove(cfmtosService);
                };
                fakeCurrentSubscriber.ProvisionedServicesListGet = () => fakeProvisioningServiceList;

                // Fake RosettianClient
                ShimRosettianClient.AllInstances.UpdateSubscriberSubscriberDtoBooleanUserDto = delegate { return true; };

                var result = ServicesControllerForTests.RemoveTermsOfServiceBlock(TOSTypeDto.GeneralTOS);
                Assert.IsNotNull(result, "Partial view result returned is null.");
                Assert.IsTrue(result is PartialViewResult, "Result is of type PartialViewResult");

                var viewResult = result as PartialViewResult;
                Assert.IsNotNull(viewResult, "PartialViewResult returned is null.");
                Assert.IsNotNull(viewResult.Model, "PartialViewResult.Model is null.");

                var model = (ServiceStatusViewModel)viewResult.Model;
                Assert.IsFalse(model.ShouldShowRemoveGeneralTermsOfServiceBlockButton);
                Assert.IsTrue(model.GeneralTermsOfServiceBlockRemoved);
            }
        }
예제 #11
0
        public void Restore_Ftth_Data_Service_HappyPath()
        {
            using (ShimsContext.Create())
            {
                //Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject();

                // Fake the HttpContext
                ShimHttpContext.CurrentGet = () => new ShimHttpContext();

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = delegate
                {
                    return new ShimHttpSessionState
                    {
                        ItemGetString = s => null
                    };
                };

                // Fake CurrentSubscriber
                var fakeProvisioningServiceList = new List<ServiceDto>();
                var fakeCurrentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => "test_subscriber",
                    DataEnabledGet = () => false,
                };
                ShimCurrentSubscriber.SessionInstanceGet = () => fakeCurrentSubscriber;
                ShimCurrentSubscriber.RefreshServicesData = () => { };
                fakeCurrentSubscriber.ProvisionedServicesListSetListOfServiceDto = (servicesParameter) =>
                {
                    fakeProvisioningServiceList = servicesParameter;
                };
                fakeCurrentSubscriber.ProvisionedServicesListGet = () => fakeProvisioningServiceList;

                // Fake RosettianClient
                ShimRosettianClient.AllInstances.RestoreServiceStringServiceClassTypeCollectionDtoUserDto = delegate
                {
                    return new ServiceCollectionDto
                    {
                        new ServiceDto
                        {
                            ClassName = "DATA - FTTH SPEED",
                            Name = "F25M25M",
                            Description = "25M DOWN 25M UP"
                        }
                    };
                };

                var servicesController = DependencyResolver.Current.GetService<ServicesController>();

                var result = servicesController.SuspendRestoreService(ServiceClassTypeDto.Data);
                Assert.IsNotNull(result, "Partial view result returned is null.");
                Assert.IsTrue(result is PartialViewResult, "Result is of type PartialViewResult");

                var viewResult = result as PartialViewResult;
                Assert.IsNotNull(viewResult, "PartialViewResult returned is null.");
                Assert.IsNotNull(viewResult.Model, "PartialViewResult.Model is null.");
                Assert.AreEqual(ServiceStatus.Active, ((ServiceStatusViewModel)viewResult.Model).DataServiceStatus, "Data service is not restored");
            }
        }
예제 #12
0
        public void Remove_General_Terms_of_Service_Block_Button_Should_Not_Be_Visible_When_Not_Enabled()
        {
            using (ShimsContext.Create())
            {
                // Fake the HttpContext
                ShimHttpContext.CurrentGet = () => new ShimHttpContext();

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = delegate
                {
                    return new ShimHttpSessionState
                    {
                        ItemGetString = s => null
                    };
                };

                // Fake CurrentSubscriber
                var fakeProvisioningServiceList = new List<ServiceDto>
                {
                    new ServiceDto
                    {
                        ClassName = "OVERRIDE",
                        Name = "CFMTOS",
                        Description = "CONFIRM TERMS"
                    },
                    new ServiceDto
                    {
                        ClassName = "DATA - DSL SPEED",
                        Name = "D24M3M",
                        Description = "24MBPS / 3MBPS"
                    }
                };
                var fakeCurrentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => "test_subscriber",
                    DataProductTypeGet = () => SubscriberEnums.DataProductType.XDsl,
                    DataEnabledGet = () => true,
                    GeneralTermsOfServiceStatusGet = () => TOSStatus.None,
                    E911TermsOfServiceStatusGet = () => TOSStatus.None
                };
                ShimCurrentSubscriber.SessionInstanceGet = () => fakeCurrentSubscriber;
                fakeCurrentSubscriber.ProvisionedServicesListGet = () => fakeProvisioningServiceList;

                // Fake ConfigurationManager
                ShimConfigurationManager.AppSettingsGet = () => new NameValueCollection
                {
                    { "RemoveGeneralTosBlockEnabled", "false" }
                };

                var model = new ServiceStatusViewModel();
                Assert.IsFalse(model.ShouldShowRemoveGeneralTermsOfServiceBlockButton);
            }
        }
예제 #13
0
        public void Remove_E911_Terms_of_Service_Block_Success()
        {
            using (ShimsContext.Create())
            {
                //Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject();

                // Fake the HttpContext
                ShimHttpContext.CurrentGet = () => new ShimHttpContext();

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = delegate
                {
                    return new ShimHttpSessionState
                    {
                        ItemGetString = s => null
                    };
                };

                // Fake CurrentSubscriber
                var cfmtosService = new ServiceDto
                {
                    ClassName = "OVERRIDE",
                    Name = "CFM911",
                    Description = "CONFIRM 911"
                };
                var fakeProvisioningServiceList = new List<ServiceDto>
                {
                    cfmtosService,
                    new ServiceDto
                    {
                        ClassName = "VOICE",
                        Name = "CVOIP",
                        Description = "CONSUMER VOIP"
                    }
                };
                var fakeCurrentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => "test_subscriber",
                    VoiceProductTypeGet = () => SubscriberEnums.VoiceProductType.CVoip,
                    VoiceEnabledGet = () => true,
                    GeneralTermsOfServiceStatusGet = () => TOSStatus.None,
                    E911TermsOfServiceStatusGet = () => TOSStatus.None
                };
                ShimCurrentSubscriber.SessionInstanceGet = () => fakeCurrentSubscriber;
                ShimCurrentSubscriber.UpdateSubscriberDto = delegate
                {
                    fakeProvisioningServiceList.Remove(cfmtosService);
                };
                fakeCurrentSubscriber.ProvisionedServicesListGet = () => fakeProvisioningServiceList;

                // Fake RosettianClient
                ShimRosettianClient.AllInstances.UpdateSubscriberSubscriberDtoBooleanUserDto = delegate { return true; };

                // Fake ConfigurationManager
                ShimConfigurationManager.AppSettingsGet = () => new NameValueCollection
                {
                    { "RemoveE911TosBlockEnabled", "true" }
                };

                // Fake Permissions.UserHasGrant
                ShimPermissions.UserHasGrantGrant = delegate { return true; };

                var result = ServicesControllerForTests.RemoveTermsOfServiceBlock(TOSTypeDto.E911TOS);
                Assert.IsNotNull(result, "Partial view result returned is null.");
                Assert.IsTrue(result is PartialViewResult, "Result is of type PartialViewResult");

                var viewResult = result as PartialViewResult;
                Assert.IsNotNull(viewResult, "PartialViewResult returned is null.");
                Assert.IsNotNull(viewResult.Model, "PartialViewResult.Model is null.");

                var model = (ServiceStatusViewModel)viewResult.Model;
                Assert.IsFalse(model.VoiceServiceStatusTemplate.ShouldShowRemoveE911TermsOfServiceBlockButton);
                Assert.IsTrue(model.E911TermsOfServiceBlockRemoved);
            }
        }
예제 #14
0
        public void Remove_E911_Terms_of_Service_Block_Button_Should_Not_Be_Visible_When_Not_Enabled()
        {
            using (ShimsContext.Create())
            {
                // Fake the HttpContext
                ShimHttpContext.CurrentGet = () => new ShimHttpContext();

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = delegate
                {
                    return new ShimHttpSessionState
                    {
                        ItemGetString = s => null
                    };
                };

                // Fake CurrentSubscriber
                var fakeProvisioningServiceList = new List<ServiceDto>
                {
                    new ServiceDto
                    {
                        ClassName = "OVERRIDE",
                        Name = "CFME911",
                        Description = "CONFIRM E911"
                    },
                    new ServiceDto
                    {
                        ClassName = "VOICE",
                        Name = "CVOIP",
                        Description = "CONSUMER VOIP"
                    }
                };
                var fakeCurrentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => "test_subscriber",
                    VoiceProductTypeGet = () => SubscriberEnums.VoiceProductType.CVoip,
                    VoiceEnabledGet = () => true,
                    GeneralTermsOfServiceStatusGet = () => TOSStatus.None,
                    E911TermsOfServiceStatusGet = () => TOSStatus.None
                };
                ShimCurrentSubscriber.SessionInstanceGet = () => fakeCurrentSubscriber;
                fakeCurrentSubscriber.ProvisionedServicesListGet = () => fakeProvisioningServiceList;

                // Fake ConfigurationManager
                ShimConfigurationManager.AppSettingsGet = () => new NameValueCollection
                {
                    { "RemoveE911TosBlockEnabled", "false" }
                };

                // Fake Permissions.UserHasGrant
                ShimPermissions.UserHasGrantGrant = delegate { return true; };

                var model = new ServiceStatusViewModel();
                Assert.IsFalse(model.VoiceServiceStatusTemplate.ShouldShowRemoveE911TermsOfServiceBlockButton);
            }
        }
예제 #15
0
        public void UpdatePPVVOD_ValidateUserAbleToUpdatePPVPrivilegeFromCappedToUnlimited()
        {
            using (ShimsContext.Create())
            {
                // Given a user that has permission to update ppv vod settings
                ShimCurrentUser.AsUserDto = () => new UserDto();

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

                // And the subscriber has ppv vod settings with ppv privilege capped
                var ppvVodModel = new PPV_VOD_SettingsModel
                {
                    PIN = "1234",
                    PINRequired = true,
                    PPVCap = "150.00",
                    PPVPrivilege = SubscriberEnums.PPVPrivilegeEnum.Capped,
                    PPVResetDay = 15
                };

                // And the user has loaded the subscriber
                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => subId,
                    NameGet = () => "subname",
                    LocationIdGet = () => "locid",
                    ServiceEnabledGet = () => true,
                    FoundInBillingGet = () => true,
                    AccountTypeGet = () => AccountTypeDto.Residential,
                    CbrGet = () => "4250010001",
                    EmailGet = () => "*****@*****.**",
                    PINGet = () => ppvVodModel.PIN,
                    PPVCapGet = () => ppvVodModel.PPVCap,
                    PPVResetDayGet = () => ppvVodModel.PPVResetDay.ToString(CultureInfo.InvariantCulture),
                    PPVPrivilegeGet = () => ppvVodModel.PPVPrivilege,
                    ProvisionedServicesListGet = () => new List<ServiceDto>()
                };

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

                // And the user edits ppv privilege from capped to unlimited
                var ppvVodModel4Update = new PPV_VOD_SettingsModel
                {
                    PIN = ppvVodModel.PIN,
                    PINRequired = ppvVodModel.PINRequired,
                    PPVCap = ppvVodModel.PPVCap,
                    PPVPrivilege = SubscriberEnums.PPVPrivilegeEnum.Unlimited,
                    PPVResetDay = ppvVodModel.PPVResetDay
                };

                // When updating the ppv vod settings
                var ppvVodController = DependencyResolver.Current.GetService<PPV_VODController>();

                ShimRosettianClient.AllInstances.UpdateSubscriberSubscriberDtoBooleanUserDto =
                    (myTestClient, mySubscriberDto, myOverriteService, myUserDto) => true;

                var actionResponse = ppvVodController.UpdatePPV_VOD(ppvVodModel4Update) as JsonResult;

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

                // And the response is successful
                var jss = new JavaScriptSerializer();
                var expectedResult = new
                {
                    status = "valid",
                    returnedPartial = "",
                }.ToJSON();
                Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResponse.Data.ToJSON()));
            }
        }
예제 #16
0
        public void UpdateMaxBandwidth_ValidateFailedScenario()
        {
            using (ShimsContext.Create())
            {
                const string subId = "sub12345";
                const string locId = "loc12345";
                const string oldMaxBandwidth = "19";
                const string newMaxBandwidth = "55";
                const string error = "error xyz";

                // current subscriber with maxbandwidth
                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => subId,
                    LocationIdGet = () => locId,
                    MaxBandwidthGet = () => oldMaxBandwidth,
                };

                // controller
                var servicesControllerForTest = DependencyResolver.Current.GetService<ServicesController>();

                // set values
                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;
                ShimCurrentUser.AsUserDto = () => new UserDto();

                // set rosettian exception
                ShimRosettianClient.AllInstances.UpdateLocationLocationDtoUserDto =
                    (myTestClient, myLocationDto, myUserDto) => { throw new SystemException("error xyz"); };

                // call UpdateMaxBandwidth action method
                var result = servicesControllerForTest.UpdateMaxBandwidth(locId, newMaxBandwidth) as JsonResult;

                // expected Json result
                var expectedJsonResult = new
                {
                    status = "error",
                    message = string.Format("Error updating Maxbandwidth: {0}", error)
                }.ToJSON();

                // validate results
                Assert.IsNotNull(result, "Json result returned is null");
                Assert.IsNotNull(result.Data, "Json result Data returned is null");
                Assert.AreEqual(expectedJsonResult, result.Data.ToJSON(), "Json result does not match");
            }
        }
예제 #17
0
        public void Index_When_DeviceID_IsNull_User_Is_Shown_Index2_View()
        {
            using (ShimsContext.Create())
            {
                // Arrange
                ShimRosettianClient.AllInstances.LoadLocationStringUserDto = delegate { return new LocationDto(); };
                ShimRosettianClient.AllInstances.GetServicesUserDto = delegate { return new ServiceCollectionDto(); };
                const string subscriberID = "999999999999";
                const string subscriberContactPhone = "9999999999";
                const string firstName = "Test";
                const string lastName = "Account";
                const string deviceID = null;
                var myContext = new SIMPLTestContext();

                // Build Fake UserDto
                var fakeUserDto = myContext.GetFakeUserDtoObject();

                // Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => fakeUserDto;
                ShimCurrentUser.GetInstance = () => new ShimCurrentUser
                {
                    UniqueIdGet = () => "abc123"
                };

                ShimCurrentUser.AllInstances.RolesGet = delegate { return new List<int> {1}; };

                // Shim Permissions.UserHasGrant
                ShimPermissions.UserHasGrantGrant = delegate { return true; };

                // Shim feature flag
                ShimFeatureFlags.IsEnabledString = delegate { return true; };

                // Build Fake AccountDto
                var fakeAccountDto = myContext.GetFakeAccountDtoObject();

                // Build Fake CustomFieldDto
                var fakeCustomFieldDto = myContext.GetFakeCustomFieldDto();

                // Build Fake SubscriberDto
                var fakeSubscriberDto = myContext.GetFakeSubscriberDto(subscriberID, firstName, lastName, subscriberContactPhone, fakeCustomFieldDto, fakeAccountDto);

                // Build Fake PhoneNumberAsIdDto (internally builds the Fake TelephoneNumberDto)
                var fakePhoneNumberAsIdDto = myContext.GetFakePhoneNumberAsIdDto(subscriberContactPhone);

                // Build Fake BillingAccountIdDto
                var fakeBillingAccountIdDto = myContext.GetFakeBillingAccountIdDto(subscriberID, fakePhoneNumberAsIdDto);

                // Build Fake CustomerAccountIdDto
                var fakeCustomerAccountIdDto = myContext.GetFakeCustomerAccountIdDto(subscriberID, fakePhoneNumberAsIdDto);

                // Build Fake CustomerAccountDto (internaly builds the Fake IndividualNameDto,
                // the Fake IndividualDto, and the Fake CustomerDto)
                var fakeCustomerAccountDto = myContext.GetFakeCustomerAccountDto(firstName, lastName, subscriberID, fakeBillingAccountIdDto, fakeCustomerAccountIdDto);

                // Build Fake CompositeSubscriber
                var fakeCompositeSubscriber = new CompositeSubscriber()
                {
                    SubscriberTriad = fakeSubscriberDto,
                    SubscriberDpi = fakeCustomerAccountDto,
                };

                // Fake the BusinessFacade.LoadCompositeSubscriber call
                ShimBusinessFacade.AllInstances.LoadCompositeSubscriberStringStringUserDto =
                    delegate { return fakeCompositeSubscriber; };

                // Build Fake fakeEquipmentDto
                var fakeEquipmentDto = new List<EquipmentDto>();

                // Fake the RosettianClient.SearchEquipment call
                ShimRosettianClient.AllInstances.SearchEquipmentSearchFieldsDtoUserDto =
                    (myRosettianClient, mySubscriberID, myUserObject) => fakeEquipmentDto;

                // Fake the EquipmentExtension.ToONTList call
                // Returning new List<ONT> as this is valid for this test as the subscriber doesn't have any equipment
                SIMPL.Areas.Common.Extensions.Fakes.ShimEquipmentExtension.ToONTListIEnumerableOfEquipmentDto =
                    (myEquipmentList) => new List<ONT>();

                // No Video Devices
                var fakeVideoDeviceList = new List<SerializableVideoDevice>();

                // Fake the EquipmentExtension.ToVideoDeviceList call
                ShimEquipmentExtension.ToVideoDeviceListIEnumerableOfEquipmentDto =
                    (myVideoDeviceList) => fakeVideoDeviceList;

                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => "SubId",
                    ProvisionedServicesListGet = () => new List<ServiceDto>()
                };
                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;

                // Fake the CurrentSubscriber.SetInstance call
                ShimCurrentSubscriber.SetInstanceCompositeSubscriberSubscriberModel = (myCompositeSubscriber, mySubscriberModel) => { };

                // Fake the CurrentSubscriber.DataProductType call
                ShimCurrentSubscriber.AllInstances.DataProductTypeGet = (myResult) => SubscriberEnums.DataProductType.Ftth;

                // Fake the CurrentSubscriber.VideoProductType call
                ShimCurrentSubscriber.AllInstances.VideoProductTypeGet = (myResult) => SubscriberEnums.VideoProductType.FiberRf;

                // Fake the CurrentSubscriber.DataProductType call
                ShimCurrentSubscriber.AllInstances.VoiceProductTypeGet = (myResult) => SubscriberEnums.VoiceProductType.FiberPots;

                // Fake the CurrentSubscriber.DataProductType call
                ShimCurrentSubscriber.AllInstances.StateGet = (myResult) => "CT";

                //Fake DB call to get Headends
                var headends = new List<HeadEnd>()
                {
                    new HeadEnd()
                    {
                        EntityKey = new EntityKey(),
                        headend_code = "1",
                        headend_loc = "1",
                        headend_name = "1",
                        headend_nbr = 1,
                        location_id = "1",
                        location_nbr = 1
                    }
                };

                ShimDBCache.HeadEndCodesGet = delegate { return headends; };

                //Fake Line Results DB Call.
                var testResultsDbSet = new ShimDbSet<test_results>();

                testResultsDbSet.Bind(new List<test_results>().AsQueryable());

                ShimLineTestEntities.AllInstances.test_resultsGet = delegate { return testResultsDbSet; };

                ShimCurrentUser.RetrieveUserRolesString = (myUniqueId) => new List<int>() { 1 };

                // 1st Act
                var result = SubscriberControllerForTests.Index(subscriberID, deviceID) as ViewResult;

                // 1st set of Asserts
                Assert.IsNotNull(result, "SubscriberController Index method returned null");
                Assert.IsNotNull(result.ViewName, "result.ViewName method returned null");
                Assert.IsTrue(result.ViewName.Equals("Index2"));
                Assert.IsTrue(result.Model is SubscriberModel, "Not SubscriberModel");

                // 2nd Act
                var testSubscriberModel = result.Model as SubscriberModel;

                // 2nd set of Asserts
                var successCode = "200";
                Assert.AreEqual(successCode, testSubscriberModel.ActionResponse.Code, "Test threw an exception {0}{0}{1}", Environment.NewLine, testSubscriberModel.ActionResponse.Message);

                var jss = new JavaScriptSerializer();
                var expectedModel = fakeCompositeSubscriber.MapToSubscriberModel();
                expectedModel.SubEquipmentModel.ONTOnlyList = new List<ONT>();
                expectedModel.SubEquipmentModel.RGOnlyList = new List<ONT>();
                expectedModel.SubEquipmentModel.LoadedSubID = subscriberID;
                expectedModel.SubEquipmentModel.LoadedLocID = expectedModel.SubLocationModel.LocationID;
                expectedModel.SubEquipmentModel.WanIpAddress = string.Empty;
                expectedModel.SubEquipmentModel.MaxStb = string.Empty;
                Assert.AreEqual(jss.Serialize(expectedModel.ActionResponse), jss.Serialize(testSubscriberModel.ActionResponse));

                Assert.AreEqual(jss.Serialize(expectedModel.SubDetailsModel), jss.Serialize(testSubscriberModel.SubDetailsModel));
                Assert.AreEqual(jss.Serialize(expectedModel.SubLocationModel),jss.Serialize(testSubscriberModel.SubLocationModel));

                // Since deviceID is null, check to verify that LoadedDeviceID is string.Empty
                Assert.AreEqual(string.Empty, expectedModel.SubLocationModel.LoadedDeviceID, "LoadedDeviceID should be string.Empty is deviceID is null");
                Assert.AreEqual(jss.Serialize(expectedModel.SubServicesModel),jss.Serialize(testSubscriberModel.SubServicesModel));
                Assert.AreEqual(jss.Serialize(expectedModel.SubEquipmentModel.ONTList), jss.Serialize(testSubscriberModel.SubEquipmentModel.ONTList), "SubscriberEquipmentModel ONTList");
                Assert.AreEqual(jss.Serialize(expectedModel.SubEquipmentModel.ONTOnlyList), jss.Serialize(testSubscriberModel.SubEquipmentModel.ONTOnlyList), "SubscriberEquipmentModel ONTOnlyList");
                Assert.AreEqual(jss.Serialize(expectedModel.SubEquipmentModel.RGOnlyList), jss.Serialize(testSubscriberModel.SubEquipmentModel.RGOnlyList), "SubscriberEquipmentModel RGOnlyList");
                Assert.AreEqual(jss.Serialize(expectedModel.SubEquipmentModel.VideoDeviceList), jss.Serialize(testSubscriberModel.SubEquipmentModel.VideoDeviceList), "SubscriberEquipmentModel VideoDeviceList");
                Assert.AreEqual(jss.Serialize(expectedModel.SubEquipmentModel), jss.Serialize(testSubscriberModel.SubEquipmentModel));
            }
        }
예제 #18
0
        public void UpdateMaxBandwidth_ValidateUserAbleToUpdateMaxBandwidth()
        {
            using (ShimsContext.Create())
            {
                // Given a user that has permission to update provisioned location
                ShimCurrentUser.AsUserDto = () => new UserDto();

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

                // And the subscriber has a valid provisioned location
                const string locId = "loc12345";

                // And the subscriber has a valid max bandwidth
                const string maxBandwidth = "19";

                // And the user has loaded the subscriber
                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => subId,
                    LocationIdGet = () => locId,
                    MaxBandwidthGet = () => maxBandwidth
                };
                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;

                // And the user edits the max bandwidth to a new valid value
                const string newMaxBandwidth = "55";

                // When updating max bandwith for the subscriber
                var servicesControllerForTest = DependencyResolver.Current.GetService<ServicesController>();

                ShimRosettianClient.AllInstances.UpdateLocationLocationDtoUserDto =
                    (myTestClient, myLocationDto, myUserDto) => true;
                ShimCurrentSubscriber.UpdateMaxBandwidthString = (myMaxBandwidth) => { };

                var actionResponse = servicesControllerForTest.UpdateMaxBandwidth(locId, newMaxBandwidth) 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 Max Bandwidth to {0} MB", newMaxBandwidth)
                }.ToJSON();
                Assert.AreEqual(jss.Serialize(expectedResult), jss.Serialize(actionResponse.Data.ToJSON()));
            }
        }
예제 #19
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());
            }
        }
예제 #20
0
        public void Bug_16354_When_Restore_button_is_clicked_for_Voice_Service_and_a_generic_error_happens_the_return_will_include_the_error_message()
        {
            using (ShimsContext.Create())
            {
                //Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject();

                // Fake the HttpContext
                ShimHttpContext.CurrentGet = () => new ShimHttpContext();

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = delegate
                {
                    return new ShimHttpSessionState
                    {
                        ItemGetString = s => null
                    };
                };

                // Fake CurrentSubscriber
                var fakeProvisioningServiceList = new List<ServiceDto>();
                var fakeCurrentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => "test_subscriber",
                    VoiceEnabledGet = () => false,
                };
                ShimCurrentSubscriber.SessionInstanceGet = () => fakeCurrentSubscriber;
                ShimCurrentSubscriber.RefreshServicesData = () => { };
                fakeCurrentSubscriber.ProvisionedServicesListSetListOfServiceDto = (servicesParameter) =>
                {
                    fakeProvisioningServiceList = servicesParameter;
                };
                fakeCurrentSubscriber.ProvisionedServicesListGet = () => fakeProvisioningServiceList;

                const string exceptionMessage = "An exception message that is less than 512 characters";

                // Fake RosettianClient
                ShimRosettianClient.AllInstances.RestoreServiceStringServiceClassTypeCollectionDtoUserDto = delegate
                {
                    throw new Exception(exceptionMessage);
                };

                ShimErrorLoggingService.AllInstances.LogErrorException = (myClient, myException) => { };

                var servicesController = DependencyResolver.Current.GetService<ServicesController>();

                var result = servicesController.SuspendRestoreService(ServiceClassTypeDto.Voice);
                Assert.IsNotNull(result, "result returned is null.");
                Assert.IsTrue(result is HttpStatusCodeResult, "Result was expected to be of type HttpStatusCodeResult");

                var viewResult = result as HttpStatusCodeResult;
                Assert.IsNotNull(viewResult, "HttpStatusCodeResult returned is null.");
                Assert.AreEqual(500, viewResult.StatusCode, "StatusCode doesn't match the expected value");
                Assert.AreEqual(exceptionMessage, viewResult.StatusDescription, "StatusDescription doesn't match the expected value");
            }
        }
예제 #21
0
        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()));
            }
        }
예제 #22
0
        public void Bug_16354_When_Restore_button_is_clicked_for_Voice_Service_and_the_APC_unconfigure_operation_failed_error_happens_the_error_message_is_customized()
        {
            using (ShimsContext.Create())
            {
                //Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject();

                // Fake the HttpContext
                ShimHttpContext.CurrentGet = () => new ShimHttpContext();

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = delegate
                {
                    return new ShimHttpSessionState
                    {
                        ItemGetString = s => null
                    };
                };

                // Fake CurrentSubscriber
                var fakeProvisioningServiceList = new List<ServiceDto>();
                var fakeCurrentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => "test_subscriber",
                    VoiceEnabledGet = () => false,
                };
                ShimCurrentSubscriber.SessionInstanceGet = () => fakeCurrentSubscriber;
                ShimCurrentSubscriber.RefreshServicesData = () => { };
                fakeCurrentSubscriber.ProvisionedServicesListSetListOfServiceDto = (servicesParameter) =>
                {
                    fakeProvisioningServiceList = servicesParameter;
                };
                fakeCurrentSubscriber.ProvisionedServicesListGet = () => fakeProvisioningServiceList;

                const string veryLongExceptionMessage = "Provisioning error: details follow, ErrorMessage: RemoteError-GENERIC:APC unconfigure operation failed Caused by: Could not unconfigure XDSL atm ptm(ANSI) on 1-1-4-30 Caused by: Unconfiguration of Following Configurator Failed: XDSL(ANSI) Bonding Link... Rollback Succeeded Caused by: XDSL MGT error 41 :, Controller Code:Success, Name:APC DSL, Type:Alcatel DSL APCErrorMessage: RemoteError-TEMPLATE_ALREADY_CONFIGURED:APC configure operation failed Caused by: Could not configure the complete configuration, did a successful rollback Caused by: Could not configure ISAM bridge port(ANSI) on 1-1-4-29.0.0 Caused by: ISAM bridge port(E, Controller Code:Success, Name:APC DSL, Type:Alcatel DSL APCErrorMessage: RemoteError-TEMPLATE_NOT_CONFIGURED:APC suspend operation failed Caused by: The template Stk-Pri-Bnd-HSIA is not configured on the port 'BETHCT35---01CAB101A:1-1-4-29', Controller Code:Success, Name:APC DSL, Type:Alcatel DSL APCErrorMessage: RemoteError-TEMPLATE_ALREADY_CONFIGURED:APC configure operation failed Caused by: The template 'Stack:Stk-Sec-Bnd null' is already configured on the port 'BETHCT35---01CAB101A:1-1-4-30', Controller Code:Success, Name:APC DSL, Type:Alcatel DSL APCErrorMessage: RemoteError-TEMPLATE_NOT_CONFIGURED:APC resume operation failed Caused by: The template Stk-Pri-Bnd-HSIA is not configured on the port 'BETHCT35---01CAB101A:1-1-4-29', Controller Code:Success, Name:APC DSL, Type:Alcatel DSL APC";
                const string expectedExceptionMessageShownToUser = "******";

                // Fake RosettianClient
                ShimRosettianClient.AllInstances.RestoreServiceStringServiceClassTypeCollectionDtoUserDto = delegate
                {
                    throw new Exception(veryLongExceptionMessage);
                };

                ShimErrorLoggingService.AllInstances.LogErrorException = (myClient, myException) => { };

                var servicesController = DependencyResolver.Current.GetService<ServicesController>();

                var result = servicesController.SuspendRestoreService(ServiceClassTypeDto.Voice);
                Assert.IsNotNull(result, "result returned is null.");
                Assert.IsTrue(result is HttpStatusCodeResult, "Result was expected to be of type HttpStatusCodeResult");

                var viewResult = result as HttpStatusCodeResult;
                Assert.IsNotNull(viewResult, "HttpStatusCodeResult returned is null.");
                Assert.AreEqual(500, viewResult.StatusCode, "StatusCode doesn't match the expected value");
                Assert.AreEqual(expectedExceptionMessageShownToUser, viewResult.StatusDescription, "StatusDescription doesn't match the expected value");
            }
        }
예제 #23
0
        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()));
            }
        }
예제 #24
0
        public void Index_WithMaxBandwidth()
        {
            using (ShimsContext.Create())
            {
                const string subId = "sub12345";
                const string locId = "loc12345";
                const string expectedViewName = "Services_Partial";
                const string maxBandwidth = "55";

                // current subscriber with maxbandwidth
                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => subId,
                    LocationIdGet = () => locId,
                    MaxBandwidthGet = () => maxBandwidth,
                };

                // controller
                var servicesControllerForTest = DependencyResolver.Current.GetService<ServicesController>();

                // set values
                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;

                // call Index action method
                var result = servicesControllerForTest.Index();

                // validate partial view result
                Assert.IsNotNull(result);
                Assert.AreEqual(expectedViewName, result.ViewName);

                // valiate model
                var model = result.Model as SubscriberServicesModel;
                Assert.IsNotNull(model);

                // validate maxbandwidth
                Assert.AreEqual(maxBandwidth, model.MaxBandwidth);
            }
        }
예제 #25
0
        public void Index_SubscriberDetails_AccountType()
        {
            using (ShimsContext.Create())
            {
                // Arrange
                const string subscriberId = "1234567890";
                const string subscriberContactPhone = "4250010001";
                const string firstName = "JAMES";
                const string lastName = "SMITH";
                const AccountTypeDto accountType = AccountTypeDto.Business;
                var myContext = new SIMPLTestContext();

                // Build Fake UserDto
                var fakeUserDto = myContext.GetFakeUserDtoObject();

                // Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => fakeUserDto;
                ShimCurrentUser.GetInstance = () => new ShimCurrentUser
                {
                    UniqueIdGet = () => "abc123"
                };

                // Build Fake AccountDto
                var fakeAccountDto = myContext.GetFakeAccountDtoObject();
                fakeAccountDto.AccountType = accountType;

                // Build Fake CustomFieldDto
                var fakeCustomFieldDto = myContext.GetFakeCustomFieldDto();

                // Build Fake SubscriberDto
                var fakeSubscriberDto = myContext.GetFakeSubscriberDto(subscriberId, firstName, lastName, subscriberContactPhone, fakeCustomFieldDto, fakeAccountDto);

                // Build Fake PhoneNumberAsIdDto (internally builds the Fake TelephoneNumberDto)
                var fakePhoneNumberAsIdDto = myContext.GetFakePhoneNumberAsIdDto(subscriberContactPhone);

                // Build Fake BillingAccountIdDto
                var fakeBillingAccountIdDto = myContext.GetFakeBillingAccountIdDto(subscriberId, fakePhoneNumberAsIdDto);

                // Build Fake CustomerAccountIdDto
                var fakeCustomerAccountIdDto = myContext.GetFakeCustomerAccountIdDto(subscriberId, fakePhoneNumberAsIdDto);

                // Build Fake CustomerAccountDto (internaly builds the Fake IndividualNameDto,
                // the Fake IndividualDto, and the Fake CustomerDto)
                var fakeCustomerAccountDto = myContext.GetFakeCustomerAccountDto(firstName, lastName, subscriberId, fakeBillingAccountIdDto, fakeCustomerAccountIdDto);

                // Build Fake CompositeSubscriber
                var fakeCompositeSubscriber = new CompositeSubscriber()
                {
                    SubscriberTriad = fakeSubscriberDto,
                    SubscriberDpi = fakeCustomerAccountDto
                };

                // Fake the BusinessFacade.LoadCompositeSubscriber call
                ShimBusinessFacade.AllInstances.LoadCompositeSubscriberStringStringUserDto =
                    delegate { return fakeCompositeSubscriber; };
                //TODO: Figure out why it is failing without below
                ShimRosettianClient.AllInstances.SearchEquipmentSearchFieldsDtoUserDto = delegate
                {
                    return new List<EquipmentDto>();
                };
                ShimRosettianClient.AllInstances.LoadLocationStringUserDto = delegate
                {
                    return new LocationDto();
                };

                ShimRosettianClient.AllInstances.SearchEquipmentSearchFieldsDtoUserDto = delegate
                {
                    return new List<EquipmentDto>();
                };
                ShimRosettianClient.AllInstances.LoadLocationStringUserDto = delegate
                {
                    return new LocationDto();
                };

                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => subscriberId,
                    ProvisionedServicesListGet = () => new List<ServiceDto>()
                };
                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;

                // Fake the CurrentSubscriber.SetInstance call
                ShimCurrentSubscriber.SetInstanceCompositeSubscriberSubscriberModel = (myCompositeSubscriber, mySubscriberModel) => { };

                // Call Index
                var result = SubscriberControllerForTests.Index(subscriberId, string.Empty) as ViewResult;

                // Validate view
                Assert.IsNotNull(result);
                Assert.AreEqual("Index2", result.ViewName, "ViewName does not match!");

                // Validate subscriber details account type
                var testSubscriberModel = result.Model as SubscriberModel ?? new SubscriberModel();

                var successCode = "200";
                Assert.AreEqual(successCode, testSubscriberModel.ActionResponse.Code, "Test threw an exception {0}{0}{1}", Environment.NewLine, testSubscriberModel.ActionResponse.Message);

                var actualSubDetailsModel = testSubscriberModel.SubDetailsModel;
                Assert.IsNotNull(actualSubDetailsModel, "SubscriberDetailsModel is null");
                Assert.AreEqual(subscriberId, actualSubDetailsModel.USI, "USI does not match");
                Assert.AreEqual(accountType, actualSubDetailsModel.AccountType, "AccountType does not match");
            }
        }
예제 #26
0
        public void AddServices_ValidateSuccessScenario()
        {
            using (ShimsContext.Create())
            {
                // current subId
                const string subId = "sub12345";

                // current locationId
                const string locId = "loc12345";

                // current service list
                var existingService = new ServiceDto
                {
                    ClassName = ServiceClassType.ProvisionedOntDataPort.GetStringValue(),
                    Name = "ENET",
                    Description = "RJ-45 ETHERNET PORT"
                };
                var existingServicesList = new List<ServiceDto> { existingService };

                // current subscriber with service list
                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => subId,
                    LocationIdGet = () => locId,
                    ProvisionedServicesListGet = () => existingServicesList
                };

                // set values
                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;
                ShimCurrentUser.AsUserDto = () => new UserDto();

                // service to be added
                var serviceToAdd = new ServiceDto
                {
                    ClassName = "DATA - FTTH SPEED",
                    Name = "F50M20M",
                    Description = "50M DOWN 20M UP"
                };
                var serviceToAddAsJson = "[" + new JavaScriptSerializer().Serialize(serviceToAdd) + "]";

                // expected service list (includes existing service and service to add)
                var expectedServicesListAfterAdd = new List<ServiceDto> { existingService, serviceToAdd };

                // expected SubscriberServiceModel after service add succeed
                var expectedSubscriberServiceModel = new SubscriberServicesModel
                {
                    SubscriberID = subId,
                    LocationID = locId,
                    ProvisionedServicesList = expectedServicesListAfterAdd
                };

                // set ROZ UpdateSubscriber succeed
                ShimRosettianClient.AllInstances.UpdateSubscriberSubscriberDtoBooleanUserDto =
                    (myTestClient, mySubscriberDto, overWriteServices, myUserDto) => true;

                // set CurrentSubscriber UpdateSubscriber succeed
                ShimCurrentSubscriber.UpdateSubscriberDto =
                    (mySubscriberDto) => { };

                // set MapToSubServicesModel
                ShimSubscriberExtension.MapToSubServicesModelCurrentSubscriber =
                    (myCurrentSubscriber) => expectedSubscriberServiceModel;

                // get service for ServicesController
                var servicesController = DependencyResolver.Current.GetService<ServicesController>();

                // call AddServices action method
                var actualJsonResult = servicesController.AddServices(serviceToAddAsJson) as JsonResult;

                // verify returned JsonResult is not null
                Assert.IsNotNull(actualJsonResult);

                // verify the result
                dynamic actualJson = actualJsonResult.Data;
                var status = actualJson.status as string;
                Assert.AreEqual("success", status, "AddServices returned Json result status does not match");
            }
        }
예제 #27
0
        public void Index_User_Is_Shown_Index2_View_With_A_Single_ONT_And_A_Single_RG()
        {
            using (ShimsContext.Create())
            {
                // Arrange
                ShimRosettianClient.AllInstances.LoadLocationStringUserDto = delegate { return new LocationDto(); };
                ShimRosettianClient.AllInstances.GetServicesUserDto = delegate { return new ServiceCollectionDto(); };
                const string subscriberID = "999999999999";
                const string subscriberContactPhone = "9999999999";
                const string firstName = "Test";
                const string lastName = "Account";
                const string deviceID = "11111111";
                var myContext = new SIMPLTestContext();

                // Build Fake UserDto
                var fakeUserDto = myContext.GetFakeUserDtoObject();

                // Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => fakeUserDto;
                ShimCurrentUser.GetInstance = () => new ShimCurrentUser
                {
                    UniqueIdGet = () => "abc123",
                };

                ShimCurrentUser.AllInstances.RolesGet = delegate { return new List<int> { 1 }; };

                // Shim Permissions.UserHasGrant
                ShimPermissions.UserHasGrantGrant = delegate { return true; };

                // Shim feature flag
                ShimFeatureFlags.IsEnabledString = delegate { return true; };

                // Build Fake AccountDto
                var fakeAccountDto = myContext.GetFakeAccountDtoObject();

                // Build Fake CustomFieldDto
                var fakeCustomFieldDto = myContext.GetFakeCustomFieldDto();

                // Build Fake SubscriberDto
                var fakeSubscriberDto = myContext.GetFakeSubscriberDto(subscriberID, firstName, lastName, subscriberContactPhone, fakeCustomFieldDto, fakeAccountDto);

                // Build Fake PhoneNumberAsIdDto (internally builds the Fake TelephoneNumberDto)
                var fakePhoneNumberAsIdDto = myContext.GetFakePhoneNumberAsIdDto(subscriberContactPhone);

                // Build Fake BillingAccountIdDto
                var fakeBillingAccountIdDto = myContext.GetFakeBillingAccountIdDto(subscriberID, fakePhoneNumberAsIdDto);

                // Build Fake CustomerAccountIdDto
                var fakeCustomerAccountIdDto = myContext.GetFakeCustomerAccountIdDto(subscriberID, fakePhoneNumberAsIdDto);

                // Build Fake CustomerAccountDto (internaly builds the Fake IndividualNameDto,
                // the Fake IndividualDto, and the Fake CustomerDto)
                var fakeCustomerAccountDto = myContext.GetFakeCustomerAccountDto(firstName, lastName, subscriberID, fakeBillingAccountIdDto, fakeCustomerAccountIdDto);

                // A single ONT
                var fakeEquipmentTypeDtoONT = new EquipmentTypeDto
                {
                    ONTModel = new ONTModelDto(),
                    Category = EquipmentCategoryDto.ONTDataPort
                };

                var myEquipmentDto1 = new EquipmentDto()
                {
                    Type = fakeEquipmentTypeDtoONT
                };

                // A single ONT
                var fakeEquipmentTypeDtoRG = new EquipmentTypeDto
                {
                    ONTModel = new ONTModelDto(),
                    Category = EquipmentCategoryDto.RGDataPort
                };

                var myEquipmentDto2 = new EquipmentDto()
                {
                    Type = fakeEquipmentTypeDtoRG
                };

                // A single Video Device
                var fakeEquipmentTypeDtoVideoDevice = new EquipmentTypeDto
                {
                    ONTModel = null
                };

                var myEquipmentDto3 = new EquipmentDto()
                {
                    Type = fakeEquipmentTypeDtoVideoDevice
                };

                fakeSubscriberDto.Accounts[0].Equipment = new EquipmentCollectionDto();
                fakeSubscriberDto.Accounts[0].Equipment.Add(myEquipmentDto1);
                fakeSubscriberDto.Accounts[0].Equipment.Add(myEquipmentDto2);
                fakeSubscriberDto.Accounts[0].Equipment.Add(myEquipmentDto3);

                // Build Fake CompositeSubscriber
                var fakeCompositeSubscriber = new CompositeSubscriber()
                {
                    SubscriberTriad = fakeSubscriberDto,
                    SubscriberDpi = fakeCustomerAccountDto
                };

                // Fake the BusinessFacade.LoadCompositeSubscriber call
                ShimBusinessFacade.AllInstances.LoadCompositeSubscriberStringStringUserDto =
                    delegate { return fakeCompositeSubscriber; };

                // Build Fake fakeEquipmentDto
                var fakeEquipmentDto = new List<EquipmentDto>();
                fakeEquipmentDto.Add(myEquipmentDto1);
                fakeEquipmentDto.Add(myEquipmentDto2);
                fakeEquipmentDto.Add(myEquipmentDto3);

                // Fake the RosettianClient.SearchEquipment call
                ShimRosettianClient.AllInstances.SearchEquipmentSearchFieldsDtoUserDto =
                    (myRosettianClient, mySubscriberID, myUserObject) => fakeEquipmentDto;

                // A single ONT
                var fakeONT = new ONT
                {
                    Type = fakeEquipmentTypeDtoONT
                };

                // A single RG
                var fakeRG = new ONT
                {
                    Type = fakeEquipmentTypeDtoRG
                };

                var fakeONTAndRGList = new List<ONT>();
                fakeONTAndRGList.Add(fakeONT);
                fakeONTAndRGList.Add(fakeRG);

                var fakeONTList = new List<ONT>();
                fakeONTList.Add(fakeONT);

                var fakeRGList = new List<ONT>();
                fakeRGList.Add(fakeRG);

                // Fake the EquipmentExtension.ToONTList call
                SIMPL.Areas.Common.Extensions.Fakes.ShimEquipmentExtension.ToONTListIEnumerableOfEquipmentDto =
                    (myEquipmentList) =>
                    {
                        if (myEquipmentList != null)
                        {
                            var items = myEquipmentList.ToList();

                            if (items.Any())
                            {
                                if (items.Count == 2)
                                {
                                    return fakeONTAndRGList;
                                }
                                if (items[0].Type.Category == EquipmentCategoryDto.ONTDataPort)
                                {
                                    return fakeONTList;
                                }
                                if (items[0].Type.Category == EquipmentCategoryDto.RGDataPort)
                                {
                                    return fakeRGList;
                                }
                            }
                        }

                        return new List<ONT>();
                    };

                // A single Video Device
                var fakeVideoDevice = new SerializableVideoDevice();
                var fakeVideoDeviceList = new List<SerializableVideoDevice>();
                fakeVideoDeviceList.Add(fakeVideoDevice);

                // Fake the EquipmentExtension.ToVideoDeviceList call
                ShimEquipmentExtension.ToVideoDeviceListIEnumerableOfEquipmentDto =
                    (myVideoDeviceList) => fakeVideoDeviceList;

                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => "SubId",
                    ProvisionedServicesListGet = () => new List<ServiceDto>()
                };
                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;

                // Fake the CurrentSubscriber.SetInstance call
                ShimCurrentSubscriber.SetInstanceCompositeSubscriberSubscriberModel = (myCompositeSubscriber, mySubscriberModel) => { };

                // Fake the CurrentSubscriber.DataProductType call
                ShimCurrentSubscriber.AllInstances.DataProductTypeGet = (myResult) => SubscriberEnums.DataProductType.Ftth;

                // Fake the CurrentSubscriber.VideoProductType call
                ShimCurrentSubscriber.AllInstances.VideoProductTypeGet = (myResult) => SubscriberEnums.VideoProductType.FiberRf;

                // Fake the CurrentSubscriber.DataProductType call
                ShimCurrentSubscriber.AllInstances.VoiceProductTypeGet = (myResult) => SubscriberEnums.VoiceProductType.FiberPots;

                // Fake the CurrentSubscriber.DataProductType call
                ShimCurrentSubscriber.AllInstances.StateGet = (myResult) => "CT";

                ShimCurrentUser.RetrieveUserRolesString = (myUniqueId) => new List<int>() { 1 };

                //Fake DB call to get Headends
                var headends = new List<HeadEnd>()
                {
                    new HeadEnd()
                    {
                        EntityKey = new EntityKey(),
                        headend_code = "1",
                        headend_loc = "1",
                        headend_name = "1",
                        headend_nbr = 1,
                        location_id = "1",
                        location_nbr = 1
                    }
                };

                ShimDBCache.HeadEndCodesGet = delegate { return headends; };

                //Fake Line Results DB Call.
                var testResultsDbSet = new ShimDbSet<test_results>();

                testResultsDbSet.Bind(new List<test_results>().AsQueryable());

                ShimLineTestEntities.AllInstances.test_resultsGet = delegate { return testResultsDbSet; };

                // 1st Act
                var result = SubscriberControllerForTests.Index(subscriberID, deviceID) as ViewResult;

                // 1st set of Asserts
                Assert.IsNotNull(result, "SubscriberController Index method returned null");
                Assert.IsNotNull(result.ViewName, "result.ViewName method is null");
                const string expectedViewName = "Index2";
                Assert.IsTrue(expectedViewName == result.ViewName, "Expected: " + expectedViewName + ", Actual: " + result.ViewName);
                Assert.IsTrue(result.ViewName.Equals(expectedViewName));
                Assert.IsTrue(result.Model is SubscriberModel, "Not SubscriberModel");

                // 2nd Act
                var testSubscriberModel = result.Model as SubscriberModel;

                // 2nd set of Asserts
                var successCode = "200";
                Assert.AreEqual(successCode, testSubscriberModel.ActionResponse.Code, "Test threw an exception {0}{0}{1}", Environment.NewLine, testSubscriberModel.ActionResponse.Message);

                var jss = new JavaScriptSerializer();
                var expectedModel = fakeCompositeSubscriber.MapToSubscriberModel();
                expectedModel.SubEquipmentModel = new SubscriberEquipmentModel
                {
                    ONTList = fakeONTAndRGList,
                    ONTOnlyList = fakeONTList,
                    RGOnlyList = fakeRGList,
                    VideoDeviceList = fakeVideoDeviceList,
                    AccessDeviceList = fakeONTAndRGList,
                    LoadedSubID = subscriberID,
                    LoadedLocID = expectedModel.SubLocationModel.LocationID,
                    WanIpAddress = string.Empty,
                    MaxStb = string.Empty
                };
                expectedModel.SubLocationModel.LoadedDeviceID = deviceID;
                Assert.AreEqual(jss.Serialize(expectedModel.ActionResponse), jss.Serialize(testSubscriberModel.ActionResponse), "SubscriberModel");
                Assert.AreEqual(jss.Serialize(expectedModel.SubDetailsModel), jss.Serialize(testSubscriberModel.SubDetailsModel), "SubscriberDetailsModel");
                Assert.AreEqual(jss.Serialize(expectedModel.SubLocationModel), jss.Serialize(testSubscriberModel.SubLocationModel), "SubscriberLocationModel");

                // Since deviceID is not null, check to verify that LoadedDeviceID has the expected value
                Assert.AreEqual(deviceID, expectedModel.SubLocationModel.LoadedDeviceID, "LoadedDeviceID should not be string.Empty is deviceID is {0}", deviceID);
                Assert.AreEqual(jss.Serialize(expectedModel.SubServicesModel), jss.Serialize(testSubscriberModel.SubServicesModel), "SubscriberServicesModel");
                Assert.AreEqual(jss.Serialize(expectedModel.SubEquipmentModel.ONTList), jss.Serialize(testSubscriberModel.SubEquipmentModel.ONTList), "SubscriberEquipmentModel ONTList");
                Assert.AreEqual(jss.Serialize(expectedModel.SubEquipmentModel.ONTOnlyList), jss.Serialize(testSubscriberModel.SubEquipmentModel.ONTOnlyList), "SubscriberEquipmentModel ONTOnlyList");
                Assert.AreEqual(jss.Serialize(expectedModel.SubEquipmentModel.RGOnlyList), jss.Serialize(testSubscriberModel.SubEquipmentModel.RGOnlyList), "SubscriberEquipmentModel RGOnlyList");
                Assert.AreEqual(jss.Serialize(expectedModel.SubEquipmentModel.VideoDeviceList), jss.Serialize(testSubscriberModel.SubEquipmentModel.VideoDeviceList), "SubscriberEquipmentModel VideoDeviceList");
                Assert.AreEqual(jss.Serialize(expectedModel.SubEquipmentModel), jss.Serialize(testSubscriberModel.SubEquipmentModel), "SubscriberEquipmentModel entire object");
            }
        }
예제 #28
0
        public void LoadPPV_VOD_Mgmt_HasPPVSettings_HasPPVPrivilegeUnlimited_HasVideoDeviceActions_UserAbleToLoadPpvVodMgmt()
        {
            using (ShimsContext.Create())
            {
                // Given a user
                ShimCurrentUser.AsUserDto = () => new UserDto();

                // And a provisioned subscriber
                const string subId = "subid";

                // And the subscriber has valid ppv vod settings
                // And the ppv privilege is unlimited
                // And the subscriber has history of video device actions for drop
                var ppvVodMgmtModel = new PPV_VOD_MgmtModel
                {
                    PIN = "1234",
                    PINRequired = true,
                    PPVCap = "150.00",
                    PPVPrivilege = SubscriberEnums.PPVPrivilegeEnum.Unlimited,
                    PPVResetDay = 15,
                    DeviceActions = new VideoDeviceActionCollectionDto
                    {
                        new VideoDeviceActionDto
                        {
                            DeviceID = "deviceid",
                            DeviceModel = "videodevicemodel",
                            Action = "dropped",
                            ActionDate = DateTime.Now,
                        }
                    }
                };

                // And the user has loaded the subscriber
                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => subId,
                    PINGet = () => ppvVodMgmtModel.PIN,
                    PINRequiredGet = () => ppvVodMgmtModel.PINRequired,
                    PPVPrivilegeGet = () => ppvVodMgmtModel.PPVPrivilege,
                    PPVResetDayGet = () => ppvVodMgmtModel.PPVResetDay.ToString(CultureInfo.InvariantCulture),
                    PPVCapGet = () => ppvVodMgmtModel.PPVCap
                };

                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 loading the ppv and vod management for the subscriber
                ShimRosettianClient.AllInstances.GetVideoDeviceActionsStringUserDto =
                    (myTestClient, mySubId, myUserDto) => ppvVodMgmtModel.DeviceActions;

                var ppvVodController = DependencyResolver.Current.GetService<PPV_VODController>();
                var actionResponse = ppvVodController.LoadPPV_VOD_Mgmt(subId) as PartialViewResult;

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

                // And the response is successful
                Assert.AreEqual("PPV_VOD_Mgmt_Partial", actionResponse.ViewName);
                var actualPpvVodMgmtModel = actionResponse.Model as PPV_VOD_MgmtModel;
                Assert.IsNotNull(actualPpvVodMgmtModel, "PPV_VOD_MgmtModel is null");

                // And the returned ppv vod info matches with the requested ppv vod info for the subscriber
                Assert.AreEqual(ppvVodMgmtModel.PPVPrivilege, actualPpvVodMgmtModel.PPVPrivilege, "PPVPrivilege does not match");
                Assert.AreEqual(ppvVodMgmtModel.PPVCap, actualPpvVodMgmtModel.PPVCap, "PPVCape does not match");
                Assert.AreEqual(ppvVodMgmtModel.PPVResetDay, actualPpvVodMgmtModel.PPVResetDay, "PPVResetDay does not match");
                Assert.AreEqual(ppvVodMgmtModel.PINRequired, actualPpvVodMgmtModel.PINRequired, "PinRequired does not match");
                Assert.AreEqual(ppvVodMgmtModel.PIN, actualPpvVodMgmtModel.PIN, "PIN does not match");

                // And the returned video devices actions matches with the requestd video devices actions for the subscriber
                var jss = new JavaScriptSerializer();
                Assert.AreEqual(jss.Serialize(ppvVodMgmtModel.DeviceActions), jss.Serialize(actualPpvVodMgmtModel.DeviceActions), "DeviceActions does not match");
            }
        }
예제 #29
0
        public void SyncPlantData_HappyPath()
        {
            using (ShimsContext.Create())
            {
                //Arrange
                var myContext = new SIMPLTestContext();
                var fakeUserDto = myContext.GetFakeUserDtoObject();
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                // Fake the HttpContext
                var context = new ShimHttpContext();
                ShimHttpContext.CurrentGet = () => context;

                // Fake the session state for HttpContext
                var session = new ShimHttpSessionState
                {
                    ItemGetString = s =>
                    {
                        if (s == "")
                            return null;
                        return null;
                    }
                };

                ShimHttpContext.AllInstances.SessionGet = (o) => session;

                 //Expected Result
                var expectedResult = new
                {
                    status = "valid",
                    message = "Success: DPI plant data will be updated in the next 10 minutes."
                };

                var fakeCurrentSubscriber = new ShimCurrentSubscriber
                {
                   LocationIdGet = () => "0089451",
                   DpiRegionGet = ()=>"CT"
                };

                ShimCurrentSubscriber.SessionInstanceGet = () => fakeCurrentSubscriber;

                // Call FacilitiesController SyncPlantData
                ShimEnterpriseClient.AllInstances.SyncPlantDataStringHeaderArgs = delegate { return true; };

                //Act
                var actualResult = FacilitiesControllerForTests.SyncPlantData() as JsonResult;

                // Test Validation
                Assert.IsNotNull(actualResult, "JsonResult returned is null");
                Assert.IsNotNull(actualResult.Data, "JsonResult Data returned is null");
                Assert.AreEqual(expectedResult.ToString(), actualResult.Data.ToString());
            }
        }
예제 #30
0
        public void ActivateServiceOrder_ESB_Throw_Exception_PerformSOA_false()
        {
            using (ShimsContext.Create())
            {
                //Arrange
                var myContext = new SIMPLTestContext();
                var message ="New Exception thrown";

                //Build FakeDto
                var fakeUserDto = myContext.GetFakeUserDtoObject();
                fakeUserDto.Email = "*****@*****.**";
                fakeUserDto.Name = "FakeUserName";
                fakeUserDto.Role = "FakeRole";

                //Fake call to CurrentUser.AsUserDto()
                ShimCurrentUser.AsUserDto = () => fakeUserDto;

                // Fake the HttpContext
                var context = new ShimHttpContext();
                ShimHttpContext.CurrentGet = () => context;

                // SIMPL.Session.Fakes.ShimCurrentSubscriber.SessionInstanceGet = () => new ShimCurrentSubscriber();

                // Fake the session state for HttpContext
                var session = new ShimHttpSessionState
                {
                    ItemGetString = s =>
                    {
                        if (s == "")
                            return null;
                        return null;
                    }
                };

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = (o) => session;

                var currentSubscriber = new ShimCurrentSubscriber
                {
                    SubIdGet = () => "77441",
                    DpiRegionGet = () => "FakeRegion"
                };

                ShimCurrentSubscriber.GetInstance = () => currentSubscriber;
                ShimEnterpriseClient.AllInstances.ActivateServiceOrderActivateServiceOrderRequestDtoHeaderArgs =
                    delegate
                    {
                        throw new Exception(message);
                    };

                // create phone controller instance
                var phoneController = DependencyResolver.Current.GetService<CVoipPhoneController>();

                ShimConfigurationManager.AppSettingsGet = () =>
                {
                    var nameValueCollection = new NameValueCollection
                    {
                        {"NewPerformSOAEnabled", "false"}
                    };

                    // nameValueCollection.Add("PerformSoaEnabled", "true");

                    return nameValueCollection;
                };

                var result = phoneController.ActivateServiceOrder("4252309331");

                // 1st Assert
                Assert.IsNotNull(result, "CVoipController ActivateServiceOrder operation returned null");

                var jsonResult = result as JsonResult;

                // 2nd Assert
                Assert.IsNotNull(jsonResult, "result is not JsonResult");

                // 3rd Assert
                Assert.IsNotNull(jsonResult.Data, "jsonResult.Data is null");

                // 4th Assert
                Assert.AreEqual("500", ((dynamic)jsonResult.Data).code, "Invalid status code returned from controller");

                // 5th Assert
                Assert.AreEqual(message, ((dynamic)jsonResult.Data).message, "Invalid status code returned from controller");
            }
        }