public async Task GettingAllRecords_WithPageInformation_ReturnsMappedModels(int currentPage, int pageSize) { // Arrange var pageInformation = new PageInformation(currentPage, pageSize); var expectedRecords = InsolvenciesTestData.CreateInsolvenciesExpecteds(pageInformation).ToList(); var insolvencyRecords = InsolvenciesTestData.CreateInsolvenciesActuals(); var context = TestDbContext.CreateContextWithSeededData(insolvencyRecords); var operationDateProvider = new Mock <IOperationDateProvider>(); operationDateProvider.Setup(x => x.GetOperationDate()).Returns(DateTime.Now); IOptions <RetentionOptions> retentionOptions = new ConfigurationOption( new RetentionOptions() { RetentionPeriod = 10, CutOffPeriod = 6 }); var insolvencyOrdersFilteredBaseData = new InsolvencyOrderFilterContext(retentionOptions, operationDateProvider.Object); var disputesFilteredBaseData = new DisputeFilterContext(retentionOptions, operationDateProvider.Object); var insolvencyOrdersRepository = new InsolvencyOrdersRepository( context, insolvencyOrdersFilteredBaseData, disputesFilteredBaseData, mockTelemetryClient.Object); // Act var actualRecords = (await insolvencyOrdersRepository.GetAllAsync(pageInformation)).ToList(); // Assert CollectionAssert.AreEqual(expectedRecords, actualRecords, new InsolvencyModelComparer()); }
private List <ConfigurationOption> getNonChildrenOptions() { List <ConfigurationOption> options = GlobalState.varModel.getOptions(); List <ConfigurationOption> optionsToRemove = new List <ConfigurationOption>(); optionsToRemove.Add(currentOption); while (optionsToRemove.Count > 0) { ConfigurationOption opt = optionsToRemove[0]; options.Remove(opt); foreach (ConfigurationOption child in GlobalState.varModel.BinaryOptions) { if (child.Parent != null && child.Parent.Equals(opt)) { optionsToRemove.Add(child); } } optionsToRemove.Remove(opt); } return(options); }
/// <summary> /// Initializes the form and its data. /// </summary> private void initializeForm() { List <ConfigurationOption> opts = new List <ConfigurationOption>(); foreach (ConfigurationOption o in GlobalState.varModel.getOptions()) { if (o.Children.Count > 1) { opts.Add(o); } } selectedOptionComboBox.Items.AddRange(opts.Where(x => x is BinaryOption).ToArray()); selectedOptionComboBox.SelectedIndex = 0; foreach (string c in GlobalState.varModel.BinaryConstraints) { ConfigurationOption opt = getAltGroup(c); if (opt != null && !currAltGroups.Contains(opt)) { currAltGroups.Add(opt); currAltGroupsListBox.Items.Add(opt); } } }
public StatusForm() { InitializeComponent(); Program.InstallUtils.ConfigurationEventPre += new EventHandler<ConfigurationEventArgs>(this.ConfigurationPreEventHandler); Program.InstallUtils.ConfigurationEventPost += new EventHandler<ConfigurationEventArgs>(this.ConfigurationPostEventHandler); Program.InstallUtils.ConfigurationEventException += new EventHandler<ConfigurationEventArgs>(this.ConfigurationEventException); this.operationOption = ConfigurationOption.Install; this.integratedOrgs = Program.InstallUtils.Arguments[Constants.IntegratedOrganizations] as List<OrganizationDetail>; this.FormClosing += new FormClosingEventHandler(this.StatusForm_FormClosing); }
public StatusForm() { InitializeComponent(); Program.InstallUtils.ConfigurationEventPre += new EventHandler <ConfigurationEventArgs>(this.ConfigurationPreEventHandler); Program.InstallUtils.ConfigurationEventPost += new EventHandler <ConfigurationEventArgs>(this.ConfigurationPostEventHandler); Program.InstallUtils.ConfigurationEventException += new EventHandler <ConfigurationEventArgs>(this.ConfigurationEventException); this.operationOption = ConfigurationOption.Install; this.integratedOrgs = Program.InstallUtils.Arguments[Constants.IntegratedOrganizations] as List <OrganizationDetail>; this.FormClosing += new FormClosingEventHandler(this.StatusForm_FormClosing); }
private void ProcessesCommandAddOption( bool verbose, string dir, string name, string description) { try { if (verbose) { Logger.EnableVerbose(); } if (!PlugInConfigurationValidation.ValidateElementName(name)) { Logger.Error( "The name is invalid '{0}'- " + PlugInConfigurationValidation.ValidCharactersMessage, name); return; } string file = GetFileName(dir); using var fileStream = File.Open(file, FileMode.Open, FileAccess.ReadWrite); var logger = new BridgeLogger(); var existingConfiguration = PlugInConfigurationSerializer.ReadFromStream(fileStream, logger); if (existingConfiguration == null) { return; } ConfigurationOption newOption = new ConfigurationOption(name, description); var options = new HashSet <ConfigurationOption>(existingConfiguration.Options); if (!options.Add(newOption)) { Logger.Error("Option {0} already exists.", name); return; } fileStream.Position = 0; var configuration = new PlugInConfiguration( existingConfiguration.PlugInName, existingConfiguration.Version, options); PlugInConfigurationSerializer.WriteToStream(configuration, fileStream, logger); Logger.Information($"Added option {name}."); } catch (Exception e) { _parsingException = e; } }
/// <summary> /// Checks if the current data is valid. /// /// The data is valid if /// - the feature name is neither empty, already used or contains invalid characters /// - the range of values contains valid numbers and form a valid range and /// - the step function is in the right form /// /// If the data is not valid, the option cannot be added and an error message will be /// displayed. /// </summary> private void checkValidityOfData() { // Check if feature name is empty if (featureNameTextBox.Text == "") { errorLabel.Text = ERROR_NAME_EMPTY; errorLabel.Visible = true; addOptionButton.Enabled = false; return; } // Check if feature name already exists if (GlobalState.varModel.getOption(featureNameTextBox.Text) != null) { errorLabel.Text = ERROR_NAME_EXISTS; errorLabel.Visible = true; addOptionButton.Enabled = false; return; } // Check if feature name is invalid if (featureNameTextBox.Text != ConfigurationOption.removeInvalidCharsFromName(featureNameTextBox.Text)) { errorLabel.Text = ERROR_INVALID_NAME; errorLabel.Visible = true; addOptionButton.Enabled = false; return; } if (numericRadioButton.Checked) { // Check if the range of values is invalid if (!isRangeValid()) { errorLabel.Text = ERROR_INVALID_RANGE; errorLabel.Visible = true; addOptionButton.Enabled = false; return; } // Check if step function is valid if (stepSizeCheckBox.Checked && !isStepSizeValid()) { errorLabel.Text = ERROR_INVALID_STEP_FUNCTION; errorLabel.Visible = true; addOptionButton.Enabled = false; return; } } errorLabel.Visible = false; addOptionButton.Enabled = true; }
/// <summary> /// Invokes if the 'Add option'-button was pressed. /// /// This method will add the option the the current variability model and /// will dispose this form. /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event</param> private void addOptionButton_Click(object sender, EventArgs e) { ConfigurationOption newOption = null; if (numericRadioButton.Checked) { newOption = new NumericOption(GlobalState.varModel, this.featureNameTextBox.Text); ((NumericOption)newOption).Min_value = Convert.ToDouble(minValueTextBox.Text); ((NumericOption)newOption).Max_value = Convert.ToDouble(maxValueTextBox.Text); if (stepSizeCheckBox.Checked) { ((NumericOption)newOption).StepFunction = new InfluenceFunction( stepSizeTextBox.Text == "" ? "n + 1" : stepSizeTextBox.Text, (NumericOption)newOption); } else { ((NumericOption)newOption).StepFunction = new InfluenceFunction("n + 1", (NumericOption)newOption); } if (numOptionalCheckBox.Checked) { ((NumericOption)newOption).Optional = true; int flag; if (!int.TryParse(deselectedFlagTextBox.Text, out flag)) { MessageBox.Show("Invalid deselection flag. Value must be integer."); return; } else { ((NumericOption)newOption).setOptional(true, flag); } } } else { newOption = new BinaryOption(GlobalState.varModel, this.featureNameTextBox.Text); ((BinaryOption)newOption).Optional = optionalCheckBox.Checked; } if (prePostCheckBox.Checked) { newOption.Prefix = prefixTextBox.Text; newOption.Postfix = postfixTextBox.Text; } newOption.OutputString = outputStringTextBox.Text; newOption.Parent = GlobalState.varModel.getOption(this.parentComboBox.Text); GlobalState.varModel.addConfigurationOption(newOption); this.Close(); }
public void ParsesConfigurationOptionSucessfully_Value() { // Arrange const string key = "key"; const string value = "value"; string configLine = $"{key}={value}"; // Act var result = new ConfigurationOption(configLine); // Assert Assert.Equal(result.Value, value); }
protected void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Button == MouseButtons.Right) { TreeNode tn = e.Node; ConfigurationOption f = (ConfigurationOption)tn.Tag; String featureName = (f == null ? null : f.Name); NewFeatureDialog dlg = new NewFeatureDialog(featureName); dlg.ShowDialog(); InitTreeView(); } }
/// <summary> /// Constructor of this class. /// /// Initializes all necessary information of this form. The combo box of /// the form will be set the specified option. If the specified option is /// null or not selectable, the combo box will start at the first element. /// </summary> /// <param name="opt">Initial selected option</param> public AlternativeGroupDialog(ConfigurationOption opt) { InitializeComponent(); initializeForm(); if (selectedOptionComboBox.Items.Count > 0) { if (opt != null && selectedOptionComboBox.Items.Contains(opt)) selectedOptionComboBox.SelectedItem = opt; else selectedOptionComboBox.SelectedIndex = 0; selectedOptionAddButton.Enabled = !currAltGroups.Contains( (ConfigurationOption) selectedOptionComboBox.SelectedItem); } else selectedOptionAddButton.Enabled = false; }
protected void insertSubElements(ConfigurationOption element, TreeNode t, bool bParentChecked) { bool bChecked = false; t.Tag = element; if (element is SPLConqueror_Core.NumericOption) t.ForeColor = Color.Red; //rekursiv die unterelemente einfügen element.updateChildren(); foreach (ConfigurationOption elem in element.Children) { TreeNode tn = new TreeNode(elem.Name); insertSubElements(elem, tn, bChecked); t.Nodes.Add(tn); } }
private bool ParseArguments() { ProjectPath = GetProjectPath(Options.ProjectArgument.Value); Configuration = ConfigurationOption.Value() ?? DotNet.Cli.Utils.Constants.DefaultConfiguration; if (FrameworkOption.HasValue()) { TargetFramework = NuGetFramework.Parse(FrameworkOption.Value()); } if (!OutputPathOption.HasValue()) { Application.Error.WriteLine($"Option {OutputPathOption.Template} does not have a value."); return(false); } OutputPath = OutputPathOption.Value(); return(true); }
public async Task GettingRecordsByResidenceId_WithSeededInsolvenciesRecords_ReturnsMappedModels(int residenceId) { // Arrange var pageInformation = new PageInformation(1, 100); var expecteds = InsolvenciesTestData.GetExpectedsByResidenceId(residenceId); var insolvencyRecords = InsolvenciesTestData.CreateInsolvenciesActuals(); var context = TestDbContext.CreateContextWithSeededData(insolvencyRecords); var operationDateProvider = new Mock <IOperationDateProvider>(); operationDateProvider.Setup(x => x.GetOperationDate()).Returns(DateTime.Now); IOptions <RetentionOptions> retentionOptions = new ConfigurationOption( new RetentionOptions() { RetentionPeriod = 10, CutOffPeriod = 6 }); var insolvencyOrdersFilteredBaseData = new InsolvencyOrderFilterContext(retentionOptions, operationDateProvider.Object); var disputesFilteredBaseData = new DisputeFilterContext(retentionOptions, operationDateProvider.Object); var insolvencyOrdersRepository = new InsolvencyOrdersRepository( context, insolvencyOrdersFilteredBaseData, disputesFilteredBaseData, mockTelemetryClient.Object); // Act var actuals = await insolvencyOrdersRepository.GetResultsByAsync( residenceId, record => record.ResidenceId, pageInformation); // Assert CollectionAssert.AreEqual( expecteds.OrderBy(x => x.InsolvencyOrderId).ToList(), actuals.OrderBy(x => x.InsolvencyOrderId).ToList(), new InsolvencyModelComparer()); }
protected void insertSubElements(ConfigurationOption element, TreeNode t, bool bParentChecked) { bool bChecked = false; t.Tag = element; if (element is SPLConqueror_Core.NumericOption) t.ForeColor = Color.Red; //else //{ // if (element.getCommulatives().Count > 0) // t.ForeColor = Color.LightBlue; // else // { // if (element.isOptional()) // t.ForeColor = Color.Green; // //check optional childs if parent already checked // else if (bParentChecked) // { // bChecked = true; // t.Checked = true; // } // } //} //rekursiv die unterelemente einfügen element.updateChildren(); foreach (ConfigurationOption elem in element.Children) { TreeNode tn = new TreeNode(elem.Name); insertSubElements(elem, tn, bChecked); t.Nodes.Add(tn); } }
public void deleteOption(ConfigurationOption toDelete) { // Removing all children List<ConfigurationOption> children = new List<ConfigurationOption>(); foreach (ConfigurationOption opt in toDelete.Children) children.Add(opt); foreach (ConfigurationOption child in children) deleteOption(child); // Removing option from other options foreach (ConfigurationOption opt in getOptions()) { for (int i = opt.Excluded_Options.Count - 1; i >= 0; i--) { if (opt.Excluded_Options[i].Contains(toDelete)) opt.Excluded_Options.RemoveAt(i); } for (int i = opt.Implied_Options.Count - 1; i >= 0; i--) { if (opt.Implied_Options[i].Contains(toDelete)) opt.Implied_Options.RemoveAt(i); } } // Removing option from constraints booleanConstraints.RemoveAll(x => x.Contains(toDelete.ToString())); nonBooleanConstraints.RemoveAll(x => x.ToString().Contains(toDelete.ToString())); toDelete.Parent.Children.Remove(toDelete); if (toDelete is BinaryOption) binaryOptions.Remove((BinaryOption)toDelete); else if (toDelete is NumericOption) numericOptions.Remove((NumericOption)toDelete); else throw new Exception("An illegal option was found while deleting."); }
/// <summary> /// Adds a configuration option to the variability model. /// The method checks whether an option with the same name already exists and whether invalid characters are within the name /// </summary> /// <param name="option">The option to be added to the variability model.</param> /// <returns>True if the option was added to the model, false otherwise</returns> public bool addConfigurationOption(ConfigurationOption option) { if (option.Name.Contains('-') || option.Name.Contains('+')) return false; // the vitrual root configuration option does not have to be added to the variability model. if (option.Name.Equals("root")) return true; foreach (var opt in binaryOptions) { if (opt.Name.Equals(option.Name)) return false; } foreach (var opt in numericOptions) { if (opt.Name.Equals(option.Name)) return false; } if (this.hasOption(option.ParentName)) option.Parent = this.getOption(option.ParentName); //Every option must have a parent if (option.Parent == null) option.Parent = this.root; if (option is BinaryOption) this.binaryOptions.Add((BinaryOption)option); else this.numericOptions.Add((NumericOption)option); // create Index optionToIndex.Add(optionToIndex.Count, option); indexToOption.Add(option, indexToOption.Count); return true; }
public void deleteOption(ConfigurationOption toDelete) { throw new NotImplementedException(); }
/// <summary> /// Adds a configuration option to the variability model. /// The method checks whether an option with the same name already exists and whether invalid characters are within the name /// </summary> /// <param name="option">The option to be added to the variability model.</param> /// <returns>True if the option was added to the model, false otherwise</returns> public bool addConfigurationOption(ConfigurationOption option) { if (option.Name.Contains('-') || option.Name.Contains('+')) return false; // the vitrual root configuration option does not have to be added to the variability model. if (option.Name.Equals("root")) return true; foreach (var opt in binaryOptions) { if (opt.Name.Equals(option.Name)) return false; } foreach (var opt in numericOptions) { if (opt.Name.Equals(option.Name)) return false; } //Every option must have a parent if (option.Parent == null) option.Parent = this.root; if(parentChildRelationships.ContainsKey(option.Parent)) parentChildRelationships[option.Parent].Add(option); else { List<ConfigurationOption> childs = new List<ConfigurationOption>(); childs.Add(option); parentChildRelationships.Add(option.Parent,childs); } if (option is BinaryOption) this.binaryOptions.Add((BinaryOption)option); else this.numericOptions.Add((NumericOption)option); return true; }
/// <summary> /// Copies the existing <c>ObjectProvider</c> configuration files to a company specific directory /// </summary> /// <param name="option">The current <c>ConfigurationOption</c> for this configuration run</param> internal void SetupCompanyConfig(ConfigurationOption option) { if (option == ConfigurationOption.Install) { // Create a company specific directory for the configuration files DirectoryInfo dir = Directory.CreateDirectory(this.GetConfigPath(true)); this.PublishPreConfigurationMessage(string.Format(CultureInfo.CurrentCulture, Resources.StartCopyingConfigFileMessage, dir.FullName)); // Copy the existing configuration files to the new directory and set their attributes so they can be updated later foreach (string fileName in Directory.GetFiles(this.GetConfigPath(false))) { File.Copy(fileName, Path.Combine(dir.FullName, Path.GetFileName(fileName)), true); File.SetAttributes(Path.Combine(dir.FullName, Path.GetFileName(fileName)), FileAttributes.Normal); } this.PublishPostConfigurationMessage(FormattedString(Resources.FinishedCopyingConfigFileMessage)); } else { // This is a remove operation and we need to delete the company specific directory and configuration files this.PublishPreConfigurationMessage(string.Format(CultureInfo.CurrentCulture, Resources.StartDeletingConfigFileMessage, this.GetConfigPath(true))); if (Directory.Exists(this.GetConfigPath(true))) { Directory.Delete(this.GetConfigPath(true), true); } this.PublishPostConfigurationMessage(FormattedString(Resources.FinishedDeletingConfigFileMessage)); } }
/// <summary> /// Returns whether the influence function coints a specific configuration option. /// </summary> /// <param name="option"></param> /// <returns></returns> public bool containsOption(ConfigurationOption option) { if(this.participatingBoolOptions.Contains(option)) return true; if(this.participatingNumOptions.Contains(option)) return true; return false; }
//checks if the element is already present in the list private bool testDependencyOccurance(List<ConfigurationOption> depedenciesToAdd, ConfigurationOption pairWiseDepedency) { //List<Element> pairWiseParents = pairWiseDepedency.getDerivativeParents(); //foreach (Element current in depedenciesToAdd) //{ // if (pairWiseDepedency.getDerivativeParents().Count != current.getDerivativeParents().Count) // continue; // bool sameElement = true; // foreach (Element parent in current.getDerivativeParents())//should be enough, because both elements (current and pairWise) have the same number of parents // { // if (!pairWiseParents.Contains(parent)) // { // sameElement = false; // break; // } // } // if (sameElement) // return false; //} return true; }
//Checks if there is already an existing dependencies with the same parents private bool isAlreadyExistingDependencies(ConfigurationOption current) { //foreach (Element dependency in fm.getAllElements()) //{ // if (dependency.getType() == "derivative" && dependency.getDerivativeParents().Count == current.getDerivativeParents().Count) // { // bool sameElement = true; // foreach (Element parent in current.getDerivativeParents()) // { // if (!dependency.getDerivativeParents().Contains(parent)) // { // sameElement = false; // break; // } // } // if (sameElement) // return true; // } //} return false; }
/// <summary> /// Creates a tree node out of the specified option. /// /// While doing that, all children of this option (according to the variability model) will be /// added as children of this node. /// </summary> /// <param name="val">Option that is about to be inserted into the tree view. Must not be null.</param> /// <returns>The corresponding tree node ready for insertion.</returns> private TreeNode insertIntoTreeView(ConfigurationOption val) { if (val == null) throw new ArgumentException("Parameter val must not be null!"); List<TreeNode> functionChildren = new List<TreeNode>(); // Creating all nodes of the children foreach (ConfigurationOption child in val.Children) functionChildren.Add(insertIntoTreeView(child)); // Creating this node and setting the correct state of this node TreeNode current = new TreeNode(val.Name, functionChildren.ToArray()); if (currentModel.BinaryOptions.Contains(val) && !((BinaryOption)val).Optional && !((BinaryOption)val).hasAlternatives()) { current.Checked = true; current.BackColor = deactivatedColor; } else if (currentModel.NumericOptions.Contains(val)) current.Checked = true; return current; }