public void ParameterWithNullValueAndValueNameIsInvalid()
        {
            string valueName = "HSAS";
            string value = null;
            var parameter = new Parameter(valueName, value);

            var parameterValidator = new ParameterValidator(parameter);
            Assert.False(parameterValidator.IsValid);
        }
        public void ParameterWithValueAndValueNameIsValid()
        {
            string valueName = "HSAS";
            string value = "00512";
            var parameter = new Parameter(valueName, value);

            var parameterValidator = new ParameterValidator(parameter);
            Assert.True(parameterValidator.IsValid);
        }
Example #3
0
        public override System.Collections.Specialized.NameValueCollection GetParameters()
        {
            NameValueCollection nvc = base.GetParameters();

            if (RequiresApiToken)
            {
                if (!String.IsNullOrEmpty(GetApiToken()))
                {
                    nvc.Add("token", GetApiToken());
                }
            }

            if (RequiresServiceId)
            {
                if (!String.IsNullOrEmpty(GetServiceId()))
                {
                    nvc.Add("serviceId", GetServiceId());
                }
            }

            ParameterValidator.IsNotNull(Amount, "Amount");
            nvc.Add("amount", Amount.ToString());

            ParameterValidator.IsNotNull(BankAccountHolder, "BankAccountHolder");
            nvc.Add("bankAccountHolder", BankAccountHolder);

            ParameterValidator.IsNotNull(BankAccountNumber, "BankAccountNumber");
            nvc.Add("bankAccountNumber", BankAccountNumber);

            ParameterValidator.IsNotNull(BankAccountBic, "BankAccountBic");
            nvc.Add("bankAccountBic", BankAccountBic);

            if (!ParameterValidator.IsEmpty(Description))
            {
                nvc.Add("description", Description);
            }

            if (!ParameterValidator.IsNonEmptyInt(PromotorId))
            {
                nvc.Add("promotorId", PromotorId.Value.ToString());
            }

            if (!ParameterValidator.IsEmpty(Tool))
            {
                nvc.Add("tool", Tool);
            }

            if (!ParameterValidator.IsEmpty(Info))
            {
                nvc.Add("info", Info);
            }

            if (!ParameterValidator.IsEmpty(Object))
            {
                nvc.Add("object", Object);
            }

            if (!ParameterValidator.IsEmpty(Extra1))
            {
                nvc.Add("extra1", Extra1);
            }
            if (!ParameterValidator.IsEmpty(Extra2))
            {
                nvc.Add("extra2", Extra2);
            }
            if (!ParameterValidator.IsEmpty(Extra3))
            {
                nvc.Add("extra3", Extra3);
            }

            if (!ParameterValidator.IsEmpty(Currency))
            {
                nvc.Add("currency", Currency);
            }

            if (this.ProcessDate.HasValue)
            {
                nvc.Add("processDate", this.ProcessDate.Value.ToString("yyyy-MM-dd"));
            }

            return(nvc);
        }
Example #4
0
 public void ValidateObject_ParameterNotNull_OK()
 {
     ParameterValidator.ValidateObject("d", "data");
 }
Example #5
0
        /// <inheritdoc />
        public override NameValueCollection GetParameters()
        {
            var nvc = new NameValueCollection();

            ParameterValidator.IsNotNull(AmountInCents, "Amount");
            nvc.Add("amount", AmountInCents.ToString());

            ParameterValidator.IsNotNull(BankAccountHolder, "BankAccountHolder");
            nvc.Add("bankAccountHolder", BankAccountHolder);

            ParameterValidator.IsNotNull(BankAccountNumber, "BankAccountNumber");
            nvc.Add("bankAccountNumber", BankAccountNumber);

            ParameterValidator.IsNotNull(BankAccountBic, "BankAccountBic");
            nvc.Add("bankAccountBic", BankAccountBic);

            if (!ParameterValidator.IsEmpty(Description))
            {
                nvc.Add("description", Description);
            }

            if (PromotorId.HasValue)
            {
                nvc.Add("promotorId", PromotorId.Value.ToString());
            }

            if (!ParameterValidator.IsEmpty(Tool))
            {
                nvc.Add("tool", Tool);
            }

            if (!ParameterValidator.IsEmpty(Info))
            {
                nvc.Add("info", Info);
            }

            if (!ParameterValidator.IsEmpty(Object))
            {
                nvc.Add("object", Object);
            }

            if (!ParameterValidator.IsEmpty(Extra1))
            {
                nvc.Add("extra1", Extra1);
            }
            if (!ParameterValidator.IsEmpty(Extra2))
            {
                nvc.Add("extra2", Extra2);
            }
            if (!ParameterValidator.IsEmpty(Extra3))
            {
                nvc.Add("extra3", Extra3);
            }

            if (!ParameterValidator.IsEmpty(Currency))
            {
                nvc.Add("currency", Currency);
            }

            if (ProcessDate.HasValue)
            {
                nvc.Add("processDate", ProcessDate.Value.ToString("yyyy-MM-dd"));
            }

            return(nvc);
        }
Example #6
0
        public override NameValueCollection GetParameters(string serviceId)
        {
            var parameters = base.GetParameters(serviceId);

            ParameterValidator.IsNotNull(Amount, "Amount");
            parameters.Add("amount", Amount.ToString());

            ParameterValidator.IsNotNull(BankaccountHolder, "BankaccountHolder");
            parameters.Add("bankaccountHolder", BankaccountHolder);

            ParameterValidator.IsNotNull(BankaccountNumber, "BankaccountNumber");
            parameters.Add("bankaccountNumber", BankaccountNumber);

            ParameterValidator.IsNotNull(IntervalValue, "IntervalValue");
            parameters.Add("intervalValue", IntervalValue.ToString());

            ParameterValidator.IsNotNull(IntervalPeriod, "IntervalPeriod");
            parameters.Add("intervalPeriod", IntervalPeriod.ToEnumString());

            if (!ParameterValidator.IsEmpty(BankaccountBic))
            {
                parameters.Add("bankaccountBic", BankaccountBic);
            }

            if (!ParameterValidator.IsNull(ProcessDate))
            {
                parameters.Add("processDate", ProcessDate.Value.ToString("dd-MM-yyyy"));
            }

            if (!ParameterValidator.IsEmpty(Description))
            {
                parameters.Add("description", Description);
            }

            if (!ParameterValidator.IsEmpty(Currency))
            {
                parameters.Add("currency", Currency);
            }

            if (!ParameterValidator.IsEmpty(ExchangeUrl))
            {
                parameters.Add("exchangeUrl", ExchangeUrl);
            }

            if (!ParameterValidator.IsEmpty(IpAddress))
            {
                parameters.Add("ipAddress", IpAddress);
            }

            if (!ParameterValidator.IsEmpty(Email))
            {
                parameters.Add("email", Email);
            }

            if (ParameterValidator.IsNonEmptyInt(PromotorId))
            {
                parameters.Add("promotorId", PromotorId.ToString());
            }

            if (!ParameterValidator.IsEmpty(Tool))
            {
                parameters.Add("tool", Tool);
            }

            if (!ParameterValidator.IsEmpty(Info))
            {
                parameters.Add("info", Info);
            }

            if (!ParameterValidator.IsEmpty(Object))
            {
                parameters.Add("object", Object);
            }

            if (!ParameterValidator.IsEmpty(Extra1))
            {
                parameters.Add("extra1", Extra1);
            }

            if (!ParameterValidator.IsEmpty(Extra2))
            {
                parameters.Add("extra2", Extra2);
            }

            if (!ParameterValidator.IsEmpty(Extra3))
            {
                parameters.Add("extra3", Extra3);
            }

            return(parameters);
        }
Example #7
0
        public static Client Create(IRestClient restClient, Features[] features = null)
        {
            ParameterValidator.IsNotNull(restClient, "restClient");

            return(new Client(restClient, features));
        }
