public void SubController_UpdateLocation_notUpdateCustomFields()
        {
            var sub = Data.Data.Simpltest1();
            var loc = sub.Accounts[0].Location;
            var expectedCustomFileds = Common.Data.DefaultCustomFields_Loc();
            loc.AddressLine1 += "UPDATED1";
            loc.CustomFields = Common.Data.DynamicCustomFields_Loc();
            var expected = Data.Data.LocDetailsViewModel(loc);

            const string message = "Successfully Updated Location";
            var expectedViewData = new ViewDataDictionary
            {
                new KeyValuePair<string, object>("message", message)
            };
            var result = _subscriberController.UpdateLocation(expected) as PartialViewResult;
            LocationDetailsViewModel actual = null;
            if (result != null)
            {
                Common.Validation.Validate("LocationDetails_Partial", result.ViewName, "ViewName");
                Validation.Validation.ValidateViewData(expectedViewData, result.ViewData);

                actual = result.Model as LocationDetailsViewModel;
            }
            Validation.Validation.ValidateLocationDetailsViewModel(expected, actual);

            //Validate Location updated and customfields not updated
            loc.CustomFields = null;

            using (var client = new RosettianClient())
            {
                if (actual != null)
            {
                    var actualLoc = client.LoadLocation(actual.ID, _user);
                    Common.Validation.ValidateLocation(loc, actualLoc);
                    Common.Validation.ValidateCustomFields(expectedCustomFileds, actualLoc.CustomFields);
                }
            }
        }
        public void SubController_UpdateLocation()
        {
            var sub = Data.Data.Simpltest1();
            var loc = sub.Accounts[0].Location;
            loc.AddressLine1 += "UPDATED1";
            loc.AddressLine2 += "UPDATED2";
            loc.CityName = "FORT WAYNE";
            loc.ZipCode = "46835";
            loc.HeadendCode = "01";
            var expected = Data.Data.LocDetailsViewModel(loc);

            const string message = "Successfully Updated Location";
            var expectedViewData = new ViewDataDictionary
            {
                new KeyValuePair<string, object>("message", message)
            };
            var result = _subscriberController.UpdateLocation(expected) as PartialViewResult;
            LocationDetailsViewModel actual = null;
            if (result != null)
            {
                Common.Validation.Validate("LocationDetails_Partial", result.ViewName, "ViewName");
                Validation.Validation.ValidateViewData(expectedViewData, result.ViewData);

                actual = result.Model as LocationDetailsViewModel;
            }
            Validation.Validation.ValidateLocationDetailsViewModel(expected, actual);

            using (var client = new RosettianClient())
            {
                if (actual != null)
            {
                    var actualLoc = client.LoadLocation(actual.ID, _user);
                    Common.Validation.ValidateLocation(loc, actualLoc);
                }
            }
        }
        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_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);
            }
        }
 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);
     }
 }
Пример #6
0
 private static Tuple<string, string, string> GetLocationRegion(string locationId)
 {
     LocationDto location;
     using (var client = new RosettianClient())
     {
          location = client.LoadLocation(locationId, new UserDto { Name = "SIMPL" });
     }
     var dpiRegion = GetDpiRegionFromStateAbbreviation(location.StateName);
     return new Tuple<string, string, string>(location.ID, location.StateName, dpiRegion);
 }