Exemplo n.º 1
0
        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));
            }
        }
Exemplo n.º 2
0
        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));

            }
        }
Exemplo n.º 3
0
        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));
            }
        }