Example #8
0
        public IActionResult AddParameterValue(int id, [FromBody] ParameterValueAddDto parameterValueAddDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var sim = _context.Experiments
                      .Include(s => s.Parameters).ThenInclude(p => p.Values)
                      .Include(s => s.ExperimentInstances)
                      .SingleOrDefault(s => s.Id == id);

            if (sim == null)
            {
                return(NotFound());
            }

            var changedParameter = sim.Parameters.SingleOrDefault(p => p.Name == parameterValueAddDto.ParameterName);

            if (changedParameter == null)
            {
                return(BadRequest("Invalid parameter name."));
            }

            if (changedParameter.Values.Any(v => v.Value == parameterValueAddDto.Value))
            {
                return(BadRequest("Parameter value already exists."));
            }

            if (!ParameterValidator.IsValid(changedParameter.Type, parameterValueAddDto.Value))
            {
                return(BadRequest("Parameter value is invalid."));
            }

            var addedParameterValue = new ParameterValue
            {
                Parameter = changedParameter,
                Value     = parameterValueAddDto.Value
            };

            changedParameter.Values.Add(addedParameterValue);

            // Find all permutations for all parameters that have not been changed.
            // At this point, all of these experiment instances miss an assignment for the changed parameter!
            var unchangedParameters = sim.Parameters.Where(p => p.Name != parameterValueAddDto.ParameterName);
            var experimentInstances = FindAllInstancePermutations(unchangedParameters);

            // Add the new parameter value to each experiment instance.
            foreach (var experimentInstance in experimentInstances)
            {
                experimentInstance.ParameterValues.Add(new ExperimentParameterAssignment
                {
                    ParameterValue     = addedParameterValue,
                    ExperimentInstance = experimentInstance
                });
            }

            experimentInstances = FilterPermutations(experimentInstances, sim.PermutationFilter);

            experimentInstances = DuplicateExperimentInstances(experimentInstances, sim.Repetitions);


            if (!experimentInstances.Any())
            {
                return(BadRequest("No experiment instances generated after filtering and duplicating."));
            }

            foreach (var experimentInstance in experimentInstances)
            {
                sim.ExperimentInstances.Add(experimentInstance);
            }

            _context.SaveChanges();

            _scalingService.Scale(sim);

            return(Ok());
        }
        public override IWebDriver CreateDriver(DriverProperty driverProperty)
        {
            ParameterValidator.ValidateNotNull(driverProperty, "Driver Property");

            ChromeOptions options = new ChromeOptions();

            if (driverProperty.Headless)
            {
                options.AddArgument("--headless");
                options.AddArgument("--disable-gpu");
                options.AddUserProfilePreference("disable-popup-blocking", "true");
                options.AddUserProfilePreference("intl.accept_languages", "en,en_US");
            }

            if (driverProperty.DownloadLocation != null)
            {
                options.AddUserProfilePreference("download.default_directory", driverProperty.DownloadLocation);
            }

            if (driverProperty.Arguments != null)
            {
                options.AddArguments(driverProperty.GetArgumentsAsArray());
            }

            if (DriverVersion == null)
            {
                lock (Instancelock)
                {
                    if (DriverVersion == null)
                    {
                        if (string.IsNullOrEmpty(driverProperty.DriverVersion))
                        {
                            DriverVersion = GetStableVersion();
                        }
                        else
                        {
                            DriverVersion = driverProperty.DriverVersion;
                        }
                    }
                }
            }

            // Use custom Chrome binary (81)
            // https://chromium.cypress.io/win64/stable/81.0.4044.92
            // options.BinaryLocation = "C:\\Users\\sbaltuonis\\Downloads\\chrome-win\\chrome.exe";

            // Run in private mode
            options.AddArgument("--incognito");

            // Enable mobile emulation
            if (!string.IsNullOrEmpty(driverProperty.DeviceName))
            {
                options.EnableMobileEmulation(driverProperty.DeviceName);
            }
            else if (!string.IsNullOrEmpty(driverProperty.CustomUserAgent))
            {
                if (driverProperty.CustomWidth <= 0 ||
                    driverProperty.CustomHeight <= 0 ||
                    driverProperty.CustomPixelRatio <= 0)
                {
                    throw new Exception("Custom device width, height and pixel ratio must be greater than 0");
                }

                ChromeMobileEmulationDeviceSettings emulationSettings = new ChromeMobileEmulationDeviceSettings
                {
                    UserAgent  = driverProperty.CustomUserAgent,
                    Width      = driverProperty.CustomWidth,
                    Height     = driverProperty.CustomHeight,
                    PixelRatio = driverProperty.CustomPixelRatio
                };

                options.EnableMobileEmulation(emulationSettings);
            }

            // Setup driver binary
            try
            {
                new WebDriverManager.DriverManager().SetUpDriver(new ChromeConfig(), DriverVersion);
            }
            catch (Exception)
            {
                throw new Exception($"Cannot get Chrome driver version {DriverVersion}");
            }

            #pragma warning disable CA2000 // Dispose objects before losing scope
            return(new ChromeDriver(ChromeDriverService.CreateDefaultService(), options, TimeSpan.FromSeconds(180)));

            #pragma warning restore CA2000 // Dispose objects before losing scope
        }
Example #10
0
        public IHttpResponse Handle(IHttpRequest request)
        {
            var getParams     = request.UrlParameters;
            var postParams    = request.FormData;
            var requestMethod = request.Method.ToString();

            var controllerName = string.Empty;
            var actionName     = string.Empty;

            //This handles "/" Url For Controller and Action
            if (request.Path == DefaultPath)
            {
                controllerName = DefaultControllerName;
                actionName     = DefaultActionName;
            }
            else
            {
                string[] invocationParameters =
                    request.Path.Split('/', StringSplitOptions.RemoveEmptyEntries);
                if (invocationParameters.Length != 2)
                {
                    throw new InvalidOperationException("Invalid URL");
                }

                controllerName = invocationParameters[0].CapitalizeFirstLetter() + MvcContext.Get.ControllerSuffix;
                actionName     = invocationParameters[1].CapitalizeFirstLetter();
            }

            var controller = this.GetController(controllerName, request);

            //This validates if there is user logged for all method with needed PreAuthorization and throws Exception if there is no logger user
            try
            {
                MethodInfo action = this.GetMethod(requestMethod, controller, actionName);

                if (action == null)
                {
                    return(new NotFoundResponse());
                }

                var authorizationAtt = action
                                       .GetCustomAttributes()
                                       .Where(att => att is PreAuthorizeAttribute)
                                       .Cast <PreAuthorizeAttribute>()
                                       .FirstOrDefault();

                if (authorizationAtt != null && !controller.SessionUser.IsAuthenticated)
                {
                    return(new RedirectResponse(HomeRoute));
                }

                var parameterValidator = new ParameterValidator();

                var actionParameters = this.MapActionParameters(action, getParams, postParams, parameterValidator);

                controller.ParameterValidator = parameterValidator;

                return(this.PrepareResponse(controller, action, actionParameters));
            }
            catch (Exception e)
            {
                return(new PreAuthorizeAttribute().GetResponse(e.Message));
            }
        }
