public void SaveNote_Happy_Path() { const string subscriberID = "KNOWNSUBSCRIBER"; const string locationID = "KNOWNLOCATIONID"; var savenoteFormCollection = new FormCollection(); savenoteFormCollection["note"] = "DOESNOTMATTER"; var CreateSubNoteCalled = false; using (ShimsContext.Create()) { var myContext = new SIMPLTestContext(); var fakeUserDto = myContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUserDto; ShimRosettianClient.AllInstances.CreateSubNoteStringNoteDtoUserDto = delegate { CreateSubNoteCalled = true; }; var testServiceHistoryController = new ServiceHistoryController(); var result = testServiceHistoryController.saveNote(savenoteFormCollection, subscriberID, locationID); Assert.IsNotNull(result, "Partial view result returned is null."); Assert.IsTrue(CreateSubNoteCalled, "RosettianClient.CreateSubNote was not called."); Assert.IsTrue(result != null, "The result from saveNote was not an ActionResult."); Assert.IsTrue(result is PartialViewResult, "The result from saveNote was not a PartialViewResult."); var saveNotePartialViewResult = result as PartialViewResult; Assert.AreEqual(saveNotePartialViewResult.ViewName, "ServiceHistoryDetails_Partial", "The result does not call the 'ServiceHistoryDetails_Partial' view"); Assert.IsTrue(saveNotePartialViewResult.Model is ServiceHistoryViewModel, "The result model form saveNote was not of type ServiceHistoryViewModel"); } }
public void GetNotes_Second_WTNUSI_USES_Associated_Triad_USI_to_get_Notes() { //Arrange var response = new ServiceHistoryCollectionDto(); const string subID = "SUBID"; const string expectedID = "PROVISIONEDID"; var passedUsi = string.Empty; using (ShimsContext.Create()) { SIMPLTestContext testContext = new SIMPLTestContext(); var fakeUser = testContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUser; ShimCurrentUser.GetInstance = () => new ShimCurrentUser { UniqueIdGet = () => "mjw425" }; var session = GetShimmedSession(); var context = new ShimHttpContext(); ShimHttpContext.CurrentGet = () => context; ShimHttpContext.AllInstances.SessionGet = (o) => session; ShimRosettianClient.AllInstances.GetServiceHistorySearchServiceHistoryDtoUserDto = (client, criteria, user) => { passedUsi = criteria.SubscriberId; return response; }; var dataSourcerequest = new DataSourceRequest() { Aggregates = new List<AggregateDescriptor>(), Filters = new List<IFilterDescriptor>(), Groups = new List<GroupDescriptor>(), Page = 1, PageSize = 0, Sorts = new List<SortDescriptor>() }; var fromDate = DateTime.Now.AddDays(-7).ToString(); var toDate = DateTime.Now.AddDays(7).ToString(); var defaultFilterAsJson = "{'NoteTypes':['Triad'],'IsCustomDate':true,'FromDateRange':'" + fromDate + "','ToDateRange':'" + toDate + "','SubscriberId':'" + subID + "','LocationId':'1319028645001', 'ProvisionedId': '"+expectedID+"'}"; //Act var result = NotesControllerForTest.GetNotes(dataSourcerequest, defaultFilterAsJson) as JsonResult; //Assert Assert.AreEqual(expectedID, passedUsi, string.Format("Did not used provisioned USI: {0}, Actual: {1}", expectedID, passedUsi));//change to expectedid } }
public void SendCommand_Receives_Generic_Error_Message() { const string errorMessage = "DOESNOTMATTER"; const string expectedMessage = "Error: Received an exception trying to perform the operation - please contact support"; const string serialNumber = "KNOWNSERIALNUMBER"; const string command = "Initialize"; string expectedJSON = "{ Code = 500, Message = " + expectedMessage + " }"; var performEquipmentOperationWasCalled = false; using (ShimsContext.Create()) { var myContext = new SIMPLTestContext(); var fakeUserDto = myContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUserDto; ShimRosettianClient.AllInstances.PerformEquipmentOperationListOfEquipmentOperationDtoUserDto = delegate { performEquipmentOperationWasCalled = true; throw new Exception(errorMessage); }; var testCleanAndScreenController = new CleanAndScreenController(new RosettianClient(), null); var result = testCleanAndScreenController.SendCommand(serialNumber, command); Assert.IsNotNull(result, "Send Command result is null"); Assert.IsTrue(performEquipmentOperationWasCalled, "PerformEquipmentOperation was not called"); Assert.IsTrue(result is JsonResult, "Result is not a JSON Result"); var testJsonResult = result as JsonResult; Assert.AreEqual(expectedJSON, testJsonResult.Data.ToString(), string.Format("Resulting JSON is incorrect: Actual-{0} Expected-{1}", testJsonResult.Data.ToString(), expectedJSON)); } }
public void SendCommand_Receives_ProvisioningError_From_Triad() { const string errorMessage = "\n Provisioning error: details follow\n , ErrorMessage: Terminal state operation, defined by the operation code of the state component, failed., Controller Code:2005, Name:DAC 11, Type:GI DAC 6000"; const string expectedMessage = "Provisioning error: details follow<br/>ErrorMessage: Terminal state operation, defined by the operation code of the state component, failed.<br />Controller Code:2005, Name:DAC 11, Type:GI DAC 6000"; const string serialNumber = "KNOWNSERIALNUMBER"; const string command = "Initialize"; string expectedJSON = "{ Code = 500, Message = "+ expectedMessage + " }"; var performEquipmentOperationWasCalled = false; using (ShimsContext.Create()) { var myContext = new SIMPLTestContext(); var fakeUserDto = myContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUserDto; ShimRosettianClient.AllInstances.PerformEquipmentOperationListOfEquipmentOperationDtoUserDto = delegate { performEquipmentOperationWasCalled = true; throw new Exception(errorMessage); }; var testCleanAndScreenController = new CleanAndScreenController(new RosettianClient(), null); var result = testCleanAndScreenController.SendCommand(serialNumber, command); Assert.IsNotNull(result, "Send Command result is null"); Assert.IsTrue(performEquipmentOperationWasCalled, "PerformEquipmentOperation was not called"); Assert.IsTrue(result is JsonResult, "Result is not a JSON Result"); var testJsonResult = result as JsonResult; Assert.AreEqual(expectedJSON, testJsonResult.Data.ToString(), string.Format("Resulting JSON is incorrect: Actual-{0} Expected-{1}", testJsonResult.Data.ToString(), expectedJSON)); } }
public void Upsell_submit_is_partially_successful() { using (ShimsContext.Create()) { #region Initial Setup SIMPLTestContext testContext = new SIMPLTestContext(); var session = GetShimmedSession(); var context = new ShimHttpContext(); ShimHttpContext.CurrentGet = () => context; ShimHttpContext.AllInstances.SessionGet = (o) => session; ShimCurrentSubscriber.GetInstance = () => new ShimCurrentSubscriber { DataProductTypeGet = () => SubscriberEnums.DataProductType.XDsl, VideoProductTypeGet = () => SubscriberEnums.VideoProductType.IpTv, StateGet = () => "CT", WtnGet = () => "2061272727", ProvisionedServicesListGet = () => new List<ServiceDto> { new ServiceDto { Action = "None", ClassName = "DATA - DSL SPEED", Description = "12 MBPS/1.5 MBPS", Name = "D12M1M", Type = ServiceClassTypeDto.None }, new ServiceDto { Action = "None", ClassName = "DSL - TECHNOLOGY CODE", Description = "HSIA SERVICES", Name = "VDSL", Type = ServiceClassTypeDto.None } } }; ShimUpsellRepository.AllInstances.GetUpsellProductClassesDefinitions = delegate { return new List<UpsellProductClassDefinitionDto>(); }; //Given a user //And user is authenticated to process Upsell submission var fakeUser = testContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUser; ShimCurrentUser.GetInstance = () => new ShimCurrentUser { UniqueIdGet = () => "mjw425" }; string upsellJsonData = "[{'ClassName':'DATA - DSL SPEED','Name':'D12M1M','Description':'12MBPS / 1.5MBPS'},{'ClassName':'DATA - DSL SPEED','Name':'D18M1M','Description':'18MBPS / 1.5MBPS'},{'ClassName':'F-SECURE','Name':'CANYW','Description':'Content Anywhere'},{'ClassName':'F-SECURE','Name':'DCPRO','Description':'Dropcam Pro'}]"; string autorizeBy = "Mark"; //No need to call Update subscriber hence shimming the method // bool isUpdateSubscriberCalled = false; ShimRosettianClient.AllInstances.UpdateSubscriberSubscriberDtoBooleanUserDto = delegate { return true; }; ShimCurrentSubscriber.UpdateSubscriberDto = delegate { }; //ShimMailHelper.AllInstances.Send = delegate { }; #endregion const int numOfProductsInTheReq = 2; //If num of products are even then half of them will fail. If num of products are odd then every even item in the req will fail. const int numOfProductsThatShouldFail = 1; //And all the required fields are captured for Upsell submission UpsellSubmittedOrder subReq = new UpsellSubmittedOrder { SimpleId = 2, SubscriberId = "490000608154", SubscriberName = "DWAYNE BROWN", TelephoneNumber = "9999999999", SubmittedBy = "mjw425", SubmissionDate = new DateTimeOffset(DateTime.Now).ToString(), StatusDescription = UpsellStatus.New.ToString(), AuthorizedBy = "Mark", AccountType = "R", }; List<UpsellSubmittedProduct> prodInReq = new List<UpsellSubmittedProduct>() { new UpsellSubmittedProduct() { ProductId = 1, ProductName = "D18M1M", ProductDescription = "18MBPS / 1.5MBPS", productAction = "A" }, new UpsellSubmittedProduct() { ProductId = 2, ProductName = "D12M1M", ProductDescription = "12MBPS / 1.5MBPS", productAction = "R" } }; //And submitting order to Offline Order System is enabled bool isFeatureFlagOn = false; ShimFeatureFlags.IsEnabledString = (o) => isFeatureFlagOn = true; //And failure occurs processing Offline Order Submission //When Order is submitted OfflineOrderSubmitResponse offlineSubmissionResponse = null; bool shouldFailTheSubmission = false; ShimOfflineOrderSystemClient.AllInstances.SubmitOrderToOfflineOrderSystemOfflineOrderSubmitRequest = delegate { if (isFeatureFlagOn) { // Since request going to be partially successful we need a way to control that. //The way control is acheived is by toggeling 'shouldFailTheSubmission' boolean if (shouldFailTheSubmission) { shouldFailTheSubmission = false; return offlineSubmissionResponse = new OfflineOrderSubmitResponse { //return dummy content. this will be different for each Content = "{'message': 'The request is invalid.','modelState': {'simple.simpleId': ['An error has occurred.','\'Simple Id\' should not be empty.']}}", IsSuccess = false, StatusCode = HttpStatusCode.BadRequest }; } else { shouldFailTheSubmission = true; //Then Upsell submission is successful return offlineSubmissionResponse = new OfflineOrderSubmitResponse { Content = "", IsSuccess = true, StatusCode = HttpStatusCode.Created }; } } return offlineSubmissionResponse; }; //Then Upsell Submission is saved outside Offline Order System ShimUpsellRepository.AllInstances.AddRecordUpsellSubmissionDtoIEnumerableOfUpsellProductChangeDto = delegate { //And all required fields are captured for Upsell submission return new UpsellAddRecordResult() { UpsellNewRecord = subReq, UpsellNewlyAddedProducts = prodInReq, }; }; //Shimming logging of product level failures bool didProductFailsLogged = false; int numOfProductFailed = 0; ShimUpsellRepository.AddOfflineProductFailuresInt32OfflineOrderSubmitResponse = delegate { didProductFailsLogged = true; numOfProductFailed++; //Keeping track of how many products failed to reach Offline Order System }; //Shimming the update status database call bool didRecordStatusUpdatedInSIML = false; UpsellStatus recStatus = UpsellStatus.Offline_Submission_Successful; ShimUpsellRepository.UpdateRecordStatusInt32UpsellStatus = delegate { if (numOfProductFailed == numOfProductsInTheReq) //Two since there are only two product in the data. { recStatus = UpsellStatus.Offline_Submission_Failed; } else if (numOfProductFailed < numOfProductsInTheReq) { recStatus = UpsellStatus.Offline_Submission_Partially_Successful; } return didRecordStatusUpdatedInSIML = true; }; //Shimming method that sends email bool isEmailSend = false; ShimEmailRepository.AllInstances.SendMail = delegate { return isEmailSend = true; }; //Action var result = UpsellControllerForTests.SubmitUpsell(upsellJsonData, autorizeBy) as PartialViewResult; //Was data returned? Assert.IsNotNull(result, "No result returned from UpdateUpsellRecord"); //And Upsell Offline Order Submission is unsuccessful //Assert.IsNotNull(offlineSubmissionResponse, "Offline submission response is null"); //Assert.IsFalse(offlineSubmissionResponse.IsSuccess, String.Format("Offline submission returned response: {0} and Status Code: {1}", offlineSubmissionResponse.IsSuccess, offlineSubmissionResponse.StatusCode)); //And record indicate that the submission to the Offline Order System was unsuccessful Assert.IsTrue(didRecordStatusUpdatedInSIML, "Record status was not updated in SIMPL. Set value: {0}", didRecordStatusUpdatedInSIML); Assert.AreEqual(recStatus, UpsellStatus.Offline_Submission_Partially_Successful, "Record status should be 'Partially Successful'.Instead it was updated to: {0}", recStatus); //And Upsell product failed to reach Offline Order System are saved Assert.IsTrue(didProductFailsLogged, "Adding product failures to db is not called."); Assert.AreEqual(numOfProductFailed, numOfProductsThatShouldFail, String.Format("Num of product logged are not same as the products in request. Failed Product: {0} and Products in req: {1}", numOfProductFailed, numOfProductsThatShouldFail)); //And email with failure details is send to Offline Order System Assert.IsTrue(isEmailSend, "No email is send."); } }
public void An_upsell_records_with_a_known_billing_order_number_and_complete_status_is_successfully_updated() { using (ShimsContext.Create()) { // Setup var myContext = new SIMPLTestContext(); var session = GetShimmedSession(); // Fake the HttpContext var context = new ShimHttpContext(); ShimHttpContext.CurrentGet = () => context; ShimHttpContext.AllInstances.SessionGet = (o) => session; // Given a user // And the user can resolve upsell records var fakeUserDto = myContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUserDto; ShimCurrentUser.GetInstance = () => new ShimCurrentUser { UniqueIdGet = () => "abc123" }; // And a known upsell record id const int upsellRecordId = 111111; // And a complete upsell status const int upsellStatus = (int)UpsellStatus.Complete; // And a known billing order number const string billingOrderNumber = "999999999"; //And a known billing region ShimBusinessFacade.AllInstances.GetDpiRegionFromStateNonStaticString = delegate { return "CT"; }; // And an known subscriber const string subscriberId = "KnownSubId"; //And the order number validation is turned on ShimFeatureFlags.IsEnabledString = delegate { return true; }; // When updating the upsell record var fakeAccountDto = myContext.GetFakeAccountDtoObject(); fakeAccountDto.Location = myContext.GetFakeLocationDtoObject("111111111"); var fakeCustomFieldDto = myContext.GetFakeCustomFieldDto(); var fakeSubscriberDto = myContext.GetFakeSubscriberDto(subscriberId, "TEST", "TEST", "555-555-1212", fakeCustomFieldDto, fakeAccountDto); var findOrderResponse = new retrieveCustomerAccountOrderDetailsResponse1 { retrieveCustomerAccountOrderDetailsResponse = new retrieveCustomerAccountOrderDetailsResponse { retrieveCustomerAccountOrderDetailsOutput = new msg_Customer { Payload = new[] { new Customer { CustomerAccount = new[] { new CustomerAccount { CustomerOrder = new[] { new CustomerOrder { CustomerOrderItem = new[] { new CustomerOrderItem() } } } } } } } } } }; ShimCustomerOrderInformationClient.AllInstances.SIMPLDALCustomerOrderInformationCustomerOrderInformationretrieveCustomerAccountOrderDetailsretrieveCustomerAccountOrderDetailsRequest = delegate { return findOrderResponse; }; ShimRosettianClient.AllInstances.LoadSubscriberStringUserDto = delegate { return fakeSubscriberDto; }; DAL.Implementation.Fakes.ShimUpsellRepository.AllInstances.UpdateRecordInt32Int32StringString = delegate { }; var result = UpsellControllerForTests.UpdateUpsellRecord(upsellRecordId, subscriberId, upsellStatus, billingOrderNumber) as HttpStatusCodeResult; //Was data returned Assert.IsNotNull(result, "No result returned from UpdateUpsellRecord"); // Then the record is updated // And the status indicates the update was successful Assert.IsNotNull(result, "Update Upsell Record returned null"); Assert.AreEqual(200, result.StatusCode, string.Format("The status code returned was not success. It was {0}", result.StatusCode)); } }
public void Upsell_Order_is_successfully_submitted_to_Offline_Order_System_with_required_fields() { using (ShimsContext.Create()) { #region Initial Setup SIMPLTestContext testContext = new SIMPLTestContext(); var session = GetShimmedSession(); var context = new ShimHttpContext(); ShimHttpContext.CurrentGet = () => context; ShimHttpContext.AllInstances.SessionGet = (o) => session; ShimCurrentSubscriber.GetInstance = () => new ShimCurrentSubscriber { DataProductTypeGet = () => SubscriberEnums.DataProductType.XDsl, VideoProductTypeGet = () => SubscriberEnums.VideoProductType.IpTv, StateGet = () => "CT", WtnGet = () => "2061272727", ProvisionedServicesListGet = () => new List<ServiceDto> { new ServiceDto { Action = "None", ClassName = "DATA - DSL SPEED", Description = "12 MBPS/1.5 MBPS", Name = "D12M1M", Type = ServiceClassTypeDto.None }, new ServiceDto { Action = "None", ClassName = "DSL - TECHNOLOGY CODE", Description = "HSIA SERVICES", Name = "VDSL", Type = ServiceClassTypeDto.None } } }; ShimUpsellRepository.AllInstances.GetUpsellProductClassesDefinitions = delegate { return new List<UpsellProductClassDefinitionDto>(); }; //Given a user //And user is authenticated to process Upsell submission var fakeUser = testContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUser; ShimCurrentUser.GetInstance = () => new ShimCurrentUser { UniqueIdGet = () => "mjw425" }; string upsellJsonData = "[{'ClassName':'DATA - DSL SPEED','Name':'D12M1M','Description':'12MBPS / 1.5MBPS'},{'ClassName':'DATA - DSL SPEED','Name':'D18M1M','Description':'18MBPS / 1.5MBPS'},{'ClassName':'F-SECURE','Name':'CANYW','Description':'Content Anywhere'},{'ClassName':'F-SECURE','Name':'DCPRO','Description':'Dropcam Pro'}]"; string autorizeBy = "Mark"; //No need to call Update subscriber hence shimming the method ShimRosettianClient.AllInstances.UpdateSubscriberSubscriberDtoBooleanUserDto = delegate { return true; }; ShimCurrentSubscriber.UpdateSubscriberDto = delegate { }; //ShimMailHelper.AllInstances.Send = delegate { }; #endregion // And all required fields are captured for Upsell submission UpsellSubmittedOrder subReq = new UpsellSubmittedOrder { SimpleId = 2, SubscriberId = "490000608154", SubscriberName = "DWAYNE BROWN", TelephoneNumber = "9999999999", SubmittedBy = "mjw425", SubmissionDate = new DateTimeOffset(DateTime.Now).ToString(), StatusDescription = UpsellStatus.New.ToString(), AuthorizedBy = "Mark", AccountType = "R", }; List<UpsellSubmittedProduct> prodInReq = new List<UpsellSubmittedProduct>() { new UpsellSubmittedProduct() { ProductId = 1, ProductName = "D18M1M", ProductDescription = "18MBPS / 1.5MBPS", productAction = "A" }, new UpsellSubmittedProduct() { ProductId = 2, ProductName = "D12M1M", ProductDescription = "12MBPS / 1.5MBPS", productAction = "R" } }; // And submitting order to Offline Order System is enabled ShimFeatureFlags.IsEnabledString = (o) => true; // When Upsell submission is send to Offline Order System //Shimming method which sends request to Offline Order System OfflineOrderSubmitResponse offlineSubmissionResponse = null; bool isSubmitToOfflineCalled = false; ShimOfflineOrderSystemClient.AllInstances.SubmitOrderToOfflineOrderSystemOfflineOrderSubmitRequest = delegate { isSubmitToOfflineCalled = true; //Then Upsell submission is successful offlineSubmissionResponse = new OfflineOrderSubmitResponse { Content = "", IsSuccess = true, StatusCode = HttpStatusCode.Created }; return offlineSubmissionResponse; }; //Shimming method which save the upsell order in SIMPL - Satisfy saving submit outside Offline Order Sytem bool isRecordSavedInSIMPL = false; UpsellAddRecordResult addedRecord = null; ShimUpsellRepository.AllInstances.AddRecordUpsellSubmissionDtoIEnumerableOfUpsellProductChangeDto = delegate { isRecordSavedInSIMPL = true; //And all required fields are captured for Upsell submission addedRecord = new UpsellAddRecordResult() { UpsellNewRecord = subReq, UpsellNewlyAddedProducts = prodInReq, }; return addedRecord; }; //Shimming the databse update which changes the status of the record bool didRecordStatusUpdatedInSIML = false; ShimUpsellRepository.UpdateRecordStatusInt32UpsellStatus = delegate { return didRecordStatusUpdatedInSIML = true; }; //Action var result = UpsellControllerForTests.SubmitUpsell(upsellJsonData, autorizeBy) as PartialViewResult; //Was data returned? Assert.IsNotNull(result, "No result returned from UpdateUpsellRecord"); // And Upsell Submission is saved outside Offline Order System Assert.IsTrue(isRecordSavedInSIMPL, "Order is not saved in SIMPL"); Assert.IsNotNull(addedRecord,"Record added in SIMPL is Null"); // Then Upsell submission is successful // And successful response is returned by Offline Order System Assert.IsTrue(isSubmitToOfflineCalled,"Offline Service was not called"); Assert.IsNotNull(offlineSubmissionResponse,"The offline response is null"); Assert.IsTrue(offlineSubmissionResponse.IsSuccess, String.Format("Upsell submission is not successful. The returned response is: {0}", offlineSubmissionResponse.IsSuccess)); Assert.AreEqual(offlineSubmissionResponse.StatusCode, HttpStatusCode.Created, string.Format("Invalid code the recieved from the service call. Expected: {0}, Recieved: {1}", HttpStatusCode.Created, offlineSubmissionResponse.StatusCode)); // And record indicates that the submission to the Offline Order System was successful Assert.IsTrue(didRecordStatusUpdatedInSIML, "Record status is not updated, which indicates usccessful submission to Offline Order System"); } }
public void The_upsell_pricing_link_is_correctly_displayed_for_a_customer_with_a_known_state() { using (ShimsContext.Create()) { // Setup ShimUpsellRepository.AllInstances.GetUpsellServiceClassesByPlatformTypeInt32Int32 = delegate { return new List<string>(); }; ShimUpsellRepository.AllInstances.GetCustomUpsellProductsInt32Int32 = delegate { return new List<UpsellProductDto>(); }; SIMPL.DAL.Rosettian.Fakes.ShimServices.ProvisioningServicesGet = delegate { return new List<ServiceDto>(); }; ShimUpsellModel.AllInstances.SetCurrentProductsDictionary = delegate { return new SortedDictionary<string, List<ServiceDto>>(); }; ShimUpsellModel.AllInstances.SetAvailableProductsDictionary = delegate { return new SortedDictionary<string, SortedList<string, ServiceDto>>(); }; SIMPL.DAL.Rosettian.Fakes.ShimData.ValidCityStateZipsGet = () => new List<LocationDto>() { new LocationDto() { StateName = "CT" } }; var myContext = new SIMPLTestContext(); var session = GetShimmedSession(); // Fake the HttpContext var context = new ShimHttpContext(); ShimHttpContext.CurrentGet = () => context; ShimHttpContext.AllInstances.SessionGet = (o) => session; // Given a user var fakeUserDto = myContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUserDto; ShimCurrentUser.GetInstance = () => new ShimCurrentUser { UniqueIdGet = () => "abc123", }; //And a known subscriber //And the subscriber has a known state ShimCurrentSubscriber.GetInstance = () => new ShimCurrentSubscriber { DataProductTypeGet = () => SubscriberEnums.DataProductType.XDsl, VideoProductTypeGet = () => SubscriberEnums.VideoProductType.IpTv, StateGet = () => "CT" }; var result = UpsellControllerForTests.LoadUpsellContent() as PartialViewResult; //Then the upsell submission window is returned Assert.IsNotNull(result, "The response from the LoadUpsellContent was null"); //Then the upsell submission window is returned Assert.IsNotNull(result, "The response from the LoadUpsellContent was null"); // And the upsell link is returned // And the upsell link is correctly formed var upsellModel = result.Model as UpsellModel; //Does the UpsellModel exiat Assert.IsNotNull(upsellModel); //Is the UpsellModel set to show pricing? Assert.IsTrue(upsellModel.ShouldShowUpsellPricing, "ShouldShowUpsellPricing should have a value of true."); //If the UpsellModel is supposed to show pricing, does it? Assert.IsNotNull(upsellModel.UpsellPricingLink, "Upsell Pricing Link was null."); //Is the UpsellPricing URL the expected one var expectedUrl = string.Format("{0}/CT", ConfigurationManager.AppSettings["UpsellPricingURL"]); //TODO: The UpsellPricingLink is making a web call so the test is an integration test, not a unit test. //TODO: We need to either move the test to the integration test or fake the web call in the method. See Visual Studio team issue 24452 var upsellPricingLink = upsellModel.UpsellPricingLink; Assert.AreEqual(expectedUrl, upsellPricingLink, string.Format("Upsell Pricing Link should be {0}. It was {1}", expectedUrl, upsellPricingLink)); } }
public void When_a_user_updates_an_upsell_record_with_a_unknown_subscriberid_an_error_is_received() { using (ShimsContext.Create()) { // Setup var myContext = new SIMPLTestContext(); var session = GetShimmedSession(); // Fake the HttpContext var context = new ShimHttpContext(); ShimHttpContext.CurrentGet = () => context; ShimHttpContext.AllInstances.SessionGet = (o) => session; // Given a user // And the user can resolve upsell records var fakeUserDto = myContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUserDto; ShimCurrentUser.GetInstance = () => new ShimCurrentUser { UniqueIdGet = () => "abc123" }; // And a known upsell record id const int upsellRecordId = 111111; // And a complete upsell status const int upsellStatus = (int)UpsellStatus.Complete; // And a known billing order number var billingOrderNumber = "021348548"; //And a known billing region ShimBusinessFacade.AllInstances.GetDpiRegionFromStateNonStaticString = delegate { return "CT"; }; // And an unknown subscriber const string subscriberId = "UnknownSubId"; //And the order number validation is turned on ShimFeatureFlags.IsEnabledString = delegate { return true; }; // When updating the upsell record ShimRosettianClient.AllInstances.LoadSubscriberStringUserDto = delegate { throw new System.Exception("Subscriber not found");}; DAL.Implementation.Fakes.ShimUpsellRepository.AllInstances.UpdateRecordInt32Int32StringString = delegate { }; var result = UpsellControllerForTests.UpdateUpsellRecord(upsellRecordId, subscriberId, upsellStatus, billingOrderNumber) as HttpStatusCodeResult; //Was data returned? Assert.IsNotNull(result, "No result returned from UpdateUpsellRecord"); // Then the record is not updated Assert.IsNotNull(result, "Update Upsell Record returned null"); Assert.IsNotNull(result.StatusDescription, "No Error Message was found in the response."); // And an error is received Assert.AreEqual(500, result.StatusCode, "An error status code was not returned to the user"); // And the error states that the upsell record needs to contain a known subscriber const string expectedErrorMessage = "There was an issue retrieving subscriber information from Triad. Please verify this subscriber id exists."; Assert.IsTrue(result.StatusDescription.Contains(expectedErrorMessage), string.Format("The error message received was {0}, it should have been {1}", result.StatusDescription, expectedErrorMessage)); } }
public void When_a_user_updates_an_upsell_record_with_a_missing_subscriberid_an_error_is_received() { using (ShimsContext.Create()) { // Setup var myContext = new SIMPLTestContext(); var session = GetShimmedSession(); // Fake the HttpContext var context = new ShimHttpContext(); ShimHttpContext.CurrentGet = () => context; ShimHttpContext.AllInstances.SessionGet = (o) => session; // Given a user // And the user can resolve upsell records var fakeUserDto = myContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUserDto; ShimCurrentUser.GetInstance = () => new ShimCurrentUser { UniqueIdGet = () => "abc123" }; // And a known upsell record id const int upsellRecordId = 111111; // And a complete upsell status const int upsellStatus = (int)UpsellStatus.Complete; // And a empty billing order number var billingOrderNumber = string.Empty; //And a known billing region ShimBusinessFacade.AllInstances.GetDpiRegionFromStateNonStaticString = delegate { return "CT"; }; // And a missing subscriber var subscriberId = string.Empty; //And the order number validation is turned on ShimFeatureFlags.IsEnabledString = delegate { return true; }; // When updating the upsell record var fakeAccountDto = myContext.GetFakeAccountDtoObject(); fakeAccountDto.Location = myContext.GetFakeLocationDtoObject("111111111"); var fakeCustomFieldDto = myContext.GetFakeCustomFieldDto(); var fakeSubscriberDto = myContext.GetFakeSubscriberDto(subscriberId, "TEST", "TEST", "555-555-1212", fakeCustomFieldDto, fakeAccountDto); ShimRosettianClient.AllInstances.LoadSubscriberStringUserDto = delegate { return fakeSubscriberDto; }; DAL.Implementation.Fakes.ShimUpsellRepository.AllInstances.UpdateRecordInt32Int32StringString = delegate { }; var result = UpsellControllerForTests.UpdateUpsellRecord(upsellRecordId, subscriberId, upsellStatus, billingOrderNumber) as HttpStatusCodeResult; // Then the record is not updated Assert.IsNotNull(result, "Update Upsell Record returned null"); Assert.IsNotNull(result.StatusDescription, "No Error Message was found in the response."); // And an error is received Assert.AreEqual(500, result.StatusCode, "An error status code was not returned to the user"); // And the error states that a billing order number is required when updating an upsell record const string expectedErrorMessage = "SubscriberId is required to update upsell record."; Assert.IsTrue(result.StatusDescription.Contains(expectedErrorMessage), string.Format("The error message received was {0}, it should have been {1}", result.StatusDescription, expectedErrorMessage)); } }
public void When_a_user_updates_an_upsell_record_with_a_malformed_billing_order_number_an_error_is_received() { using (ShimsContext.Create()) { // Setup SIMPLTestContext myContext = new SIMPLTestContext(); var session = GetShimmedSession(); // Fake the HttpContext var context = new ShimHttpContext(); ShimHttpContext.CurrentGet = () => context; ShimHttpContext.AllInstances.SessionGet = (o) => session; // Given a user // And the user can resolve upsell records var fakeUserDto = myContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUserDto; ShimCurrentUser.GetInstance = () => new ShimCurrentUser { UniqueIdGet = () => "abc123" }; // And a known upsell record id const int upsellRecordId = 111111; // And a complete upsell status const int upsellStatus = (int)UpsellStatus.Complete; // And a malformed billing order number var billingOrderNumber = Convert.ToString(TestContext.DataRow["billingOrderNumber"]); //And a known billing region ShimBusinessFacade.AllInstances.GetDpiRegionFromStateNonStaticString = delegate { return "CT"; }; // And a known subscriber const string subscriberId = "KnownSubId"; //And the order number validation is turned on ShimFeatureFlags.IsEnabledString = delegate { return true; }; // When updating the upsell record var currentSubscriber = new ShimCurrentSubscriber(); var fakeAccountDto = myContext.GetFakeAccountDtoObject(); fakeAccountDto.Location = myContext.GetFakeLocationDtoObject("111111111"); var fakeCustomFieldDto = myContext.GetFakeCustomFieldDto(); var fakeSubscriberDto = myContext.GetFakeSubscriberDto(subscriberId, "TEST", "TEST", "555-555-1212", fakeCustomFieldDto, fakeAccountDto); var findOrderResponse = new retrieveCustomerAccountOrderDetailsResponse1() { retrieveCustomerAccountOrderDetailsResponse = new retrieveCustomerAccountOrderDetailsResponse() { retrieveCustomerAccountOrderDetailsOutput = new msg_Customer() { Header = new Header { HeaderExtension = new HeaderExtension { ExecutionStatusMessage = new ExecutionStatusMessage() } }, Payload = new[] { new Customer() } } } }; ShimCustomerOrderInformationClient.AllInstances.SIMPLDALCustomerOrderInformationCustomerOrderInformationretrieveCustomerAccountOrderDetailsretrieveCustomerAccountOrderDetailsRequest = delegate { return findOrderResponse; }; ShimRosettianClient.AllInstances.LoadSubscriberStringUserDto = delegate { return fakeSubscriberDto; }; SIMPL.DAL.Implementation.Fakes.ShimUpsellRepository.AllInstances.UpdateRecordInt32Int32StringString = delegate { }; var result = UpsellControllerForTests.UpdateUpsellRecord(upsellRecordId, subscriberId, upsellStatus, billingOrderNumber) as HttpStatusCodeResult; // Then the record is not updated Assert.IsNotNull(result, "Update Upsell Record returned null"); Assert.IsNotNull(result.StatusDescription, "No Error Message was found in the response."); // And an error is received Assert.AreEqual(500, result.StatusCode, "An error status code was not returned to the user."); // And the error says Please enter a valid Billing Order Number. Billing Order Numbers are 9 digits or less. const string expectedErrorMessage = "Please enter a valid Billing Order Number. Billing Order Numbers are 9 digits or less."; Assert.IsTrue(result.StatusDescription.Contains(expectedErrorMessage), string.Format("The error message for billing order number {0} received was {1}, it should have been {2}", billingOrderNumber, result.StatusDescription, expectedErrorMessage)); } }
public void Unable_To_Retrieve_Notes_From_InetPortal_As_Wtn_Or_Btn_Does_Not_Exists() { using (ShimsContext.Create()) { #region Initialize SIMPLTestContext testContext = new SIMPLTestContext(); var session = GetShimmedSession(); var context = new ShimHttpContext(); ShimHttpContext.CurrentGet = () => context; ShimHttpContext.AllInstances.SessionGet = (o) => session; ShimCurrentSubscriber.GetInstance = () => new ShimCurrentSubscriber { DataProductTypeGet = () => SubscriberEnums.DataProductType.XDsl, VideoProductTypeGet = () => SubscriberEnums.VideoProductType.IpTv, StateGet = () => "CT", WtnGet = () => string.Empty, // mocking the condition where telephone number does not exists DpiRegionGet = () => "MS", ProvisionedServicesListGet = () => new List<ServiceDto> { new ServiceDto { Action = "None", ClassName = "DATA - DSL SPEED", Description = "12 MBPS/1.5 MBPS", Name = "D12M1M", Type = ServiceClassTypeDto.None, }, new ServiceDto { Action = "None", ClassName = "DSL - TECHNOLOGY CODE", Description = "HSIA SERVICES", Name = "VDSL", Type = ServiceClassTypeDto.None } } }; //Given a user //And user is authenticated to process Upsell submission var fakeUser = testContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUser; ShimCurrentUser.GetInstance = () => new ShimCurrentUser { UniqueIdGet = () => "mjw425" }; //Shim datasource request going from kendo grid var dataSourcerequest = new DataSourceRequest() { Aggregates = new List<AggregateDescriptor>(), Filters = new List<IFilterDescriptor>(), Groups = new List<GroupDescriptor>(), Page = 1, PageSize = 0, Sorts = new List<SortDescriptor>() }; var currentDate = DateTime.Now; var fromDate = currentDate.AddDays(-7).ToString(); var toDate = currentDate.AddDays(7).ToString(); var defaultFilterAsJson = "{'NoteTypes':['INET'],'IsCustomDate':true,'FromDateRange':'" + fromDate + "','ToDateRange':'" + toDate + "','SubscriberId':'130000990344','LocationId':'1319028645001'}"; #endregion #region Shimming service call and returning account notes response var responseFromService = new List<AccountNotes>(); //fake the call to the service and return the account notes ShimISPServiceClient.AllInstances.GetNotesStringStringStringUser = delegate { return responseFromService; }; #endregion var result = NotesControllerForTest.GetNotes(dataSourcerequest, defaultFilterAsJson) as JsonResult; //check to see if we got results back Assert.IsNotNull(result, "Did not get any notes from INet Portal"); var notes = (List<NotesViewModel>)(result.Data as DataSourceResult ?? new DataSourceResult()).Data; //validate that we received the notes data Assert.AreEqual(notes.Count, 0, string.Format("The returned notes data does not match. Expected notes count: {0}, Actual notes count: {1})", notes.Count, responseFromService.Count)); } }
public void Unable_To_Retrieve_Memos_From_DPI_As_WTN_Or_BTN_Does_Not_Exists() { using (ShimsContext.Create()) { #region Initialize SIMPLTestContext testContext = new SIMPLTestContext(); var session = GetShimmedSession(); var context = new ShimHttpContext(); ShimHttpContext.CurrentGet = () => context; ShimHttpContext.AllInstances.SessionGet = (o) => session; ShimCurrentSubscriber.GetInstance = () => new ShimCurrentSubscriber { DataProductTypeGet = () => SubscriberEnums.DataProductType.XDsl, VideoProductTypeGet = () => SubscriberEnums.VideoProductType.IpTv, StateGet = () => "CT", WtnGet = () => string.Empty, // NOT A VALID TELEPHONE NUMBER DpiRegionGet = () => "LR", ProvisionedServicesListGet = () => new List<ServiceDto> { new ServiceDto { Action = "None", ClassName = "DATA - DSL SPEED", Description = "12 MBPS/1.5 MBPS", Name = "D12M1M", Type = ServiceClassTypeDto.None, }, new ServiceDto { Action = "None", ClassName = "DSL - TECHNOLOGY CODE", Description = "HSIA SERVICES", Name = "VDSL", Type = ServiceClassTypeDto.None } } }; //Given a user //And user is authenticated to process Upsell submission var fakeUser = testContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUser; ShimCurrentUser.GetInstance = () => new ShimCurrentUser { UniqueIdGet = () => "mjw425" }; //Shim datasource request going from kendo grid var dataSourcerequest = new DataSourceRequest() { Aggregates = new List<AggregateDescriptor>(), Filters = new List<IFilterDescriptor>(), Groups = new List<GroupDescriptor>(), Page = 1, PageSize = 0, Sorts = new List<SortDescriptor>() }; //To change selected date range, modify the code here. var fromDate = DateTime.Now.AddDays(-7).ToString(); var toDate = DateTime.Now.AddDays(7).ToString(); var defaultFilterAsJson = "{'NoteTypes':['DPI'],'IsCustomDate':true,'FromDateRange':'" + fromDate + "','ToDateRange':'" + toDate + "','SubscriberId':'130000990344','LocationId':'1319028645001'}"; #endregion var result = NotesControllerForTest.GetNotes(dataSourcerequest, defaultFilterAsJson) as JsonResult; //was data returned? Assert.IsNotNull(result, "Resultset contains no memos/notes"); var notes = (List<NotesViewModel>)(result.Data as DataSourceResult ?? new DataSourceResult()).Data; Assert.IsNotNull(notes, "No data returned"); //Then no memos are fetched //And grid display is blank Assert.AreEqual(0, notes.Count, string.Format("DPI retured notes. Expected: 0, Actual: {0}", notes.Count)); } }
public void SIMPL_Successfully_Displays_Memos_From_DPI() { using (ShimsContext.Create()) { #region Initialize SIMPLTestContext testContext = new SIMPLTestContext(); var session = GetShimmedSession(); var context = new ShimHttpContext(); ShimHttpContext.CurrentGet = () => context; ShimHttpContext.AllInstances.SessionGet = (o) => session; ShimCurrentSubscriber.GetInstance = () => new ShimCurrentSubscriber { DataProductTypeGet = () => SubscriberEnums.DataProductType.XDsl, VideoProductTypeGet = () => SubscriberEnums.VideoProductType.IpTv, StateGet = () => "CT", WtnGet = () => "5852659033", DpiRegionGet = () => "LR", ProvisionedServicesListGet = () => new List<ServiceDto> { new ServiceDto { Action = "None", ClassName = "DATA - DSL SPEED", Description = "12 MBPS/1.5 MBPS", Name = "D12M1M", Type = ServiceClassTypeDto.None, }, new ServiceDto { Action = "None", ClassName = "DSL - TECHNOLOGY CODE", Description = "HSIA SERVICES", Name = "VDSL", Type = ServiceClassTypeDto.None } } }; //Given a user //And user is authenticated to process Upsell submission var fakeUser = testContext.GetFakeUserDtoObject(); ShimCurrentUser.AsUserDto = () => fakeUser; ShimCurrentUser.GetInstance = () => new ShimCurrentUser { UniqueIdGet = () => "mjw425" }; //Shim datasource request going from kendo grid var dataSourcerequest = new DataSourceRequest() { Aggregates = new List<AggregateDescriptor>(), Filters = new List<IFilterDescriptor>(), Groups = new List<GroupDescriptor>(), Page = 1, PageSize = 0, Sorts = new List<SortDescriptor>() }; var fromDate = DateTime.Now.AddDays(-7).ToString(); var toDate = DateTime.Now.AddDays(7).ToString(); var defaultFilterAsJson = "{'NoteTypes':['DPI'],'IsCustomDate':true,'FromDateRange':'" + fromDate + "','ToDateRange':'" + toDate + "','SubscriberId':'130000990344','LocationId':'1319028645001'}"; #endregion //shim the expected esb response from the service. #region ESB Response var createdDate = DateTime.Now; var response = new retrieveCustomerAccountMemosResponse1() { retrieveCustomerAccountMemosResponse = new retrieveCustomerAccountMemosResponse() { retrieveCustomerAccountMemosOutput = new msg_Memo() { Payload = new Memo[] { new Memo() { templateName = "RSSOS", templateDescription = "ROCHESTER SPECIAL SVS ORDER", type = "BasicMemo", RawText = new RawText[] { new RawText() { textLine = "20081209 61825 Add RSSOS memos for Access Lines per Scrub C.24358" } }, createdBy = "CONVER", createdDate = createdDate }, new Memo() { templateName = "RSSOS", templateDescription = "ROCHESTER SPECIAL SVS ORDER", type = "BasicMemo", RawText = new RawText[] { new RawText() { textLine = "SERVICE ORDER#: 002371328" } }, createdBy = "CONVER", createdDate = createdDate }, new Memo() { templateName = "RSSOS", templateDescription = "ROCHESTER SPECIAL SVS ORDER", type = "BasicMemo", RawText = new RawText[] { new RawText() { textLine = "SO: CD/002371326 2/17/2014 IssBy: 77777 SldBy: 0" } }, createdBy = "CONVER", createdDate = createdDate } } } } }; #endregion //Shim call to the service ShimCustomerInformationInquiryClient.AllInstances .SIMPLDALCustomerInformationInquiryCustomerInformationInquiryretrieveCustomerAccountMemosretrieveCustomerAccountMemosRequest = delegate { return response; }; var result = NotesControllerForTest.GetNotes(dataSourcerequest, defaultFilterAsJson) as JsonResult; //was data returned? Assert.IsNotNull(result, "Resultset contains no memos/notes"); var notes = (List<NotesViewModel>)(result.Data as DataSourceResult ?? new DataSourceResult()).Data; //validate the proper conversion Assert.IsNotNull(notes, "No notes data after conversion"); //Then the Memos are fetched from the DPI System Assert.AreEqual(notes.Count, response.retrieveCustomerAccountMemosResponse.retrieveCustomerAccountMemosOutput.Payload.Length, string.Format("The returned notes data does not match. Expected notes count: {0}, Actual notes count: {1})", notes.Count, response.retrieveCustomerAccountMemosResponse.retrieveCustomerAccountMemosOutput.Payload.Length)); //just get the single note obj for following asserts var singleNote = notes[0]; //And date and time of the memos is displayed Assert.AreNotEqual(string.Empty, singleNote.DateTime.ToString(), string.Format("No datetime was retured from the DPI. Actual: {0}", singleNote.DateTime.ToString())); //And user who entered the memos is displayed Assert.AreNotEqual(string.Empty, singleNote.User, string.Format("No User was retured from the DPI. Actual: {0}", singleNote.User)); //And source column displays DPI indicating the source of the memos Assert.AreEqual("DPI", singleNote.Source, string.Format("Source column does not match.Expected:'DPI', Actual: {0}", singleNote.Source)); //And description of the memos is displayed in Notes column Assert.AreNotEqual(string.Empty, singleNote.Notes, string.Format("No notes desciption is available.Retured notes description: {0}", singleNote.Notes)); } }