public static void AddPhoneToSubscriberAccount(string subID, PhoneDto phone) { try { using (var client = new RosettianClient()) { client.CreateSubscriberPhone(subID, phone, CurrentUser.AsUserDto()); } } catch (FaultException<ValidationFault> vx) { throw new Exception(vx.Detail.Details[0].Message, vx); } catch (Exception ex) { throw new Exception(Errors.parseXMLError(ex.Message), ex); } }
public void UpdatePhone_PhoneProvisionedOnSubscriber_ValidateUserAbleToUpdateSubscriberPhone() { using (ShimsContext.Create()) { // Given a user that has permission to updater subscriber phone ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject(); // And a valid subscriber id const string subId = "mysubid"; ShimCurrentSubscriber.AllInstances.SubIdGet = o => subId; ShimCurrentSubscriber.GetInstance = () => new ShimCurrentSubscriber(); // And the subscriber has a valid location id const string locId = "mylocid"; ShimCurrentSubscriber.AllInstances.LocationIdGet = o => locId; // And the subscriber has a valid provisioned equipment var expectedEquipment = PhoneTestData_Ont(subId, locId); Assert.IsTrue(expectedEquipment.Any(x => x.SerialNumber.EndsWith("P01"))); ShimRosettianClient.AllInstances.SearchEquipmentSearchFieldsDtoUserDto = (myTestClient, mySearchCritiera, myUserDto) => expectedEquipment; // And the equipment is fiber equipment ShimCurrentSubscriber.AllInstances.VoiceProductTypeGet = o => SubscriberEnums.VoiceProductType.FiberPots; ShimCurrentSubscriber.AllInstances.DataProductTypeGet = o => SubscriberEnums.DataProductType.Ftth; ShimCurrentSubscriber.AllInstances.VideoProductTypeGet = o => SubscriberEnums.VideoProductType.FiberRf; // And the subscriber has a provisioned phone var phone = new PhoneDto { PhoneNumber = "4250010001", PhoneProvSpec = new PhoneProvSpecDto { CRV = 123, InterfaceGroup = 1, } }; // And the user edited subscriber phone with new crv, new interface group, and assigned the equipment voice port to the phone const int newCrv = 321; const int newInterfaceGroup = 99; var newEquipId = expectedEquipment.First(x => x.SerialNumber.EndsWith("P01")).SerialNumber; var expectedPhoneAfterUpdate = new PhoneDto { PhoneNumber = phone.PhoneNumber, PhoneProvSpec = new PhoneProvSpecDto { CRV = newCrv, InterfaceGroup = newInterfaceGroup, EquipmentId = newEquipId } }; ShimRosettianClient.AllInstances.LoadSubscriberPhonesStringUserDto = (myTestClient, mySubId, myUserDto) => new List<PhoneDto> { expectedPhoneAfterUpdate }; // When updating the subscriber phone with the changed values ShimRosettianClient.AllInstances.UpdateSubscriberPhoneStringPhoneDtoUserDtoBoolean = (myTestClient, mysubId, myPhoneDto, myUserDto, overwriteSerive) => true; var actionResult = PhoneControllerForTests.UpdatePhone(subId, locId, phone.PhoneNumber, phone.PhoneNumber, newCrv, newInterfaceGroup, newEquipId) as PartialViewResult; // Then the user receives a response Assert.IsNotNull(actionResult, "UpdatePhone returned null"); // And the response is successful Assert.AreEqual("PhoneList_Partial", actionResult.ViewName, "ViewName does not match"); Assert.IsTrue(actionResult.ViewData.ContainsKey("error") && actionResult.ViewData["error"].ToString() == "Successfully updated phone information"); var actualModel = actionResult.Model as PhoneViewModel; Assert.IsNotNull(actualModel, "Model is null"); // And the subscriber matches the requested subscriber Assert.AreEqual(subId, actualModel.SubscriberID, "SubscriberID does not match"); // And the location matches the requested location Assert.AreEqual(locId, actualModel.LocationID, "LocationID does not match"); // And the ont voice ports matches the requested equipment var jss = new JavaScriptSerializer(); var expectedVoicePorts = expectedEquipment.Where(x => x.Type.Category == EquipmentCategoryDto.ONTVoicePort); Assert.AreEqual(jss.Serialize(expectedVoicePorts), jss.Serialize(actualModel.PhonePorts)); // And the subscriber phone is updated Assert.IsTrue(actualModel.PhoneList != null && actualModel.PhoneList.Count == 1, "PhoneList is empty"); Assert.AreEqual(jss.Serialize(expectedPhoneAfterUpdate), jss.Serialize(actualModel.PhoneList[0])); } }
public void SaveAddPhone_ValidateUserAbleToAddNewPhoneOnSubscriber() { using (ShimsContext.Create()) { // Given a user that has permission to add new subscriber phone ShimCurrentUser.AsUserDto = () => new SIMPLTestContext().GetFakeUserDtoObject(); // And a valid subscriber id const string subId = "mysubid"; // And the subscriber has a valid location id const string locId = "mylocid"; // And the subscriber has a valid provisioned equipment var expectedEquipment = PhoneTestData_Ont(subId, locId); Assert.IsTrue(expectedEquipment.Any(x => x.SerialNumber.EndsWith("P01"))); ShimRosettianClient.AllInstances.SearchEquipmentSearchFieldsDtoUserDto = (myTestClient, mySearchCritiera, myUserDto) => expectedEquipment; // And a new provisioned phone and assign the equipment voice port to it var newPhone = new PhoneDto { PhoneNumber = "4250010001", PhoneProvSpec = new PhoneProvSpecDto { CRV = 11, InterfaceGroup = 1, EquipmentId = expectedEquipment.First(x => x.SerialNumber.EndsWith("P01")).SerialNumber } }; // When creating new provisioning phone for the subscriber ShimRosettianClient.AllInstances.CreateSubscriberPhoneStringPhoneDtoUserDto = (myTestClient, mysubId, myPhoneDto, myUserDto) => true; ShimRosettianClient.AllInstances.LoadSubscriberPhonesStringUserDto = (myTestClient, mySubId, myUserDto) => new List<PhoneDto> { newPhone }; var actionResult = PhoneControllerForTests.SaveAddPhone(subId, locId, newPhone.PhoneNumber, newPhone.PhoneProvSpec.CRV, newPhone.PhoneProvSpec.InterfaceGroup, newPhone.PhoneProvSpec.EquipmentId) as PartialViewResult; // Then the user receives a response Assert.IsNotNull(actionResult, "SaveAddPhone returned null"); // And the response is successful Assert.AreEqual("PhoneList_Partial", actionResult.ViewName, "ViewName does not match"); Assert.IsFalse(actionResult.ViewData.ContainsKey("error"), actionResult.ViewData.ContainsKey("error") ? "Error: " + actionResult.ViewData["error"].ToString() : string.Empty); var actualModel = actionResult.Model as PhoneViewModel; Assert.IsNotNull(actualModel, "Model is null"); // And the subscriber matches the requested subscriber Assert.AreEqual(subId, actualModel.SubscriberID, "SubscriberID does not match"); // And the location matches the requested location Assert.AreEqual(locId, actualModel.LocationID, "LocationID does not match"); // And the ont voice ports matches the requested equipment var jss = new JavaScriptSerializer(); var expectedVoicePorts = expectedEquipment.Where(x => x.Type.Category == EquipmentCategoryDto.ONTVoicePort); Assert.AreEqual(jss.Serialize(expectedVoicePorts), jss.Serialize(actualModel.PhonePorts)); // And the new provisioning phone is created on subscriber Assert.IsTrue(actualModel.PhoneList != null && actualModel.PhoneList.Count == 1, "PhoneList is empty"); Assert.AreEqual(jss.Serialize(newPhone), jss.Serialize(actualModel.PhoneList[0])); } }
//TODO: Dynamically generate Service code based on what's cached from Triad public static PhoneDto RestorePhonetoSubscriber(string subId, string phoneNumber) { DeletePhoneFromSubscriberAccount(subId, phoneNumber); var phone = new PhoneDto() { PhoneNumber = phoneNumber, PhoneProvSpec = new PhoneProvSpecDto() { CIDLocalName = "TEST", InterfaceGroup = 2, CRV = 120, Services = new ServiceCollectionDto() { new ServiceDto() { ClassName = "VOICE - VOIP", Name = "CVCWN", Description = "CALL WAITING ID/NAME" }, new ServiceDto() { ClassName = "VOICE - VOIP", Name = "CVRVM", Description = "RESIDENTIAL VM" } } } }; AddPhoneToSubscriberAccount(subId, phone); return LoadExistingSubscriberPhones(subId).FirstOrDefault(ph => ph.PhoneNumber == phoneNumber); }
public void UpdatePhone_Action_HappyPath() { // Arrange SubscriberDto sub = null; try { sub = SIMPL.Test.IntegrationTest.Data.Data.GetSIMPLSubscriber03(); } catch (Exception ex) { Assert.Fail("Exception thrown when calling \"SIMPL.Test.IntegrationTest.Data.Data.GetSIMPLSubscriber03\" method.{0}{0}Message: {1}{0}{0}{2}", Environment.NewLine, ex.Message, ex.StackTrace); } var id = sub.ID; var locid = sub.Accounts[0].Location.ID; var oldNumber = "3001000100"; var newNumber = "3001000339"; //must be unique var CRV = 1234; var intGroup = 1; var equipId = "MRCC30010011P03"; //This was NOT set in GetSIMPLSubscriber03 var phone = new PhoneDto { PhoneNumber = newNumber, PhoneProvSpec = new PhoneProvSpecDto { CRV = CRV, InterfaceGroup = intGroup } }; SIMPL.Test.IntegrationTest.Data.Data.AddPhoneToSubscriberAccount(sub.ID, phone); // Act var result = PhoneControllerForTests.UpdatePhone(id, locid, oldNumber, newNumber, CRV, intGroup, equipId) as PartialViewResult; // Assert Assert.IsNotNull(result, "SaveAddPhone_Action_HappyPath - result was null"); Assert.AreEqual("PhoneList_Partial", result.ViewName, "SaveAddPhone_Action_HappyPath - Unexpected partial"); Assert.IsTrue(result.ViewData.ContainsKey("error"), "Error, the error value was not set" ); Assert.AreEqual("Successfully updated phone information", result.ViewData["error"], "Did not receive success message"); }
/// <summary> /// ValidatePhone method - takes PhoneDto objects /// </summary> /// <param name="expected"></param> /// <param name="actual"></param> public static void ValidatePhone(PhoneDto expected, PhoneDto actual) { if (expected == null) { return; } if (expected.PhoneNumber != null) { Validate(expected.PhoneNumber, actual.PhoneNumber, TestAttribute.Phone); } if (expected.PhoneProvSpec != null) { ValidatePhoneProvSpec(expected.PhoneProvSpec, actual.PhoneProvSpec); } }