Example #11
0
        public void UI_EditQuote_Edit_Coverages_Add_Additional_Coverages_Edit_Additional_Coverages(int number, EditQuoteEditCoveragesInformation testData)
        {
            ParameterValidator.ValidateNotNull(testData, "Test Item");

            //1. Navigate to Home page.
            LoginPage loginPage = OpenBreezeApplication();

            //2. Login to Welcome Page
            WelcomePage welcomePage = loginPage.Login();

            //3. Start New Submision
            BusinessClassificationPage businessClassificationPage = welcomePage.StartNewSubmission();

            //4. Get quoteID to be used in subsequent steps
            string quoteId = businessClassificationPage.GetQuoteId();

            //5. Enter business information
            EffectiveDatePage effectiveDatePage = businessClassificationPage.EnterBusinessInformation(testData.BusinessClassification);

            //6. Enter customer information
            VehicleInfoPage vehicleInfoPage = effectiveDatePage.EnterCustomerInformation(testData.CustomerInformation);

            //7. Enter policy level vehicle info
            VehicleEntryPage vehicleEntryPage = vehicleInfoPage.EnterPolicyLevelVehicleInfo <VehicleEntryPage>(testData.PolicyLevelVehicleInformation);

            //8. Add first vehicle
            AddAnotherVehiclePage addAnotherVehiclePage = vehicleEntryPage.AddVehicle(testData.VehicleInfo1);

            //9. No more vehicles
            DriverEnterPage driverEnterPage = addAnotherVehiclePage.NoMoreVehicle();

            //10. Add first driver (PO) - invalid MVR
            AddAnotherDriverPage addAnotherDriverPage = driverEnterPage.AddDriver(testData.DriverInfo1);

            //11. No more drivers
            CoveragesPage coveragesPage = addAnotherDriverPage.NoMoreDriver();

            //12. Use default coverages
            AdditionalCoveragesPage additionalCoveragesPage = coveragesPage.UseDefaultCoverages();

            //13. Select Additional Coverages
            SummaryPage summaryPage = additionalCoveragesPage.SelectAdditionalCoverages <SummaryPage>(testData.DefaultAdditionalCoverages);

            //14. Select Close
            summaryPage.SelectCloseButton();
            // Verification
            welcomePage.ValidateWelcomePageDisplayed();

            //15. Open quote using the quoteID captured in step 4
            welcomePage.ResumeQuote <SummaryPage>(EnvironmentSetting.WebUrl, quoteId);
            // Verification
            summaryPage.ValidateSummaryPageDisplayed();

            //16. Select coverages in the left navigation
            summaryPage.SelectMenuLink <CoveragesPage>(LeftNavigationHeader.Coverage);
            // Verification
            coveragesPage.ValidateCoveragesPageDisplayed()
            .ValidateAdditionalCoveragesSectionDisplayed()
            .ValidateAdditionalCoveragesEditButtonDisplayed();

            //17. Change coverages
            coveragesPage.SelectCoverageLimits(testData.CoverageLimits);
            // Verification
            coveragesPage.ValidatePremiumsNoLongerShown();

            //18. Select Calculate button
            coveragesPage.SelectCalculateButton();
            // Verification
            coveragesPage.ValidateTotalPremiumRecalculatedAndDisplayed();

            //19. Add Additional coverage from Coverage screen with no prior additional coverage
            coveragesPage.AddAdditionalCoverageFromCoverageScreenWithNoPriorAdditionalCoverage(testData.DefaultCoverageSections, testData.DefaultAdditionalCoveragesList);

            //20. Select Additional Interests and Cargo, Select Next
            AdditionalInterestCountsPage additionalInterestCountsPage = additionalCoveragesPage.SelectAdditionalCoverages <AdditionalInterestCountsPage>(testData.AdditionalCoverages, true);

            //21. Enter @AddInterests, Select Next
            CargoLimitDeductiblePage cargoLimitDeductiblePage = additionalInterestCountsPage.EnterAdditionalInterestCounts <CargoLimitDeductiblePage>(testData.AdditionalCoverages, true);

            //22. Make @CargoInfo selections
            AdditionalCoveragesOverviewPage additionalCoveragesOverviewPage = cargoLimitDeductiblePage.EnterCargoInformation <AdditionalCoveragesOverviewPage>(testData.AdditionalCoverages, true);

            // Verification
            additionalCoveragesOverviewPage.ValidateAdditionalCoverageDisplayed(AdditionalCoveragesType.AdditionalInterests)
            .ValidateAdditionalCoverageDisplayed(AdditionalCoveragesType.Cargo)
            .ValidateAdditionalInterestsCoverageDisplayedCorrectly(testData.AdditionalCoverages.AdditionalInterests)
            .ValidateCargoCoverageDisplayedCorrectly(testData.AdditionalCoverages.Cargo)
            .ValidateEditButtonDisplayed(AdditionalCoveragesType.AdditionalInterests)
            .ValidateDeleteButtonDisplayed(AdditionalCoveragesType.AdditionalInterests)
            .ValidateEditButtonDisplayed(AdditionalCoveragesType.Cargo)
            .ValidateDeleteButtonDisplayed(AdditionalCoveragesType.Cargo)
            .ValidateAdditionalCoveragePremiumDisplayed(AdditionalCoveragesType.AdditionalInterests)
            .ValidateAdditionalCoveragePremiumDisplayed(AdditionalCoveragesType.Cargo);

            //23. Select Coverages from the left navigation
            additionalCoveragesOverviewPage.SelectMenuLink <CoveragesPage>(LeftNavigationHeader.Coverage);
            // Verification
            coveragesPage.ValidateCoveragesPageDisplayed()
            .ValidatePreviousCoveragesListed(testData.CoverageLimits)
            .ValidatePremiumInLeftNavigationMatchesCoveragesScreen();

            //24. Select Edit button of Additional Coverages section
            coveragesPage.SelectEditAdditionalCoveragesIcon();
            // Verification
            additionalCoveragesOverviewPage.ValidateAdditionalCoveragesOverviewPageDisplayed()
            .ValidateAdditionalCoverageDisplayed(AdditionalCoveragesType.AdditionalInterests)
            .ValidateAdditionalCoverageDisplayed(AdditionalCoveragesType.Cargo);

            //25. Click Delete button for Cargo
            additionalCoveragesOverviewPage.SelectDeleteIcon(AdditionalCoveragesType.Cargo);
            // Verification
            additionalCoveragesOverviewPage.ValidateDialogContentDisplayedCorrectly(testData.DialogContent);

            //26. Select yes
            additionalCoveragesOverviewPage.ConfirmDeleteAdditionalCoverage(AdditionalCoveragesType.Cargo);
            // Verification
            additionalCoveragesOverviewPage.ValidateAdditionalCoverageDisplayed(AdditionalCoveragesType.AdditionalInterests)
            .ValidateAdditionalCoverageNotDisplayed(AdditionalCoveragesType.Cargo)
            .ValidateAddAdditionalCoveragesButtonDisplayed()
            .ValidateCoverageSummaryButtonDisplayed();

            //27. Select Add Additional Coverages button
            additionalCoveragesOverviewPage.SelectAddAdditionalCoveragesButton();
            // Verification
            additionalCoveragesPage.ValidateAdditionalCoveragesPageDisplayed()
            .ValidateAdditionalCoveragesListed(testData.ExpectedAdditionalCoverages)
            .ValidateAdditionalCoveragesNotListed(testData.UnexpectedAdditionalCoverages);

            //28.1 Select Trailer Interchange and click Next
            TrailerInterchangePage trailerInterchangePage = additionalCoveragesPage.SelectAdditionalCoverages <TrailerInterchangePage>(testData.AdditionalCoveragesChange);

            //28.2 Finish Trailer Interchange coverage info
            trailerInterchangePage.EnterTrailerInterchange <AdditionalCoveragesOverviewPage>(testData.AdditionalCoveragesChange, true);

            //29. Inspect page contents
            additionalCoveragesOverviewPage.ValidatePremiumInLeftNavigationMatchesAdditionalCoveragesOverviewScreen();
        }
 public async Task RemoveBackupRepositoryAsync(string repositoryId, CancellationToken ct = default)
 {
     ParameterValidator.ValidateNotNull(repositoryId, nameof(repositoryId));
     var url = $"backuprepositories/{repositoryId}";
     await _baseClient.DeleteAsync(url, null, ct);
 }
Example #13
0
        public static SummaryPage CreateQuote(this WelcomePage wellcomePage, Quote quote)
        {
            ParameterValidator.ValidateNotNull(wellcomePage, "WellcomePage");
            ParameterValidator.ValidateNotNull(quote, "Quote");

            //1. Start new submission
            BusinessClassificationPage businessClassificationPage = wellcomePage.StartNewSubmission();
            //2. Enter business infomation
            EffectiveDatePage effectiveDatePage = businessClassificationPage.EnterBusinessInformation(quote.BusinessClassification);

            //3. Enter policy level vehicle info
            VehicleInfoPage vehicleInfoPage = effectiveDatePage.EnterCustomerInformation(quote.CustomerInformation);

            //4. Enter policy level vehicle info
            VehicleEntryPage vehicleEntryPage = vehicleInfoPage.EnterPolicyLevelVehicleInfo <VehicleEntryPage>(quote.PolicyLevelVehicleInformation);

            //5. Add vehicles
            AddAnotherVehiclePage addAnotherVehiclePage = new AddAnotherVehiclePage();

            for (int i = 0; i < quote.VehicleList.Length; i++)
            {
                vehicleEntryPage.AddVehicle(quote.VehicleList[i]);
                if (i == quote.VehicleList.Length - 1)
                {
                    addAnotherVehiclePage.NoMoreVehicle();
                }
                else
                {
                    addAnotherVehiclePage.YesMoreVehicle();
                }
            }

            //6. Add driver
            DriverEnterPage      driverEnterPage      = new DriverEnterPage();
            AddAnotherDriverPage addAnotherDriverPage = new AddAnotherDriverPage();

            for (int i = 0; i < quote.DriverList.Length; i++)
            {
                if (quote.DriverList[i].DoesNotDrive)
                {
                    driverEnterPage.AddDriver <DriverEnterPage>(quote.DriverList[i]);
                }
                else
                {
                    driverEnterPage.AddDriver(quote.DriverList[i]);
                    if (i == quote.DriverList.Length - 1)
                    {
                        addAnotherDriverPage.NoMoreDriver();
                    }
                    else
                    {
                        addAnotherDriverPage.YesMoreDriver();
                    }
                }
            }

            //7. Select coverage limits
            CoveragesPage coveragesPage = new CoveragesPage();

            if (quote.CoverageLimits != null)
            {
                coveragesPage.SelectCoverageLimits(quote.CoverageLimits).SelectCalculateButton().SelectNextButton();
            }
            else
            {
                coveragesPage.UseDefaultCoverages();
            }

            //8. Select Additional Coverages
            AdditionalCoveragesPage additionalCoveragesPage = new AdditionalCoveragesPage();

            additionalCoveragesPage.SelectAdditionalCoverages <SummaryPage>(quote.AdditionalCoverages);

            //9. Enter Additional Coverages(if needed)
            SummaryPage summaryPage = additionalCoveragesPage.EnterAdditionalCoverages(quote.AdditionalCoverages);

            return(summaryPage);
        }
