/// <summary>
 /// This method loads a Subscriber account object from Rosettian.
 /// Deliberately not catching exception - caller will be responsible for handling exceptions thrown
 /// </summary>
 /// <returns>SubscriberDto object</returns>
 public SubscriberDto LoadSubscriber(string subscriberID)
 {
     using (var client = new RosettianClient())
     {
         return client.LoadSubscriber(subscriberID, CurrentUser.AsUserDto());
     }
 }
Exemple #2
0
 /// <summary>
 /// Load subscriber specified by USI subID and convert to model instance.
 /// Load is performed twice as an easy means for creating a reference clone
 /// to use in comparing or restoring original state.
 /// Assumption: subscriber being loaded is reserved for a specific test.
 /// </summary>
 /// <param name="subID">USI for subscriber to load</param>
 /// <param name="referenceSub">deep clone of subscriber</param>
 /// <returns>subscriber identified by subID as MVC model</returns>
 public static SubscriberModel GetTestSubModel(string subID, out SubscriberDto referenceSub)
 {
     referenceSub = null;
     try
     {
         using (var client = new RosettianClient())
         {
             var user = CurrentUser.AsUserDto();
             referenceSub = client.LoadSubscriber(subID, user);
             Assert.IsNotNull(referenceSub, "GetTestSubModel() - USI {0} not found.", subID);
             // Create deep copy "clone" (with unique instances) by loading again.
             var rozSub = client.LoadSubscriber(subID, user);
             return rozSub.MapToSubscriberModel();
         }
     }
     catch (Exception)
     {
         return new SubscriberModel();
     }
 }
        public void AddServicesTest()
        {
            using (var client = new RosettianClient())
            {
                // initialize
                MyTestInitialize();

                // get test subscriber
                var testSubscriber = IntegrationTest.Data.Data.GetSIMPLSubscriber04CPE01();

                // create existing service list
                string existingServiceClassName = ServiceClassType.ProvisionedOntDataPort.GetStringValue();
                const string existingServiceName = "ENET";
                const string existingServiceDescription = "RJ-45 ETHERNET PORT";
                var existingService = new ServiceDto
                {
                    ClassName = existingServiceClassName,
                    Name = existingServiceName,
                    Description = existingServiceDescription
                };
                var existingServicesList = new List<ServiceDto> {existingService};

                // set current subscriber
                testSubscriber.Accounts.First().Services = existingServicesList.ToCollection();
                CurrentSubscriber.SetInstance(testSubscriber);

                // create service to add
                const string serviceToAddClassName = "DATA - FTTH SPEED";
                const string serviceToAddName = "F50M20M";
                const string serviceToAddDescription = "50M DOWN 20M UP";
                var serviceToAdd = new ServiceDto
                {
                    ClassName = serviceToAddClassName,
                    Name = serviceToAddName,
                    Description = serviceToAddDescription
                };
                var serviceToAddAsJSON = "[" + new JavaScriptSerializer().Serialize(serviceToAdd) + "]";

                // create expected service list (includes existing service and service to add)
                var expectedServicesListAfterAdd = new List<ServiceDto> {existingService, serviceToAdd};

                // create controller reference
                var servicesController = DependencyResolver.Current.GetService<ServicesController>();

                // ACT
                var actualJsonResult = servicesController.AddServices(serviceToAddAsJSON) as JsonResult;

                // ASSERT
                Assert.IsNotNull(actualJsonResult);
                Assert.IsInstanceOfType(actualJsonResult, typeof (JsonResult));

                // Verify the returned JSON
                dynamic actualJson = actualJsonResult.Data;
                var status = actualJson.status as string;
                Assert.IsNotNull(status);
                if (status == "error")
                {
                    var exceptionMessage = actualJson.errorMessage;

                    // Failure in action method -- report exception
                    Assert.Fail("Add Service test - unexpected JsonResult values, code = {0}\r\nmessage = {1}", status, exceptionMessage);
                }
                Assert.AreEqual("success", status, "Add Service test - unexpected status from update operation");

                // load updated subscriber
                var updatedSubscriber = client.LoadSubscriber(testSubscriber.ID, CurrentUser.AsUserDto());

                // verify the services list
                Assert.IsTrue(updatedSubscriber.Accounts.First().Services.SequenceEqual(expectedServicesListAfterAdd, new ServiceComparer()));
            }
        }
        public void SubController_UpdateSubscriber_noChange4Services()
        {
            var sub = Data.Data.Simpltest1();
            sub.Name = string.Format("{0} updated", sub.Name);
            sub.SubContactEmail = string.Format("{0}.org", sub.SubContactEmail);
            sub.SubContactPhone = "3001000103";
            sub.Accounts[0].PIN = "4321";
            sub.Accounts[0].PinRequired = false;
            sub.Accounts[0].PPVCap = "300.00";
            sub.Accounts[0].PPVPrivilege = "1";
            sub.Accounts[0].PPVResetDay = "10";
            sub.Accounts[0].ServiceEnabled = false;
            var expected = Data.Data.SubDetailsViewModel(sub);

            var result = _subscriberController.UpdateSubscriber(expected) as PartialViewResult;
            SubscriberDetailsViewModel actual = null;
            if (result != null)
            {
                Common.Validation.Validate("SubscriberDetails_Partial", result.ViewName, "ViewName");

                actual = result.Model as SubscriberDetailsViewModel;
            }
            Validation.Validation.ValidateSubscriberDetailsViewModel(expected, actual);

            using (var client = new RosettianClient())
            {
                var actualSub = client.LoadSubscriber(sub.ID, _user);
                Common.Validation.ValidateSubscriber(sub, actualSub, true);
            }
        }
