Beispiel #1
0
        /// <summary>
        /// GetFakeServiceAccountDto - return fake ServiceAccountDto object
        /// </summary>
        /// <returns></returns>
        public ServiceAccountDto GetFakeServiceAccountDto()
        {
            var fakeServiceAccountDto = new ServiceAccountDto
            {
                Address = new ServiceAddressDto { LocationId = "1" },
                IsBTN = true,
                SubscriberName = "King Copper",
                TN = "2068945100",
                USI = "89451",
                Services = new List<DAL.DataTransfer.Enterprise.ServiceDto>()
                {
                    new DAL.DataTransfer.Enterprise.ServiceDto(){ ServiceCode = "U-VERSE VOIP", ServiceDescription = "(FTRCFS) METASWITCH SIP"}
                }
            };

            return fakeServiceAccountDto;
        }
        //private string MapResponse(retrieveCustomerServiceConfigurationResponse1 esbResponse)
        //{
        //    try
        //    {
        //        return esbResponse.retrieveCustomerServiceConfigurationResponse.retrieveCustomerServiceConfigurationOutput.Payload.First()
        //            .ResourceFacingServices.First()
        //            .logicalResource.First()
        //            .LogicalResourceCharacteristicValues.First()
        //            .Value.value;
        //    }
        //    catch (System.Exception e)
        //    {
        //        throw new EnterpriseServiceException("Error mapping retrieveCustomerServiceConfiguration response - no IP found in the response.", e);
        //    }
        //}
        private BillingandServiceAccountDto MapResponse(retrieveCustomerAccountSummaryResponse1 esbResponse)
        {
            var customerAndServiceAccounts = new BillingandServiceAccountDto();

            if (esbResponse.retrieveCustomerAccountSummaryResponse.retrieveCustomerAccountSummaryOutput == null ||
                esbResponse.retrieveCustomerAccountSummaryResponse.retrieveCustomerAccountSummaryOutput.Payload == null ||
                !esbResponse.retrieveCustomerAccountSummaryResponse.retrieveCustomerAccountSummaryOutput.Payload.Any())
            {
                customerAndServiceAccounts.CustomerAccount = null;
                customerAndServiceAccounts.ServiceAccounts = null;
                return customerAndServiceAccounts;
            }

            // ReSharper disable once ForCanBeConvertedToForeach
            for (var index = 0;
                index < esbResponse.retrieveCustomerAccountSummaryResponse.retrieveCustomerAccountSummaryOutput.Payload.Length;
                index++)
            {
                var payload = esbResponse.retrieveCustomerAccountSummaryResponse.retrieveCustomerAccountSummaryOutput.Payload[index];

                var serviceAccount = new ServiceAccountDto();

                if (payload.accountType != null && payload.accountType == "Billing")
                {
                    serviceAccount.IsBTN = true;
                    customerAndServiceAccounts.CustomerAccount.Customer.CitizensPostalAddress.AddressTexts.Add(
                        new AddressTextDto()
                        {
                            Address = payload.AccountContact.ContactMedium.GeographicAddress.GeographicAddressExtension.AddressText[0].addressText ?? "No Data",
                            SequenceNumber = payload.AccountContact.ContactMedium.GeographicAddress.GeographicAddressExtension.AddressText[0].sequenceNumber
                        }
                     );

                    customerAndServiceAccounts.CustomerAccount.Customer.CitizensPostalAddress.Locality =
                        payload.AccountContact.ContactMedium.GeographicAddress.UrbanPropertyAddress.locality ?? "No Data";
                    customerAndServiceAccounts.CustomerAccount.Customer.CitizensPostalAddress.Postcode =
                        payload.AccountContact.ContactMedium.GeographicAddress.UrbanPropertyAddress.postcode ?? "No Data";
                    customerAndServiceAccounts.CustomerAccount.Customer.CitizensPostalAddress.StateOrProvince =
                        payload.AccountContact.ContactMedium.GeographicAddress.stateOrProvince ?? "No Data";
                    customerAndServiceAccounts.CustomerAccount.BillingAccountId.PhoneNumberAsId.TelephoneNumber.Number = payload.CustomerAccountExtension.AccountId.PhoneAsId.telephoneNumber;
                    customerAndServiceAccounts.CustomerAccount.BillingAccountId.UniversalServiceId = payload.CustomerAccountExtension.AccountId.universalServiceId;
                    customerAndServiceAccounts.CustomerAccount.Customer.ContactName = payload.CustomerAccountExtension.contactName;
                    customerAndServiceAccounts.CustomerAccount.Customer.EmailAddress =
                        payload.AccountContact.ContactMedium.eMailAddress;
                }

                serviceAccount.TN = payload.CustomerAccountExtension.AccountId.PhoneAsId.telephoneNumber;
                serviceAccount.USI = payload.CustomerAccountExtension.AccountId.universalServiceId;
                serviceAccount.SubscriberName = payload.CustomerAccountExtension.contactName;

                var serviceLocation = payload.CustomerAccountProductInvolvement.First().product.Services.First().ServiceLocation;
                serviceAccount.Address.LocationId = serviceLocation.ID;
                var geoAddress = serviceLocation.GeographicAddress;
                var urbanAddress = geoAddress.UrbanPropertyAddress;

                if (urbanAddress != null)
                {
                    var address1 = string.Empty;
                    const string space = " ";
                    if (!string.IsNullOrWhiteSpace(urbanAddress.streetNrFirst))
                    {
                        address1 += space + urbanAddress.streetNrFirst.Trim();
                    }
                    if (!string.IsNullOrWhiteSpace(urbanAddress.streetNrFirstSuffix))
                    {
                        address1 += space + urbanAddress.streetNrFirstSuffix.Trim();
                    }
                    if (!string.IsNullOrWhiteSpace(urbanAddress.streetName))
                    {
                        address1 += space + urbanAddress.streetName.Trim();
                    }

                    if (!string.IsNullOrWhiteSpace(urbanAddress.streetNrLast))
                    {
                        address1 += space + urbanAddress.streetNrLast.Trim();
                    }
                    if (!string.IsNullOrWhiteSpace(urbanAddress.streetNrLastSuffix))
                    {
                        address1 += space + urbanAddress.streetNrLastSuffix.Trim();
                    }
                    if (!string.IsNullOrWhiteSpace(urbanAddress.streetType))
                    {
                        address1 += space + urbanAddress.streetType.Trim();
                    }
                    serviceAccount.Address.Address1 = address1.Trim();

                    serviceAccount.Address.Locality = urbanAddress.locality != null
                        ? urbanAddress.locality.Trim()
                        : string.Empty;

                    serviceAccount.Address.Postcode = urbanAddress.postcode != null
                        ? urbanAddress.postcode.Trim()
                        : string.Empty;

                }

                if (urbanAddress != null && urbanAddress.UrbanPropertySubAddress != null)
                {
                    var address2 = string.Empty;
                    const string space = " ";
                    if (!string.IsNullOrWhiteSpace(urbanAddress.UrbanPropertySubAddress.subUnitType))
                    {
                        address2 += space + urbanAddress.UrbanPropertySubAddress.subUnitType.Trim();
                    }
                    if (!string.IsNullOrWhiteSpace(urbanAddress.UrbanPropertySubAddress.subUnitNr))
                    {
                        address2 += space + urbanAddress.UrbanPropertySubAddress.subUnitNr.Trim();
                    }
                    if (!string.IsNullOrWhiteSpace(urbanAddress.UrbanPropertySubAddress.levelType))
                    {
                        address2 += space + urbanAddress.UrbanPropertySubAddress.levelType.Trim();
                    }
                    if (!string.IsNullOrWhiteSpace(urbanAddress.UrbanPropertySubAddress.levelNr))
                    {
                        address2 += space + urbanAddress.UrbanPropertySubAddress.levelNr.Trim();
                    }
                    if (!string.IsNullOrWhiteSpace(urbanAddress.UrbanPropertySubAddress.buildingName))
                    {
                        address2 += space + urbanAddress.UrbanPropertySubAddress.buildingName.Trim();
                    }
                    serviceAccount.Address.Address2 = address2.Trim();
                }

                serviceAccount.Address.StateOrProvince = geoAddress.stateOrProvince != null
                    ? geoAddress.stateOrProvince.Trim()
                    : string.Empty;

                foreach (
                    var service in
                        payload.CustomerAccountProductInvolvement.SelectMany(capi => capi.product.Services))
                {
                    if (service.ResourceFacingServices != null && service.ResourceFacingServices.Any())
                    {
                        serviceAccount.Services.Add(
                            new ServiceDto
                            {
                                ServiceCode = service.ResourceFacingServices.First().ResourceFacingServiceId.ID,
                                ServiceDescription =
                                    service.ResourceFacingServices.First().ResourceFacingServiceId.description
                            });
                    }
                }

                customerAndServiceAccounts.ServiceAccounts.Add(serviceAccount);
            }

            return customerAndServiceAccounts;
        }
        public void Index_ProvisioningLocation_withAddresses_withRateCenter_withNetworkLocCode()
        {
            using (ShimsContext.Create())
            {
                // Fake the session state for HttpContext
                var session = new ShimHttpSessionState
                {
                    ItemGetString = s =>
                    {
                        if (s == "")
                            return null;
                        return null;
                    }
                };

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

                // When the Fake HttpContext is called, provide the fake session state
                ShimHttpContext.AllInstances.SessionGet = (o) => session;
                var customer = new CustomerDto();
                customer.CitizensPostalAddress.AddressTexts.Add(new AddressTextDto() { Address = "TestBillingAddress", SequenceNumber = 0 });
                var billingAccountId = new BillingAccountIdDto();
                billingAccountId.PhoneNumberAsId.TelephoneNumber.Number = "TestBillingNumber";
                ShimCurrentSubscriber.AllInstances.CurrentBillingAccountGet = (myTest) => new CustomerAccountDto()
                {

                    Customer = customer,
                    BillingAccountId = billingAccountId

                };

                // service account
                var serviceAccount = new ServiceAccountDto
                {
                    Address = new ServiceAddressDto{ Address1 = "TestServiceAddress"},
                    IsBTN = false,
                    SubscriberName = "TestServiceName",
                    TN = "TestServiceNumber",
                    USI = "TestServiceUSI",
                };
                ShimCurrentSubscriber.AllInstances.CurrentServiceAccountGet = (myTest) => serviceAccount;

                // Expected provisioning locaton
                var provLocation = new LocationDto
                {
                    ID = "12345666666444",
                    AddressLine1 = "ADDRESS1",
                    AddressLine2 = "ADDRESS2",
                    CityName = "CITY",
                    StateName = "STATE WA",
                    ZipCode = "12345",
                    HeadendCode = "01",
                    NetworkLocationCode = "1234567",
                    RateCenterName = "123456",
                };

                // CurrentSubscriber location
                ShimCurrentSubscriber.AllInstances.LocationIdGet = (myTestParam) => provLocation.ID;
                ShimCurrentSubscriber.AllInstances.AddressGet = (myTestParam) => provLocation.AddressLine1;
                ShimCurrentSubscriber.AllInstances.Address2Get = (myTestParam) => provLocation.AddressLine2;
                ShimCurrentSubscriber.AllInstances.CityGet = (myTestParam) => provLocation.CityName;
                ShimCurrentSubscriber.AllInstances.StateGet = (myTestParam) => provLocation.StateName;
                ShimCurrentSubscriber.AllInstances.ZipGet = (myTestParam) => provLocation.ZipCode;
                ShimCurrentSubscriber.AllInstances.HeadendCodeGet = (myTestParam) => provLocation.HeadendCode;
                ShimCurrentSubscriber.AllInstances.RateCenterGet = (myTestParam) => provLocation.RateCenterName;
                ShimCurrentSubscriber.AllInstances.NetworkLocationCodeGet =
                    (myTestParam) => provLocation.NetworkLocationCode;
                ShimCurrentSubscriber.AllInstances.SubIdGet = (myTestParam) => "TestSub";

                // account controller
                var accountsController = DependencyResolver.Current.GetService<AccountsController>();

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

                // results is no null
                Assert.IsNotNull(result);

                var accountTuple = (AccountTuple) result.Model;

                // validate billing info
                Assert.IsTrue(accountTuple.BillingAccount.Address.AddressLine1.Equals("TestBillingAddress"));
                Assert.IsTrue(accountTuple.BillingAccount.TN.Equals("TestBillingNumber"));

                // validate service address
                Assert.AreEqual(serviceAccount.Address.Address1, accountTuple.ServiceAccount.Addresses.ServiceAddress.AddressLine1, "Service Address1 does not match");
                Assert.IsTrue(accountTuple.ServiceAccount.TN.Equals("TestServiceNumber"));

                // validate provisioning location;
                var actualProvLocaton = accountTuple.ServiceAccount.Addresses.ProvisioningAddress.Location;
                Assert.AreEqual(provLocation.ID, actualProvLocaton.LocationID, "Location ID does not match");
                Assert.AreEqual(provLocation.AddressLine1, actualProvLocaton.Address1, "Address1 does not match");
                Assert.AreEqual(provLocation.AddressLine2, actualProvLocaton.Address2, "Address2 does not match");
                Assert.AreEqual(provLocation.HeadendCode, actualProvLocaton.Headend, "Headend does not match");
                Assert.AreEqual(provLocation.CityName, actualProvLocaton.City, "City does not match");
                Assert.AreEqual(provLocation.StateName, actualProvLocaton.State, "State does not match");
                Assert.AreEqual(provLocation.RateCenterName, actualProvLocaton.RateCenter, "RateCenter does not match");
                Assert.AreEqual(provLocation.NetworkLocationCode, actualProvLocaton.NetworkLocationCode, "NetworkLocationCode does not match");
            }
        }
        public void CVoipPhoneController_LoadPartialIndex_Successful()
        {
            using (ShimsContext.Create())
            {
                // Fake the session state for HttpContext
                var session = new ShimHttpSessionState
                {
                    ItemGetString = s =>
                    {
                        if (s == "")
                            return null;
                        return null;
                    }
                };

                //Arrange
                var myContext = new SIMPLTestContext();

                //Build FakeDto
                var fakeUserDto = myContext.GetFakeUserDtoObject();

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

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

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

                var serviceAccount = new ServiceAccountDto
                {
                    Address = new ServiceAddressDto
                    {
                        LocationId = "1"
                    },
                    IsBTN = true,
                    SubscriberName = "King Copper",
                    TN = "2068945100",
                    USI = "89451",
                    Services = new List<ServiceDto>()
                    {
                        new ServiceDto(){ ServiceCode = "U-VERSE VOIP", ServiceDescription = "(FTRCFS) METASWITCH SIP"}
                    }
                };

                var list = new List<ServiceAccountDto>();
                list.Add(serviceAccount);

                ShimCurrentSubscriber.AllInstances.PhoneServicesListGet = (o) => new List<ServiceAccountDto>()
                {
                    new ServiceAccountDto()
                    {
                        Address = new ServiceAddressDto() {LocationId = "1"},
                        USI = "89451",
                        TN = "2068945100",
                        Services = new List<ServiceDto>()
                        {
                            new ServiceDto()
                            {
                                ServiceCode = "U-VERSE VOIP",
                                ServiceDescription = "(FTRCFS) METASWITCH SIP"
                            }
                        }
                    }
                };

                ShimCurrentSubscriber.AllInstances.ServiceAccountListGet = (myTest) => list;
                ShimCurrentSubscriber.AllInstances.CurrentServiceAccountGet = (myTest) => new ServiceAccountDto
                {
                    Address = new ServiceAddressDto
                    {
                        LocationId = "1"
                    },
                    IsBTN = true,
                    SubscriberName = "King Copper",
                    TN = "2068945100",
                    USI = "89451"
                };

                ShimCurrentSubscriber.AllInstances.SubIdGet = (o) => "89451";

                var phoneList = new List<PhoneDto>()
                {
                    new PhoneDto()
                    {

                        PhoneNumber = "2068945100",
                        PhoneProvSpec =
                            new PhoneProvSpecDto()
                            {
                                LocalPIC = new PICDto(),
                                LongDistancePIC = new PICDto(),
                                DSLUnitAddress =
                                    new List<DSLUnitAddressDto>()
                                    {
                                        new DSLUnitAddressDto() {CLLICode = "ACME", HSIPort = "01-10-10"}
                                    },
                                PrimaryNumber = "2068945100",
                                Services =
                                    new ServiceCollectionDto()
                                    {
                                        new DAL.DataTransfer.Provisioning.ServiceDto()
                                        {
                                            ClassName = "U-VERSE VOIP",
                                            Description = "METASWITCH SIP",
                                            Name = "FTRCFS"
                                        }
                                    }
                            }
                    }
                };

                //fake the loaded phones
                ShimRosettianClient.AllInstances.LoadSubscriberPhonesStringUserDto = (client, s, arg3) => phoneList;

                ShimRosettianClient.AllInstances.UpdateSubscriberPhoneStringPhoneDtoUserDtoBoolean =
                    (client, subId, phoneSelect, userDto, myBool) => { return true; };

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

                // 1st Assert
                Assert.IsNotNull(result, "CVoipController Index returned null");
                Assert.IsTrue(result is PartialViewResult, "Not a PartialViewResult");

                // 2nd Assert
                var resultPartialViewResult = (PartialViewResult)result;

                // 3nd Assert
                Assert.IsNotNull(resultPartialViewResult, "Cast to PartialViewResult is null");
            }
        }