Example #14
0
        public virtual bool DenyEditProperty(string propertyName)
        {
            ParameterValidator.AssertIsNotNullOrWhiteSpace("propertyName", propertyName);

            return(false);
        }
Example #15
0
        /// <summary>Initializes a new instance of the Cenfo.KeepKnowledge.Ioc.Concrete.StructureMapDependencyResolver class.</summary>
        /// <param name="container">The container.</param>
        public StructureMapDependencyResolver(IContainer container)
        {
            ParameterValidator.ValidateNotNullParameters("container", container);

            this._container = container;
        }
 public MazeGenerator()
 {
     validator = new ParameterValidator();
 }
Example #17
0
        public IActionResult Create([FromBody] ExperimentCreateDto requestData)
        {
            /* Performance statistics */
            Stopwatch sw = new Stopwatch();

            sw.Start();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (requestData.Parameters.Select(p => p.Name).Distinct().Count() != requestData.Parameters.Count)
            {
                return(BadRequest("Parameter names are not unique."));
            }

            if (!requestData.Parameters.All(p => p.Values.All(v => ParameterValidator.IsValid(p.Type, v))))
            {
                return(BadRequest("Parameter values are not valid."));
            }

            string errMsg = "";
            string msg    = "";

            if (!ExecuteLocalMACIScript(requestData.FileName, ref msg, ref errMsg))
            {
                return(new ObjectResult(new
                {
                    Failed = true,
                    Message = msg,
                    ErrorMessage = errMsg
                }));
            }

            // Create the experiment.
            var experiment = new Experiment
            {
                Created              = DateTime.UtcNow,
                Script               = requestData.Script,
                ScriptInstall        = requestData.ScriptInstall,
                Parameters           = new List <Parameter>(),
                RequiredCapabilities = requestData.RequiredCapabilities,
                Language             = requestData.Language,
                PermutationFilter    = requestData.PermutationFilter,
                Repetitions          = requestData.Repetitions,
                RunName              = requestData.RunName,
                FileName             = requestData.FileName,
                Timeout              = 60 // in minutes
            };

            // Create parameters and parameter values.
            foreach (var parameterDto in requestData.Parameters)
            {
                var experimentParam = new Parameter
                {
                    Name       = parameterDto.Name,
                    Type       = parameterDto.Type,
                    Purpose    = parameterDto.Purpose,
                    Unit       = parameterDto.Unit,
                    Experiment = experiment,
                    Values     = new List <ParameterValue>()
                };

                experiment.Parameters.Add(experimentParam);

                foreach (var value in parameterDto.Values)
                {
                    experimentParam.Values.Add(new ParameterValue
                    {
                        Parameter = experimentParam,
                        Value     = value
                    });
                }
            }

            AddSeedParameter(experiment, requestData.Seeds);

            // Create one ExperimentInstance for each unique combination of parameters.
            var instances = FindAllInstancePermutations(experiment.Parameters);

            TimeSpan ts = sw.Elapsed;

            Console.WriteLine("Generated " + instances.Count() + " experiment instances in " + String.Format("{0:00}:{1:00}:{2:00}",
                                                                                                             ts.Hours, ts.Minutes, ts.Seconds));

            try
            {
                instances = FilterPermutations(instances, experiment.PermutationFilter);
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }

            ts = sw.Elapsed;
            Console.WriteLine("Filtered to " + instances.Count() + " experiment instances in " + String.Format("{0:00}:{1:00}:{2:00}",
                                                                                                               ts.Hours, ts.Minutes, ts.Seconds));

            instances = DuplicateExperimentInstances(instances, requestData.Repetitions);

            if (!instances.Any())
            {
                return(BadRequest("No experiment instances generated after filtering and duplicating."));
            }

            if (requestData.TestRun)
            {
                instances = instances.Take(1).ToList();
                instances.ForEach(i => i.Priority = 100);
                experiment.RunName = "TEST: " + experiment.RunName;
            }

            experiment.ExperimentInstances = instances;

            // Add everything to the database.
            _context.Add(experiment);
            _context.SaveChanges();


            /* Event logging */
            TimeSpan totalTime = sw.Elapsed;

            _context.Add(new GlobalEventLogMessage
            {
                Message = String.Format("Created Experiment {0:0} with {1:0} instances in {2:00}:{3:00}:{4:00}",
                                        experiment.Id,
                                        experiment.ExperimentInstances.Count(),
                                        totalTime.Hours,
                                        totalTime.Minutes,
                                        totalTime.Seconds),
                ExperimentId         = experiment.Id,
                Time                 = DateTime.Now,
                Type                 = GlobalEventLogMessageType.Info,
                ExperimentInstanceId = -1
            });
            _context.SaveChanges();


            /* Create folder and copy relevant files (persistent snapshot)
             * after storing in database (storing generates the experimentId) */
            CreatePersistentSnapshotFolder(experiment);

            _scalingService.Scale(experiment);

            return(new ObjectResult(new
            {
                ExperimentId = experiment.Id,
                ExperimentInstanceId = experiment.ExperimentInstances.First().Id
            }));
        }
Example #18
0
        protected IRestResponse SendHttpCall(RequestParameter requestParameter)
        {
            ParameterValidator.ValidateNotNull(requestParameter, "Request parameters");

            var client = new RestClient(BaseUrl);

            string uri = BaseUrl;

            if (!string.IsNullOrEmpty(ResourceAddress))
            {
                uri = Url.Combine(uri, ResourceAddress);
            }

            if (!string.IsNullOrEmpty(requestParameter.OperationPath))
            {
                uri = Url.Combine(uri, requestParameter.OperationPath);
            }

            var request = new RestRequest(new Uri(uri), requestParameter.Method);

            // Header
            request.AddHeader("content-Type", "application/json");

            if (requestParameter.AddAccessToken)
            {
                request.AddHeader("Authorization", "Bearer " + AccessToken);
            }

            if (requestParameter.AddSubscriptionKey)
            {
                request.AddHeader("Ocp-Apim-Subscription-Key", SubscriptionKey);
            }

            if (requestParameter.HeaderParameters != null && requestParameter.HeaderParameters.Count > 0)
            {
                foreach (var item in requestParameter.HeaderParameters)
                {
                    request.AddHeader(item.Key, item.Value);
                }
            }

            // Parameters
            request.AddParameter("cache-control", "no-cache");

            if (requestParameter.QueryParameters != null && requestParameter.QueryParameters.Count > 0)
            {
                foreach (var item in requestParameter.QueryParameters)
                {
                    request.AddQueryParameter(item.Key, item.Value);
                }
            }

            if (!string.IsNullOrEmpty(Code))
            {
                request.AddQueryParameter("code", Code);
            }

            // Body
            if (requestParameter.PostBody != null)
            {
                request.JsonSerializer = NewtonsoftJsonSerializer.Default;
                if (requestParameter.PostBody is string)
                {
                    request.AddParameter(request.JsonSerializer.ContentType, requestParameter.PostBody, ParameterType.RequestBody);
                }
                else
                {
                    request.AddJsonBody(requestParameter.PostBody);
                }
            }

            var response = client.Execute(request);

            return(response);
        }