Exemple #5
0
 public static SubscriberDto GetTestSub(string subID)
 {
     try
     {
         using (var client = new RosettianClient())
         {
             return client.LoadSubscriber(subID, CurrentUser.AsUserDto());
         }
     }
     catch (Exception)
     {
         return new SubscriberDto();
     }
 }
        public void SubController_SubmitChangeLocation()
        {
            var sub = Data.Data.Simpltest1();
            var loc = sub.Accounts[0].Location;
            var newLoc = Data.Data.Simplloc1();
            //var expected = Data.Data.LocDetailsViewModel(newLoc);

            var result = _subscriberController.SubmitChangeLocation(loc.ID, newLoc.ID, sub.ID) as RedirectToRouteResult;

            //Validate action result
            var expectedRoute = new RouteValueDictionary
            {
                {"ID", newLoc.ID},
                {"message", "Location Changed Successfully"},
                {"action", "Location"},
                {"controller", "Subscriber"}
            };
            if (result != null)
            {
                var actualRoute = result.RouteValues;
                Common.Validation.Validate(expectedRoute.ToDictionary(x => x.Key, x => x.Value.ToString()), actualRoute.ToDictionary(x => x.Key, x => x.Value.ToString()), "RouteValueDictionary");
            }

            //Validate Location changed
            using (var client = new RosettianClient())
            {
                var actualSub = client.LoadSubscriber(sub.ID, _user);
                client.LoadLocation(actualSub.Accounts[0].Location.ID, _user);
                Common.Validation.ValidateLocation(newLoc, actualSub.Accounts[0].Location);
            }
        }
        public void SubController_saveCustomFieldsSubscriber()
        {
            var sub = Data.Data.Simpltest1();
            sub.CustomFields = new List<CustomField>
            {
                new CustomField{Label ="Service_ID", Value="1234"},
                new CustomField{Label = "PCAN", Value="F123456789"},
                new CustomField{Label = "IP_TYPE", Value="DYNAMIC"},
                new CustomField{Label = "Sub_WTN", Value="1234567890"},
            };
            var expected = Data.Data.SubDetailsViewModel(sub);

            var collection = new FormCollection
                {
                    {"Service_ID", "1234"},
                    {"PCAN", "F123456789"},
                    {"Sub_WTN", "1234567890"},
                    {"IP_TYPE", "DYNAMIC"}
                };

            var result = _subscriberController.saveCustomFieldsSubscriber(collection, sub.ID) as PartialViewResult;
            SubscriberDetailsViewModel actual = null;
            if (result != null)
            {
                Common.Validation.Validate("subscriberCustomFields_Partial", result.ViewName, "ViewName");

                actual = result.Model as SubscriberDetailsViewModel;
            }
            Validation.Validation.ValidateSubscriberDetailsViewModel(expected, actual);

            using (var client = new RosettianClient())
            {
                var actualSub = client.LoadSubscriber(sub.ID, _user);
                Common.Validation.ValidateSubscriber(sub, actualSub, true);
            }
        }
        public void SubController_saveCustomFieldsLocation()
        {
            var sub = Data.Data.Simpltest1();
            var loc = sub.Accounts[0].Location;
            loc.CustomFields = new List<CustomField>
            {
                new CustomField{Label="DROP_TYPE",Value="BURIED"},
                new CustomField{Label="ADDRESS_ID",Value="12345678"}
            };

            var collection = new FormCollection { { "DROP_TYPE", "BURIED" }, { "ADDRESS_ID", "12345678" } };

            var result = _subscriberController.saveCustomFieldsLocation(collection, loc.ID) as PartialViewResult;
            LocationDetailsViewModel actual = null;
            if (result != null)
            {
                Common.Validation.Validate("locationCustomFields_Partial", result.ViewName, "ViewName");

                actual = result.Model as LocationDetailsViewModel;
            }
            if (actual != null)
            {
            Assert.AreEqual(loc.ID, actual.ID, "LocationID");
                Common.Validation.ValidateCustomFields(loc.CustomFields, actual.CustomField);
            }

            using (var client = new RosettianClient())
            {
                var actualSub = client.LoadSubscriber(sub.ID, _user);
                var actualLoc = client.LoadLocation(actualSub.Accounts[0].Location.ID, _user);
                Common.Validation.ValidateLocation(loc, actualLoc);
            }
        }
        public void SubController_ClearLocation()
        {
            var sub = Data.Data.Simpltest1();
            //var expected = Data.Data.LocDetailsViewModel(new Location());

            var result = _subscriberController.ClearLocation(sub.ID) as RedirectToRouteResult;

            //Validate action result
            var expectedRoute = new RouteValueDictionary
            {
                {"ID", sub.ID},
                {"message", "Location Cleared Successfully"},
                {"action", "Index"},
                {"controller", "Subscriber"}
            };
            if (result != null)
            {
                var actualRoute = result.RouteValues;
                Common.Validation.Validate(expectedRoute.ToDictionary(x => x.Key, x => x.Value.ToString()), actualRoute.ToDictionary(x => x.Key, x => x.Value.ToString()), "RouteValueDictionary");
            }

            using (var client = new RosettianClient())
            {
                var actualSub = client.LoadSubscriber(sub.ID, _user);
                var actualLoc = actualSub.Accounts[0].Location;
                Assert.IsTrue(string.IsNullOrEmpty(actualLoc.ID), actualLoc.ID);
            }
        }
 private static void ValidateLocationNotUpdated(Subscriber expected)
 {
     using (var client = new RosettianClient())
     {
         var actualSub = client.LoadSubscriber(expected.ID, _user);
         Common.Validation.Validate(expected.ID, actualSub.ID, "Subscriber");
         var actualLoc = client.LoadLocation(actualSub.Accounts[0].Location.ID, _user);
         Common.Validation.ValidateLocation(expected.Accounts[0].Location, actualLoc);
     }
 }