/// <summary> /// GetFakeBillingAccountIdDto - returns fake BillingAccountIdDto object /// </summary> /// <param name="subscriberID"></param> /// <param name="fakePhoneNumberAsIdDto"></param> /// <returns></returns> public BillingAccountIdDto GetFakeBillingAccountIdDto(string subscriberID, PhoneNumberAsIdDto fakePhoneNumberAsIdDto) { var fakeBillingAccountIdDto = new BillingAccountIdDto() { UniversalServiceId = subscriberID, PhoneNumberAsId = fakePhoneNumberAsIdDto }; return fakeBillingAccountIdDto; }
/// <summary> /// GetFakeCustomerAccountDto - returns fake CustomerAccountDto object /// </summary> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="subscriberID"></param> /// <param name="fakeBillingAccountIdDto"></param> /// <param name="fakeCustomerAccountIdDto"></param> /// <returns></returns> public CustomerAccountDto GetFakeCustomerAccountDto(string firstName, string lastName, string subscriberID, BillingAccountIdDto fakeBillingAccountIdDto, CustomerAccountIdDto fakeCustomerAccountIdDto) { var fakeIndividualName = new IndividualNameDto() { GivenNames = firstName, FamilyNames = lastName }; var fakeIndividualDto = new IndividualDto() { IndividualName = fakeIndividualName }; var fakeCustomerDto = new CustomerDto() { Individual = fakeIndividualDto }; var fakeCustomerAccountDto = new CustomerAccountDto() { AccountID = subscriberID, BillingAccountId = fakeBillingAccountIdDto, CustomerAccountId = fakeCustomerAccountIdDto, Customer = fakeCustomerDto }; return fakeCustomerAccountDto; }
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 Index_HappyPath() { 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 }; ShimCurrentSubscriber.AllInstances.CurrentServiceAccountGet = (myTest) => new ServiceAccountDto { Address = new ServiceAddressDto{ Address1 = "TestServiceAddress"}, IsBTN = false, SubscriberName = "TestServiceName", TN = "TestServiceNumber", USI = "TestServiceUSI" }; ShimCurrentSubscriber.AllInstances.LocationIdGet = (myTestParam) => "123456789"; ShimCurrentSubscriber.AllInstances.AddressGet = (myTestParam) => "TestAddressLine1"; ShimCurrentSubscriber.AllInstances.Address2Get= (myTestParam) => "TestAddressLine2"; ShimCurrentSubscriber.AllInstances.CityGet= (myTestParam) => "TestCity"; ShimCurrentSubscriber.AllInstances.StateGet = (myTestParam) => "TestState"; ShimCurrentSubscriber.AllInstances.ZipGet = (myTestParam) => "TestZip"; ShimCurrentSubscriber.AllInstances.HeadendCodeGet = (myTestParam) => "TestHeadend"; ShimCurrentSubscriber.AllInstances.RateCenterGet= (myTestParam) => "TestRateCenter"; ShimCurrentSubscriber.AllInstances.NetworkLocationCodeGet = (myTestParam) => "TestNetworkCode"; ShimCurrentSubscriber.AllInstances.SubIdGet = (myTestParam) => "TestSub"; ShimCurrentSubscriber.AllInstances.SubIdGet = (myTestParam) => "TestSub"; var accountsController = DependencyResolver.Current.GetService<AccountsController>(); var result = accountsController.Index(); Assert.IsTrue(((AccountTuple)result.Model).BillingAccount.Address.AddressLine1.Equals("TestBillingAddress")); Assert.IsTrue(((AccountTuple)result.Model).BillingAccount.TN.Equals("TestBillingNumber")); Assert.IsTrue(((AccountTuple)result.Model).ServiceAccount.Addresses.ServiceAddress.AddressLine1.Equals("TestServiceAddress")); Assert.IsTrue(((AccountTuple)result.Model).ServiceAccount.TN.Equals("TestServiceNumber")); } }
public void Index_HasAddressConflict_True() { 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(); ShimCurrentSubscriber.AllInstances.CurrentBillingAccountGet = (myTest) => new CustomerAccountDto() { Customer = customer, BillingAccountId = billingAccountId }; const string subId = "123456789"; const string headend = "04"; const string locId = "123456789"; var address1 = "2345 TEST ADDRESS1"; var address2 = "APT 2"; var city = "REDMOND"; var state = "WA"; var zip = "98052"; // Service Address ShimCurrentSubscriber.AllInstances.CurrentServiceAccountGet = (myTest) => new ServiceAccountDto { Address = new ServiceAddressDto { Address1 = address1, Address2 = address2, Locality = city, StateOrProvince = state, Postcode = zip }, }; // Provisioning Service Address ShimCurrentSubscriber.AllInstances.HeadendCodeGet = (myTestParam) => headend; ShimCurrentSubscriber.AllInstances.LocationIdGet = (myTestParam) => locId; ShimCurrentSubscriber.AllInstances.SubIdGet = (myTestParam) => subId; ShimCurrentSubscriber.AllInstances.AddressGet = (myTestParam) => address1 + " DIFFERENT"; ShimCurrentSubscriber.AllInstances.Address2Get = (myTestParam) => address2 + " DIFFERENT"; ShimCurrentSubscriber.AllInstances.CityGet = (myTestParam) => city + " DIFFERENT"; ShimCurrentSubscriber.AllInstances.StateGet = (myTestParam) => state + " DIFFERENT"; ShimCurrentSubscriber.AllInstances.ZipGet = (myTestParam) => zip + " DIFFERENT"; ShimCurrentSubscriber.AllInstances.RateCenterGet = (myTestParam) => "TestRateCenter"; ShimCurrentSubscriber.AllInstances.NetworkLocationCodeGet = (myTestParam) => "TestNetworkCode"; var accountsController = DependencyResolver.Current.GetService<AccountsController>(); var result = accountsController.Index(); Assert.IsNotNull(result); // Validate the HasAddressConflict flag var hasAddressConflict = ((AccountTuple) result.Model).ServiceAccount.Addresses.ProvisioningAddress.Location.HasAddressConflict; Assert.IsTrue(hasAddressConflict, "HasAddressConflict should be false"); } }