Example #19
0
        public IActionResult AddCombination(int id, [FromBody] List <ParameterValueAddDto> parameterValueAddDto)
        {
            /*
             * This method does not ensure a full cartesian product.
             */

            var       performanceTracking = false;
            Stopwatch sw = performanceTracking ? new Stopwatch() : null;

            if (sw != null)
            {
                sw.Start();
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (sw != null)
            {
                TimeSpan ts = sw.Elapsed;
                Console.WriteLine("Model state validated after " + String.Format("{0:00}:{1:00}:{2:00}:{3:00}",
                                                                                 ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds));
            }

            Experiment sim;

            if (!_cache.TryGetValue(id, out sim))
            {
                sim = _context.Experiments
                      .Include(s => s.Parameters).ThenInclude(p => p.Values)
                      .SingleOrDefault(s => s.Id == id);
                _cache.Set(id, sim, TimeSpan.FromMinutes(1));
            }

            if (sim == null)
            {
                Console.WriteLine("Server did not find experiment " + id.ToString());
                return(NotFound());
            }

            if (sw != null)
            {
                TimeSpan ts = sw.Elapsed;
                Console.WriteLine("Loaded data after " + String.Format("{0:00}:{1:00}:{2:00}:{3:00}",
                                                                       ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds));
            }

            if (!parameterValueAddDto.TrueForAll(para => sim.Parameters.Single(p => p.Name == para.ParameterName) != null))
            {
                Console.WriteLine("Invalid parameter name " + parameterValueAddDto.Where(para => sim.Parameters.Single(p => p.Name == para.ParameterName) == null).First().ParameterName + ".");
                return(BadRequest("Invalid parameter name " + parameterValueAddDto.Where(para => sim.Parameters.Single(p => p.Name == para.ParameterName) == null).First().ParameterName + "."));
            }

            /*if (sim.Parameters.Where(para => parameterValueAddDto.Exists(p => p.ParameterName != para.Name)).Count() > 0)
             * {
             *  Console.WriteLine("Missing parameter " + sim.Parameters.Where(para => parameterValueAddDto.Exists(p => p.ParameterName != para.Name)).First().Name + ".");
             *  return BadRequest("Missing parameter " + sim.Parameters.Where(para => parameterValueAddDto.Exists(p => p.ParameterName != para.Name)).First().Name + ".");
             * }*/

            if (!parameterValueAddDto.TrueForAll(para => ParameterValidator.IsValid(sim.Parameters.Single(p => p.Name == para.ParameterName).Type, para.Value)))
            {
                Console.WriteLine("Parameter value " +
                                  parameterValueAddDto.Where(para => !ParameterValidator.IsValid(sim.Parameters.Single(p => p.Name == para.ParameterName).Type, para.Value)).First().Value +
                                  " is invalid.");
                return(BadRequest("Parameter value " +
                                  parameterValueAddDto.Where(para => !ParameterValidator.IsValid(sim.Parameters.Single(p => p.Name == para.ParameterName).Type, para.Value)).First().Value +
                                  " is invalid."));
            }

            var experimentInstance = new ExperimentInstance();

            experimentInstance.ParameterValues = parameterValueAddDto.
                                                 Select(para => new ExperimentParameterAssignment
            {
                ParameterValue = new ParameterValue
                {
                    Parameter = sim.Parameters.SingleOrDefault(p => p.Name == para.ParameterName),
                    Value     = para.Value
                },
                ExperimentInstance = experimentInstance
            }).ToList();

            experimentInstance.ExperimentId = sim.Id;
            experimentInstance.Experiment   = sim;

            /*
             * The whole caching is kind of nasty.
             * We might got sim from the cache, so make
             * sure to not add it without tracking.
             */

            if (sw != null)
            {
                TimeSpan ts = sw.Elapsed;
                Console.WriteLine("Prepared data for storage after " + String.Format("{0:00}:{1:00}:{2:00}:{3:00}",
                                                                                     ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds));
            }

            _context.Attach(sim);
            _context.Add(experimentInstance);
            _context.SaveChanges();

            if (sw != null)
            {
                TimeSpan ts = sw.Elapsed;
                Console.WriteLine("Stored data after " + String.Format("{0:00}:{1:00}:{2:00}:{3:00}",
                                                                       ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds));
            }

            //_scalingService.Scale(sim);

            if (sw != null)
            {
                TimeSpan ts = sw.Elapsed;
                Console.WriteLine("Finished scaling after " + String.Format("{0:00}:{1:00}:{2:00}:{3:00}",
                                                                            ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds));
            }

            return(new ObjectResult(new
            {
                ExperimentInstanceId = experimentInstance.Id
            }));
        }
Example #20
0
        public static T AddDriver <T>(this DriverEnterPage driverEnterPage, DriverInformation driverInformation)
        {
            ParameterValidator.ValidateNotNull(driverEnterPage, "Driver enter page");
            ParameterValidator.ValidateNotNull(driverInformation, "Driver information");

            AddAnotherDriverPage addAnotherDriverPage = new AddAnotherDriverPage();
            CDLExperiencePage    cDLExperiencePage    = new CDLExperiencePage();
            DriverOverviewPage   driverOverviewPage   = new DriverOverviewPage();

            if (driverInformation.IsPO)
            {
                //1. Complete driver info and select next
                driverEnterPage.EnterDriverInfo(driverInformation).SelectNextButton();
            }
            else
            {
                //1.1 Complete Name and Date of Birth
                driverEnterPage.EnterNameAndDOB(driverInformation);
                //Verification
                driverEnterPage.ValidateNextButtonDisplayedAndEnabled();

                //1.2 Complete license number and state and select next
                driverEnterPage.EnterLicenseAndState(driverInformation).SelectNextButton();
            }
            //Verification
            cDLExperiencePage.ValidateCDLExperiencePageDisplayed();

            //2. Complete CDL Experience info and select next
            dynamic currentPage = cDLExperiencePage.EnterCDLExperience(driverInformation.CDLExperience).SelectNextButton();

            if (driverInformation.MVRStatus == OrderMVRStatus.Invalid ||
                (driverInformation.MVRStatus == OrderMVRStatus.Unknown &&
                 currentPage is AccidentsAndViolationsPage))
            {
                AccidentsAndViolationsPage accidentsAndViolationsPage = new AccidentsAndViolationsPage();
                //verification
                accidentsAndViolationsPage.ValidateAccidentsAndViolationsPageDisplayed();

                //3. Complete Accident and Violation info and select next
                ConvictionsPage convictionsPage = accidentsAndViolationsPage.EnterAccidentAndViolation(driverInformation.AccidentsAndViolations).SelectNextButton();

                //Verification
                convictionsPage.ValidateConvictionsPageDisplayed();

                //4. Complete Convictions info
                convictionsPage.EnterConviction(driverInformation.Conviction);

                // Navigate to Driver Overview page if process is edit Flow
                if (driverInformation.IsEditFlow)
                {
                    //Select next button
                    convictionsPage.SelectNextButton <DriverOverviewPage>();
                }
                // Require the second driver if DoseNotDrive was checked
                else if (driverInformation.DoesNotDrive)
                {
                    // Select Next Button
                    convictionsPage.SelectNextButton <DriverEnterPage>();
                }
                else
                {
                    // Select Next button
                    convictionsPage.SelectNextButton <AddAnotherDriverPage>();
                }
            }
            if (driverInformation.IsEditFlow)
            {
                // verification
                driverOverviewPage.ValidateDriverOverviewPageDisplayed();
            }
            else if (driverInformation.DoesNotDrive)
            {
                //Verification
                driverEnterPage.ValidateDriverEnterPageDisplayed();
            }
            else
            {
                // Verification
                addAnotherDriverPage.ValidateAddAnotherDriverPageDisplayed();
            }
            return((T)Activator.CreateInstance(typeof(T)));
        }
Example #21
0
        // Alias for the old constructor so that it remains backwards compatible
        public Objects.Verify CreateVerify(string recipient, VerifyOptionalArguments arguments = null)
        {
            ParameterValidator.IsNotNullOrWhiteSpace(recipient, "recipient");

            return(CreateVerify(Convert.ToInt64(recipient), arguments));
        }
 public static string GetValue(this IWebElement element)
 {
     ParameterValidator.ValidateNotNull(element, "Element");
     return(element.GetAttribute("value"));
 }
        public static void SelectDatePicker(this IWebElement element, string date, string dateFormat = "MM/dd/yyyy")
        {
            string[] months = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" };

            if (date != null)
            {
                ParameterValidator.ValidateNotNull(element, "Element");

                string    currentValue;
                string[]  currentMonthYear;
                string[]  currentYearRange;
                int       monthIndex         = 0;
                int       yearIndex          = 1;
                char      dateSeparator      = ' ';
                char      yearRangeSeparator = '–';
                var       targetDate         = DateHelper.GetDateFromString(date, dateFormat);
                Stopwatch stopwatch          = new Stopwatch();

                // Prepare arrow button direction
                var arrowButton = nextCalendarLocator;
                if (DateTime.Now.Date > targetDate)
                {
                    arrowButton = previousCalendarLocator;
                }

                // Open date picker
                element.Click();
                WaitForElementVisible(calendarLocator);

                // Select month year if needed
                currentValue = GetText(calendarPeriodItemLocator);
                if (currentValue.Trim().Contains("/"))
                {
                    yearIndex     = 2;
                    dateSeparator = '/';
                }

                currentMonthYear = currentValue.Trim().Split(dateSeparator);
                if (targetDate.Year != Convert.ToInt32(currentMonthYear[yearIndex]))
                {
                    // Open Month Year calendar
                    CalendarPeriodItem.Click();

                    // Loop to open suitable year ranges
                    stopwatch.Start();
                    do
                    {
                        currentValue     = GetText(calendarPeriodItemLocator);
                        currentYearRange = currentValue.Trim().Split(yearRangeSeparator);
                        // Stop looping if target year match year ranges
                        if (targetDate.Year >= Convert.ToInt32(currentYearRange[0]) && targetDate.Year <= Convert.ToInt32(currentYearRange[1]))
                        {
                            break;
                        }

                        // Open other year ranges
                        StableFindElement(arrowButton, mediumTimeout).Click();
                        WaitForElementTextChanged(calendarPeriodItemLocator, currentValue, mediumTimeout);
                    } while (stopwatch.ElapsedMilliseconds <= longTimeout * 1000);
                    stopwatch.Reset();

                    // Select Year
                    currentValue = GetText(calendarPeriodItemLocator);
                    TargetCalendarItem(targetDate.Year.ToString()).Click();
                    WaitForElementTextChanged(calendarPeriodItemLocator, currentValue, mediumTimeout);

                    // Select Month
                    currentValue = GetText(calendarPeriodItemLocator);
                    TargetCalendarItem(months[targetDate.Month - 1]).Click();
                    WaitForElementTextChanged(calendarPeriodItemLocator, currentValue, mediumTimeout);
                }

                // Loop to open suitable month
                stopwatch.Start();
                do
                {
                    currentValue     = GetText(calendarPeriodItemLocator);
                    currentMonthYear = currentValue.Trim().Split(dateSeparator);
                    // Stop looping if target month match current month
                    if ((Utils.IsNumber(currentMonthYear[monthIndex]) && Convert.ToInt32(currentMonthYear[monthIndex]) == targetDate.Month) ||
                        currentMonthYear[monthIndex] == months[targetDate.Month - 1])
                    {
                        break;
                    }

                    // Open other month
                    StableFindElement(arrowButton, mediumTimeout).Click();
                    WaitForElementTextChanged(calendarPeriodItemLocator, currentValue, mediumTimeout);
                } while (stopwatch.ElapsedMilliseconds <= longTimeout * 1000);
                stopwatch.Stop();

                // Select Day
                currentValue = GetText(calendarPeriodItemLocator);
                TargetCalendarItem(targetDate.Day.ToString()).Click();
                WaitForElementInvisible(calendarLocator);
            }
        }
 public static void ScrollIntoViewAndClick(this IWebElement element)
 {
     ParameterValidator.ValidateNotNull(element, "Element");
     element.ScrollIntoView();
     element.Click();
 }
Example #25
0
        public static Client CreateDefault(string accessKey, IProxyConfigurationInjector proxyConfigurationInjector = null)
        {
            ParameterValidator.IsNotNullOrWhiteSpace(accessKey, "accessKey");

            return(new Client(new RestClient(accessKey, proxyConfigurationInjector)));
        }
 public static void ScrollIntoViewBottom(this IWebElement element)
 {
     ParameterValidator.ValidateNotNull(element, "Element");
     WebDriver.ExecuteScript("arguments[0].scrollIntoView(false);", element);
 }
Example #27
0
        public override NameValueCollection GetParameters(string serviceId)
        {
            var parameters = base.GetParameters(serviceId);

            ParameterValidator.IsNotNull(Amount, "Amount");
            parameters.Add("amount", Amount.ToString());

            ParameterValidator.IsNotNull(BankAccountHolder, "BankAccountHolder");
            parameters.Add("bankAccountHolder", BankAccountHolder);

            ParameterValidator.IsNotNull(BankAccountNumber, "BankAccountNumber");
            parameters.Add("bankAccountNumber", BankAccountNumber);

            ParameterValidator.IsNotNull(BankAccountBic, "BankAccountBic");
            parameters.Add("bankAccountBic", BankAccountBic);

            if (!ParameterValidator.IsEmpty(Description))
            {
                parameters.Add("description", Description);
            }

            if (!ParameterValidator.IsNonEmptyInt(PromotorId))
            {
                parameters.Add("promotorId", PromotorId.Value.ToString());
            }

            if (!ParameterValidator.IsEmpty(Tool))
            {
                parameters.Add("tool", Tool);
            }

            if (!ParameterValidator.IsEmpty(Info))
            {
                parameters.Add("info", Info);
            }

            if (!ParameterValidator.IsEmpty(Object))
            {
                parameters.Add("object", Object);
            }

            if (!ParameterValidator.IsEmpty(Extra1))
            {
                parameters.Add("extra1", Extra1);
            }

            if (!ParameterValidator.IsEmpty(Extra2))
            {
                parameters.Add("extra2", Extra2);
            }

            if (!ParameterValidator.IsEmpty(Extra3))
            {
                parameters.Add("extra3", Extra3);
            }

            if (!ParameterValidator.IsEmpty(Currency))
            {
                parameters.Add("currency", Currency);
            }

            if (ProcessDate.HasValue)
            {
                parameters.Add("processDate", this.ProcessDate.Value.ToString("yyyy-MM-dd"));
            }

            return(parameters);
        }
Example #28
0
        public override NameValueCollection GetParameters()
        {
            var nvc = base.GetParameters();

            // Basic params
            ParameterValidator.IsNotNull(Amount, "Amount");
            nvc.Add("amount", Amount.ToString());

            ParameterValidator.IsNotNull(IPAddress, "IPAddress");
            nvc.Add("ipAddress", IPAddress);

            ParameterValidator.IsNotNull(ReturnUrl, "ReturnUrl");
            nvc.Add("finishUrl", ReturnUrl);

            if (ParameterValidator.IsNonEmptyInt(PaymentOptionId))
            {
                nvc.Add("paymentOptionId", PaymentOptionId.ToString());
            }

            if (ParameterValidator.IsNonEmptyInt(PaymentOptionSubId))
            {
                nvc.Add("paymentOptionSubId", PaymentOptionSubId.ToString());
            }

            if (!ParameterValidator.IsEmpty(TransferValue))
            {
                if (TransferType == "transaction" || TransferType == "merchant")
                {
                    nvc.Add("transferType", TransferType);
                    nvc.Add("transferValue", TransferValue);
                }
                else
                {
                    throw new Exception("TransferValue cannot be set, without valid TransferType, please fix this.");
                }
            }

            // Transaction
            if (Transaction != null)
            {
                if (!ParameterValidator.IsNull(Transaction.Currency))
                {
                    nvc.Add("transaction[currency]", Transaction.Currency);
                }
                if (ParameterValidator.IsNonEmptyInt(Transaction.CostsVat))
                {
                    nvc.Add("transaction[costsVat]", Transaction.CostsVat.ToString());
                }
                // TODO: exclude cost?
                if (!ParameterValidator.IsEmpty(Transaction.OrderExchangeUrl))
                {
                    nvc.Add("transaction[orderExchangeUrl]", Transaction.OrderExchangeUrl);
                }
                if (!ParameterValidator.IsEmpty(Transaction.Description))
                {
                    nvc.Add("transaction[description]", Transaction.Description);
                }

                /*
                 * if (!ParameterValidator.IsNonEmptyInt(Transaction.EnduserId))
                 * {
                 *  nvc.Add("transaction[enduserId]", Transaction.EnduserId.ToString());
                 * }
                 * */
                if (!ParameterValidator.IsNull(Transaction.ExpireDate))
                {
                    nvc.Add("transaction[expireDate]", ((DateTime)Transaction.ExpireDate).ToString("dd-MM-yyyy hh:mm:ss"));
                }
                // TODO: Are these right? SHouldn't this be BOOL / INT?

                /*
                 * if (!ParameterValidator.IsEmpty(Transaction.SendReminderEmail))
                 * {
                 *  nvc.Add("transaction[sendReminderEmail]", Transaction.SendReminderEmail);
                 * }
                 * if (!ParameterValidator.IsEmpty(Transaction.ReminderMailTemplateId))
                 * {
                 *  nvc.Add("transaction[reminderMailTemplateId]", Transaction.ReminderMailTemplateId);
                 * }
                 */
                if (!ParameterValidator.IsNull(Transaction.OrderNumber))
                {
                    nvc.Add("transaction[orderNumber]", Transaction.OrderNumber);
                }
            }

            // StatsData
            if (StatsData != null)
            {
                if (ParameterValidator.IsNonEmptyInt(StatsData.PromotorId))
                {
                    nvc.Add("statsData[promotorId]", StatsData.PromotorId.ToString());
                }
                if (!ParameterValidator.IsEmpty(StatsData.Info))
                {
                    nvc.Add("statsData[info]", StatsData.Info);
                }
                if (!ParameterValidator.IsEmpty(StatsData.Tool))
                {
                    nvc.Add("statsData[tool]", StatsData.Tool);
                }
                if (!ParameterValidator.IsEmpty(StatsData.Extra1))
                {
                    nvc.Add("statsData[extra1]", StatsData.Extra1);
                }
                if (!ParameterValidator.IsEmpty(StatsData.Extra2))
                {
                    nvc.Add("statsData[extra2]", StatsData.Extra2);
                }
                if (!ParameterValidator.IsEmpty(StatsData.Extra3))
                {
                    nvc.Add("statsData[extra3]", StatsData.Extra3);
                }
                //if (!ParameterValidator.IsEmpty(StatsData.TransferData))
                //{
                //    nvc.Add("statsData[transferData]", StatsData.TransferData);
                //}
            }

            // End user
            if (Enduser != null)
            {
                /*
                 * if (!ParameterValidator.IsEmpty(Enduser.AccessCode))
                 * {
                 *  nvc.Add("enduser[accessCode]", Enduser.AccessCode);
                 * }
                 * */
                if (!ParameterValidator.IsEmpty(Enduser.Language))
                {
                    nvc.Add("enduser[language]", Enduser.Language);
                }
                if (!ParameterValidator.IsEmpty(Enduser.Initials))
                {
                    nvc.Add("enduser[initials]", Enduser.Initials);
                }
                if (!ParameterValidator.IsEmpty(Enduser.Lastname))
                {
                    nvc.Add("enduser[lastName]", Enduser.Lastname);
                }
                if (!ParameterValidator.IsNull(Enduser.Gender))
                {
                    nvc.Add("enduser[gender]", EnumUtil.ToEnumString((Gender)Enduser.Gender));
                }
                if (!ParameterValidator.IsNull(Enduser.BirthDate))
                {
                    nvc.Add("enduser[dob]", ((DateTime)Enduser.BirthDate).ToString("dd-MM-yyyy"));
                }
                if (!ParameterValidator.IsEmpty(Enduser.PhoneNumber))
                {
                    nvc.Add("enduser[phoneNumber]", Enduser.PhoneNumber);
                }
                if (!ParameterValidator.IsEmpty(Enduser.EmailAddress))
                {
                    nvc.Add("enduser[emailAddress]", Enduser.EmailAddress);
                }
                if (!ParameterValidator.IsEmpty(Enduser.BankAccount))
                {
                    nvc.Add("enduser[bankAccount]", Enduser.BankAccount);
                }
                if (!ParameterValidator.IsEmpty(Enduser.IBAN))
                {
                    nvc.Add("enduser[iban]", Enduser.IBAN);
                }

                /*
                 * if (!ParameterValidator.IsNull(Enduser.SendConfirmMail))
                 * {
                 *  nvc.Add("enduser[sendConfirmMail]", ((bool)Enduser.SendConfirmMail) ? "1" : "0");
                 * }
                 * if (!ParameterValidator.IsEmpty(Enduser.ConfirmMailTemplate))
                 * {
                 *  nvc.Add("enduser[confirmMailTemplate]", Enduser.ConfirmMailTemplate);
                 * }
                 * */
                if (!ParameterValidator.IsEmpty(Enduser.CustomerReference))
                {
                    nvc.Add("enduser[customerReference]", Enduser.CustomerReference);
                }
                // Address
                if (Enduser.Address != null)
                {
                    if (!ParameterValidator.IsEmpty(Enduser.Address.StreetName))
                    {
                        nvc.Add("enduser[address][streetName]", Enduser.Address.StreetName);
                    }
                    if (!ParameterValidator.IsEmpty(Enduser.Address.StreetNumber))
                    {
                        nvc.Add("enduser[address][streetNumber]", Enduser.Address.StreetNumber);
                    }
                    if (!ParameterValidator.IsEmpty(Enduser.Address.ZipCode))
                    {
                        nvc.Add("enduser[address][zipCode]", Enduser.Address.ZipCode);
                    }
                    if (!ParameterValidator.IsEmpty(Enduser.Address.City))
                    {
                        nvc.Add("enduser[address][city]", Enduser.Address.City);
                    }
                    if (!ParameterValidator.IsEmpty(Enduser.Address.CountryCode))
                    {
                        nvc.Add("enduser[address][countryCode]", Enduser.Address.CountryCode);
                    }
                }

                // InvoiceAddress
                if (Enduser.InvoiceAddress != null)
                {
                    if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.Initials))
                    {
                        nvc.Add("enduser[invoiceAddress][initials]", Enduser.InvoiceAddress.Initials);
                    }
                    if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.LastName))
                    {
                        nvc.Add("enduser[invoiceAddress][lastName]", Enduser.InvoiceAddress.LastName);
                    }
                    if (!ParameterValidator.IsNull(Enduser.InvoiceAddress.Gender))
                    {
                        var gender = EnumUtil.ToEnumString((Gender)Enduser.InvoiceAddress.Gender);
                        nvc.Add("enduser[invoiceAddress][gender]", gender);
                    }
                    if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.StreetName))
                    {
                        nvc.Add("enduser[invoiceAddress][streetName]", Enduser.InvoiceAddress.StreetName);
                    }
                    if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.StreetNumber))
                    {
                        nvc.Add("enduser[invoiceAddress][streetNumber]", Enduser.InvoiceAddress.StreetNumber);
                    }
                    if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.ZipCode))
                    {
                        nvc.Add("enduser[invoiceAddress][zipCode]", Enduser.InvoiceAddress.ZipCode);
                    }
                    if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.City))
                    {
                        nvc.Add("enduser[invoiceAddress][city]", Enduser.InvoiceAddress.City);
                    }
                    if (!ParameterValidator.IsEmpty(Enduser.InvoiceAddress.CountryCode))
                    {
                        nvc.Add("enduser[invoiceAddress][countryCode]", Enduser.InvoiceAddress.CountryCode);
                    }
                }

                //Company info
                if (Enduser.Company != null)
                {
                    if (!ParameterValidator.IsEmpty(Enduser.Company.CocNumber))
                    {
                        nvc.Add("enduser[company][cocNumber]", Enduser.Company.CocNumber);
                    }
                    if (!ParameterValidator.IsEmpty(Enduser.Company.CountryCode))
                    {
                        nvc.Add("enduser[company][countryCode]", Enduser.Company.CountryCode);
                    }
                    if (!ParameterValidator.IsEmpty(Enduser.Company.Name))
                    {
                        nvc.Add("enduser[company][name]", Enduser.Company.Name);
                    }
                    if (!ParameterValidator.IsEmpty(Enduser.Company.VatNumber))
                    {
                        nvc.Add("enduser[company][vatNumber]", Enduser.Company.VatNumber);
                    }
                }
            }

            // SaleData
            if (SalesData != null)
            {
                if (!ParameterValidator.IsNull(SalesData.DeliveryDate))
                {
                    nvc.Add("saleData[deliveryDate]", SalesData.DeliveryDate.ToString("dd-MM-yyyy"));
                }
                if (!ParameterValidator.IsNull(SalesData.InvoiceDate))
                {
                    nvc.Add("saleData[invoiceDate]", SalesData.InvoiceDate.ToString("dd-MM-yyyy"));
                }
                if (!ParameterValidator.IsNull(SalesData.OrderData))
                {
                    var i = 0;
                    foreach (var data in SalesData.OrderData)
                    {
                        ParameterValidator.IsNotNull(data.ProductId, "SalesData.OrderData.ProductId");
                        nvc.Add(string.Format("saleData[orderData][{0}][productId]", i), data.ProductId);

                        if (!ParameterValidator.IsNull(data.Description))
                        {
                            nvc.Add(string.Format("saleData[orderData][{0}][description]", i), data.Description);
                        }

                        ParameterValidator.IsNotNull(data.Price, "SalesData.OrderData.Price");
                        nvc.Add(string.Format("saleData[orderData][{0}][price]", i), data.Price.ToString());

                        ParameterValidator.IsNotNull(data.Quantity, "SalesData.OrderData.Quantity");
                        nvc.Add(string.Format("saleData[orderData][{0}][quantity]", i), data.Quantity.ToString());

                        if (!ParameterValidator.IsNull(data.VatCode))
                        {
                            nvc.Add(string.Format("saleData[orderData][{0}][vatCode]", i), EnumUtil.ToEnumString((TaxClass)data.VatCode));
                        }
                        if (!ParameterValidator.IsNull(data.ProductType))
                        {
                            nvc.Add(string.Format("saleData[orderData][{0}][productType]", i), EnumUtil.ToEnumString((ProductType)data.ProductType));
                        }
                        i++;
                    }
                }
            }

            // TestMode
            if (!ParameterValidator.IsNull(TestMode))
            {
                nvc.Add("testMode", ((bool)TestMode) ? "1" : "0");
            }

            return(nvc);
        }
Example #29
0
 public void ValidateString_GoodParameter_OK()
 {
     ParameterValidator.ValidateString("algo", "nameOfParameter");
 }
Example #30
0
        public static T SelectAdditionalCoverages <T>(this AdditionalCoveragesPage additionalCoveragesPage, AdditionalCoverages additionalCoverages = null, bool edit = false) where T : BasePage
        {
            ParameterValidator.ValidateNotNull(additionalCoveragesPage, "AdditionalCoveragesPage");
            if (additionalCoverages == null)
            {
                if (edit)
                {
                    AdditionalCoveragesOverviewPage additionalCoveragesOverviewPage = additionalCoveragesPage.SelectNoAdditionalCoverages <AdditionalCoveragesOverviewPage>();

                    // Verification
                    additionalCoveragesOverviewPage.ValidateAdditionalCoveragesOverviewPageDisplayed();
                }
                else
                {
                    SummaryPage summaryPage = additionalCoveragesPage.SelectNoAdditionalCoverages <SummaryPage>();
                    // Verification
                    summaryPage.ValidateSummaryPageDisplayed();
                }
            }
            else
            {
                if (additionalCoverages.AdditionalInterests != null)
                {
                    additionalCoveragesPage.SelectAdditionalCoverages(AdditionalCoveragesType.AdditionalInterests);
                }
                // else
                // {
                //     additionalCoveragesPage.DeselectAdditionalCoverages(AdditionalCoveragesType.AdditionalInterests);
                // }
                if (additionalCoverages.HiredCarNonOwned != null)
                {
                    additionalCoveragesPage.SelectAdditionalCoverages(AdditionalCoveragesType.HiredCarNonOwned);
                }
                else
                // {
                //     additionalCoveragesPage.DeselectAdditionalCoverages(AdditionalCoveragesType.HiredCarNonOwned);
                // }

                if (additionalCoverages.Cargo != null)
                {
                    additionalCoveragesPage.SelectAdditionalCoverages(AdditionalCoveragesType.Cargo);
                }
                // {
                //     additionalCoveragesPage.DeselectAdditionalCoverages(AdditionalCoveragesType.Cargo);
                // }

                if (additionalCoverages.TrailerInterchange != null)
                {
                    additionalCoveragesPage.SelectAdditionalCoverages(AdditionalCoveragesType.TrailerInterchange);
                }
                // {
                //     additionalCoveragesPage.DeselectAdditionalCoverages(AdditionalCoveragesType.TrailerInterchange);
                // }

                // Select NextButton
                //User navigates to the first entry screen of the first selected additional coverage (by oder)
                if (additionalCoverages.AdditionalInterests != null)
                {
                    // Select NextButton
                    AdditionalInterestCountsPage additionalInterestCountsPage = additionalCoveragesPage.SelectNextButton <AdditionalInterestCountsPage>();
                    //verification
                    additionalInterestCountsPage.ValidateAdditionalInterestCountsPageDisplayed();
                }
                else if (additionalCoverages.HiredCarNonOwned != null)
                {
                    // Select next button
                    LiabilityQuestions1Page liabilityQuestions1Page = additionalCoveragesPage.SelectNextButton <LiabilityQuestions1Page>();
                    // verification
                    liabilityQuestions1Page.ValidateLiabilityQuestions1PageDisplayed();
                }
                else if (additionalCoverages.Cargo != null)
                {
                    // Select Next Button
                    CargoLimitDeductiblePage cargoLimitDeductiblePage = additionalCoveragesPage.SelectNextButton <CargoLimitDeductiblePage>();
                    // Verification
                    cargoLimitDeductiblePage.ValidateCargoLimitDeductiblePageDisplayed();
                }
                else if (additionalCoverages.TrailerInterchange != null)
                {
                    // Select Next Button
                    TrailerInterchangePage trailerInterchangePage = additionalCoveragesPage.SelectNextButton <TrailerInterchangePage>();
                    // Verification
                    trailerInterchangePage.ValidateTrailerInterchangePageDisplayed();
                }
            }
            return((T)Activator.CreateInstance(typeof(T)));
        }
        public static Client Create(IRestClient restClient)
        {
            ParameterValidator.IsNotNull(restClient, "restClient");

            return(new Client(restClient));
        }
Example #32
0
        public static VehicleInfoPage EnterCustomerInformation(this EffectiveDatePage effectiveDatePage, CustomerInformation customerInformation)
        {
            ParameterValidator.ValidateNotNull(effectiveDatePage, "EffectiveDatePage");
            ParameterValidator.ValidateNotNull(customerInformation, "Customer Information");

            //1. Enter customer @effectivedate and select next
            DotNumberPage dotNumberPage = effectiveDatePage.SelectEffectiveDate(customerInformation.EffectiveDate).SelectNextButton();

            // verification
            dotNumberPage.ValidateDotNumberPageDisplayed();

            //2. Enter @DOTInfo
            EntityTypePage entityTypePage = dotNumberPage.EnterDotNumber(customerInformation.DotNumber);

            //3. Select @EntityType and select next
            BusinessInformationPage businessInformationPage = entityTypePage.SelectEntityType(customerInformation.EntityType)
                                                              .SelectNextButton();

            // verification
            businessInformationPage.ValidateBusinessInformationPageDisplayed();

            //4. If valid DOT was given, confrim business @name and @address and select next
            // If no Dot or invalid DOT was given, complete @name and @address and select next
            if (customerInformation.FilledOutBusinessInformation != null)
            {
                businessInformationPage.ValidateBusinessNameIsFilledOut(customerInformation.FilledOutBusinessInformation.CustomerName)
                .ValidateDBAIsFilledOut(customerInformation.FilledOutBusinessInformation.DBA)
                .ValidateAddressFieldsAreFilledOut(customerInformation.FilledOutBusinessInformation.Address);
            }

            if (customerInformation.BusinessInformation != null)
            {
                businessInformationPage.InputBusinessInformation(customerInformation.BusinessInformation);
            }

            PrimaryOfficerPage primaryOfficerPage = businessInformationPage.SelectNextButton();

            //verification
            primaryOfficerPage.ValidatePrimaryOfficerPageDisplayed();

            //5. Enter Primary officer information (@POName, @POAddress) and select next
            CustomerInfoPage customerInfoPage = new CustomerInfoPage();

            if (customerInformation.EntityType == "Individual")
            {
                // verification
                primaryOfficerPage.ValidatePrimaryOfficerNameAreFilledOut(customerInformation.POName).ValidatePrimaryOfficerNameDisabled();
                // Enter POAddress
                primaryOfficerPage.InputPrimaryOfficerAddress(customerInformation.POAddress).SelectNextButton();
            }
            else
            {
                //Enter POName and POAddress
                primaryOfficerPage.InputPrimaryOfficer(customerInformation.POName, customerInformation.POAddress).SelectNextButton();
            }

            //verification
            customerInfoPage.ValidateCustomerInfoPageDisplayed();

            //6. Enter @LiabilityLosses and select Next
            VehicleInfoPage vehicleInfoPage = customerInfoPage.EnterCustomerInfo(customerInformation.CustomerAdditionalInformation).SelectNextButton();

            //verification
            vehicleInfoPage.ValidateVehicleInfoPageDisplayed();
            return(vehicleInfoPage);
        }