private static void CheckUsage(SetParameter p) { var string1 = p.Options.First().ToString() + "87E32D67-330C-499D-BD4B-2AA681AF9D42"; p.TryDeserialiseValue(string1); Assert.That(p.Corrupted, Is.True); Assert.That(p.ValueAsString(), Is.EqualTo(string1)); var value1 = new ReadOnlySet <Guid>(p.Options.First()); var action1 = p.SetValueAction(value1); Assert.That(action1, Is.Not.Null); action1.Value.Redo(); Assert.That(p.SetValueAction(value1), Is.Null); CheckValue(p, value1); var value2 = new ReadOnlySet <Guid>(p.Options.First(), p.Options.ElementAt(1)); var action2 = p.SetValueAction(value2); Assert.That(action2, Is.Not.Null); action2.Value.Redo(); CheckValue(p, value2); action2.Value.Undo(); CheckValue(p, value1); action1.Value.Undo(); Assert.That(p.Corrupted, Is.True); Assert.That(p.ValueAsString(), Is.EqualTo(string1)); var string2 = p.Options.ElementAt(0) + "+" + p.Options.ElementAt(1); p.TryDeserialiseValue(string2); CheckValue(p, new ReadOnlySet <Guid>(p.Options.ElementAt(0), p.Options.ElementAt(1))); }
private static void CheckValue(SetParameter p, ReadOnlySet <Guid> value) { Assert.That(p.Corrupted, Is.False); Assert.That(p.Value, Is.EqualTo(value)); Assert.That(p.ValueAsString(), Is.EqualTo(string.Join("+", value.Select(a => a.ToString())))); Assert.That(p.DisplayValue((a, b) => null), Is.EqualTo(string.Join(" + ", value.Select(a => p.GetName(a)).OrderBy(a => a)))); //Names are displayed in alphabetical order }
/// <summary> /// Sets the 'Communication Unit' combo box to a specific value /// </summary> /// <param name="value">The value of the list item to select</param> /// <returns> /// <br>True: if the correct list item was selected</br> /// <br>False: if the item could not be selected, does not exist or another error occurred</br> /// </returns> public static bool Run(string value) { if (SetParameter.SetParameterValue(new CDICommDTMRepoElements().CommUnitCombobox, value)) { return(true); } return(false); }
public void Should_Append_Options(SetParameter setParameter, string expected) { //Given --> When var actual = setParameter.ToCommandLineArgument(); //Then Assert.Equal(expected, setParameter.ToCommandLineArgument()); }
/// <summary>Command SetParameter(007)</summary> /// <param name="setParameterType"></param> /// <param name="parameterValue"></param> private string CommandSetParameter(SetParameterType setParameterType, string parameterValue) { var parameter = new SetParameterParameter { ParameterValue = parameterValue, SetParameterType = setParameterType }; var commandText = new SetParameter().GetCommandText(parameter); UdpSocket.SendTo(Encoding.UTF8.GetBytes(commandText), TargetEndpoint); return(commandText); }
public SavedParameter(string key, T value, GetParameter getter, SetParameter setter) { Assert.IsNotNull(setter); Assert.IsNotNull(getter); m_Key = key; m_Loaded = false; m_Value = value; m_Setter = setter; m_Getter = getter; }
public void Should_Throw_If_Name_Is_Null_or_Empty() { // Given var setParameter = new SetParameter(); // When...Then var result = Record.Exception(() => setParameter.AppendCommandLineArgument(new StringBuilder())); // Then Assert.IsExceptionWithMessage <NullReferenceException>(result, "Name is required when using the SetParameter option."); }
public override string DisplayValue(Func <Id <LocalizedStringType>, Id <LocalizedText>, string> localize) { if (Corrupted) { return(ValueAsString()); } else { return(SetParameter.DisplayStringForSet(Value, GetName)); } }
public IEnumerable <SetParameter> GetValues(string options) { var tfsOptions = options.ToObject <TfsOptions>(); var tfsService = new TfsService(tfsOptions.Uri); var environmentVariables = tfsService.GetReleaseEnvironmentVariables( tfsOptions.Project, tfsOptions.Release, tfsOptions.Environment).Result; return(environmentVariables.Select(v => SetParameter.AsToken(v.Key, v.Value)).ToList()); }
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { int rowIndex = e.RowIndex; string selectValue = dataGridView1.Rows[rowIndex].Cells[0].Value.ToString(); SetParameter setParameter = new SetParameter(specifications.SetSpecificationsParameter); setParameter.Invoke(selectValue); } catch (Exception error) { B_GetMethod.LogWrite(error.ToString()); } }
public static void TestEmptyDefault() { var enumeration = TestEnumParameter.MockEnumeration1.Instance; string name = "a"; Id <Parameter> id = Id <Parameter> .Parse("0F10DB06-12E8-4FAC-9F76-53BE72D87EC5"); SetParameter p = new SetParameter(name, id, enumeration, ""); CheckConstruction(enumeration, name, id, p); Assert.That(p.Corrupted, Is.False); CheckValue(p, new ReadOnlySet <Guid>()); CheckUsage(p); }
public static void TestNullDefault() { var enumeration = TestEnumParameter.MockEnumeration1.Instance; string name = "a"; Id <Parameter> id = Id <Parameter> .Parse("0F10DB06-12E8-4FAC-9F76-53BE72D87EC5"); SetParameter p = new SetParameter(name, id, enumeration, null); CheckConstruction(enumeration, name, id, p); CheckValue(p, new ReadOnlySet <Guid>(enumeration.DefaultValue.Transformed(a => { throw new NotImplementedException(); }, a => a))); CheckUsage(p); }
public static void TestInvalidDefaultCannotParse() { var enumeration = TestEnumParameter.MockEnumeration2.Instance; string name = "b"; Id <Parameter> id = Id <Parameter> .Parse("B6FD1F35-1177-484E-8F42-731E389C57AC"); string def = "shane"; SetParameter p = new SetParameter(name, id, enumeration, def); CheckConstruction(enumeration, name, id, p); Assert.That(p.Corrupted, Is.True); Assert.That(p.ValueAsString(), Is.EqualTo(def)); CheckUsage(p); }
public static void TestInvalidDefaultGuidNotInOptions() { var enumeration = TestEnumParameter.MockEnumeration2.Instance; string name = "b"; Id <Parameter> id = Id <Parameter> .Parse("B6FD1F35-1177-484E-8F42-731E389C57AC"); string def = enumeration.Options.ElementAt(0).ToString() + "+" + "2BCD4F8F-73E0-4B57-86C7-8780C833B5C9"; SetParameter p = new SetParameter(name, id, enumeration, def); CheckConstruction(enumeration, name, id, p); Assert.That(p.Corrupted, Is.True); Assert.That(p.ValueAsString(), Is.EqualTo(def)); CheckUsage(p); }
public static void TestMultiGuidDefault() { var enumeration = TestEnumParameter.MockEnumeration1.Instance; string name = "a"; Id <Parameter> id = Id <Parameter> .Parse("0F10DB06-12E8-4FAC-9F76-53BE72D87EC5"); ReadOnlySet <Guid> def = new ReadOnlySet <Guid>(enumeration.Options.ElementAt(0), enumeration.Options.ElementAt(3), enumeration.Options.ElementAt(1)); SetParameter p = new SetParameter(name, id, enumeration, string.Join("+", def.Select(a => a.ToString()))); CheckConstruction(enumeration, name, id, p); Assert.That(p.Corrupted, Is.False); CheckValue(p, def); CheckUsage(p); }
public void Deploy(DeployOptions options) { try { var deployableProjects = this.BuildAndPublishSolution( build: !options.ExcludeBuild, parameteriseConnectionStrings: options.ParameteriseConnectionStrings, solutionFile: options.SolutionFile, platform: options.Platform, configuration: options.Configuration); var date = DateTime.Now; var applicationPath = new ApplicationService().GetApplicationDirectory(); var fileService = new FileService(); // Get list of IIS Express sites var iisExpressService = new IisExpressService(this.settings.AppCmdPath); var sites = iisExpressService.GetSites().ToList(); var nextSiteId = sites.Max(s => s.Id) + 1; foreach (var deployableProject in deployableProjects) { this.logger.Information($"Deploying '{deployableProject.ProjectName}'"); // Create a new IIS Express site var newSiteName = Guid.NewGuid().ToString().Replace("-", string.Empty); var newSitePhysicalPath = Path.Combine(applicationPath, $@"output\sites\{newSiteName}"); iisExpressService.AddSite( id: nextSiteId, name: newSiteName, bindings: $"http:/*:80:www.{newSiteName}.com", physicalPath: newSitePhysicalPath); // Copy package folder to application folder var outputProjectFolder = Path.Combine( applicationPath, $@"output\{date:yyyy-MM-dd}\{deployableProject.ProjectName}"); var packageFolder = Path.Combine( deployableProject.Folder, $@"obj\{options.Configuration}\Package"); var outputPackageFolder = Path.Combine(outputProjectFolder, "package"); fileService.CopyFiles(packageFolder, "*.*", outputPackageFolder); // Replace SetParameters.xml values including IIS Application name var pluginsFolder = Path.Combine(applicationPath, "plugins"); var valuesProvider = this.GetValuesProvider(pluginsFolder, options.ValueProviderId); if (valuesProvider == null) { throw new InvalidOperationException( $"The values provider '{options.ValueProviderId}' was not located. " + $"Check that the value provider assemblies are within a subfolder of the plugins folder at '{pluginsFolder}'"); } if (string.IsNullOrWhiteSpace(options.ValueProviderOptions)) { throw new InvalidOperationException("Unexpected empty value provider options provided"); } var setParametersValues = new List <SetParameter> { SetParameter.AsKeyed("IIS Web Application Name", newSiteName) }; var values = valuesProvider.GetValues(options.ValueProviderOptions).ToList(); if (values.GroupBy(v => v.Key).Any(g => g.Count() > 1)) { throw new InvalidOperationException( $"Value provider '{options.ValueProviderId}' returned one or more parameters that do not have distinct keys"); } foreach (var value in values) { var existingParameter = setParametersValues.FirstOrDefault(p => p.Key == value.Key); if (existingParameter != null) { continue; } setParametersValues.Add(value); } var setParametersFilePath = Path.Combine( outputPackageFolder, $"{deployableProject.ProjectName}.SetParameters.xml"); // TODO: make pre/post prefix configurable const string PrePostFix = "__"; var setParametersService = new SetParametersService(); setParametersService.TokenReplacement( setParametersFilePath, setParametersValues, PrePostFix); // Run MSDeploy deploy.cmd to deploy to the new IIS Express site var deployScriptFilePath = $"{setParametersFilePath.Replace("SetParameters.xml", string.Empty)}deploy.cmd"; setParametersService.Deploy(deployScriptFilePath, "/Y /L"); // Copy final Web.config file to deploy folder var webConfigPath = Path.Combine(newSitePhysicalPath, "Web.config"); var deployFolder = Path.Combine(outputProjectFolder, "deploy"); fileService.CopyFile(webConfigPath, deployFolder); // Clean up temporary IIS Express site // fileCopyService.DeleteFolder(newSitePhysicalPath); iisExpressService.DeleteSite(newSiteName); nextSiteId++; } this.logger.Information("Deploy complete."); } catch (Exception exception) { this.logger.Error($"An error occurred deploying: {exception}"); throw; } }
protected override string InnerValueAsString() { return(SetParameter.SerializeSet(Value)); }
protected override Tuple <ReadOnlySet <Guid>, bool> DeserializeValueInner(string value) { var result = SetParameter.StaticDeserialize(Enumeration.Select(e => e.Guid), value); return(result); }
protected override bool ValueValid(ReadOnlySet <Guid> value) { return(SetParameter.StaticValueValid(Enumeration.Select(e => e.Guid), value)); }
public GraphData(Id <NodeTemp> nodeId, Id <NodeTypeTemp> nodeTypeId, IEnumerable <NodeDataGeneratorParameterData> parameterData) { NodeId = nodeId; NodeTypeId = nodeTypeId; var allConnectorsDefinition = new ConnectorDefinitionData(null, null, null, null, false); var outputs = new List <Output>(); var parameters = new List <IParameter>(); DecimalParameter.Definition d = new DecimalParameter.Definition(null, null); ParameterType decimalType = ParameterType.Basic.Parse("721796b6-a242-4723-82e9-35201097e675"); ParameterType dynamicEnumType = ParameterType.Basic.Parse("6d2d52c8-5934-4ba8-8d4e-7081fe57f662"); DynamicEnumParameter.Source source = new DynamicEnumParameter.Source(); IEnumeration enumeration = new DummyEnumeration(); ParameterType integerEnumType = ParameterType.Basic.Parse("de108fdb-db50-4cd5-aad5-0ea791f04721"); IntegerParameter.Definition i = new IntegerParameter.Definition(null, null); AudioParameter = new AudioParameter("Audio", Id <Parameter> .Parse("3ac8d0ca-c9f6-4e06-b18c-c1366e1af7d3")); BooleanParameter = new BooleanParameter("Boolean", Id <Parameter> .Parse("0e12e8e3-4c95-43a5-a733-d2d1fbbb780c"), "false"); DecimalParameter = new DecimalParameter("Decimal", Id <Parameter> .Parse("765e616a-f165-4053-a15c-14ed593429af"), decimalType, d, "1.0"); DynamicEnumParameter = new DynamicEnumParameter("DynamicEnum", Id <Parameter> .Parse("7c5b019c-79d0-4ef0-b848-0a2c68908f34"), source, dynamicEnumType, "shnae", false); EnumParameter = new EnumParameter("Enum", Id <Parameter> .Parse("e576713b-5d45-48d0-8a4e-661f1fedcafd"), enumeration, enumeration.DefaultValue.ToString()); IntegerParameter = new IntegerParameter("Int", Id <Parameter> .Parse("275d75f3-fe4e-42b1-bfaf-e841ba591999"), integerEnumType, i, "1"); LocalizedStringParameter = new LocalizedStringParameter("Localized stirng", Id <Parameter> .Parse("f332e619-e9a3-421f-9851-d95a00b62da9"), ParameterType.Basic.Parse("4547dbf2-46cc-4c84-ac6e-81ab185575dc")); SetParameter = new SetParameter("Set", Id <Parameter> .Parse("2d6235ea-c8a1-447a-b9d8-692f6329be33"), enumeration, null); StringParameter = new StringParameter("string", Id <Parameter> .Parse("4752d30e-e1ab-47ba-bc15-b2e6ecfa5416")); StringParameter2 = new StringParameter("string2", Id <Parameter> .Parse("dcd4a349-b0a8-4fa3-8989-2d10469b1a17")); if (nodeTypeId == TYPE1) { outputs.Add(new Output(Id <TConnector> .Parse("0956c9d3-c230-49a2-874a-7e3747b58cff"), allConnectorsDefinition, this, null, DummyRules.Instance)); parameters.Add(AudioParameter); parameters.Add(BooleanParameter); parameters.Add(DecimalParameter); parameters.Add(DynamicEnumParameter); parameters.Add(EnumParameter); } else if (nodeTypeId == TYPE2) { outputs.Add(new Output(Id <TConnector> .Parse("da2b4ded-378e-4484-89f0-1328a42f00e3"), allConnectorsDefinition, this, null, DummyRules.Instance)); outputs.Add(new Output(Id <TConnector> .Parse("2bf2ca93-6b81-4a9a-814f-809a8bef332f"), allConnectorsDefinition, this, null, DummyRules.Instance)); parameters.Add(IntegerParameter); parameters.Add(LocalizedStringParameter); parameters.Add(SetParameter); parameters.Add(StringParameter); } else if (nodeTypeId == TYPE3) { outputs.Add(new Output(Id <TConnector> .Parse("c3f67c87-a3fd-428d-90a2-90cb87906eb2"), allConnectorsDefinition, this, null, DummyRules.Instance)); parameters.Add(StringParameter); parameters.Add(StringParameter2); } else { Assert.Fail("Unexpected Id"); } if (parameterData != null) { foreach (var data in parameterData) { parameters.Where(p => p.Id == data.Guid).Single().TryDeserialiseValue(data.Value); } } Connectors = outputs; Parameters = parameters; }
private static void CheckConstruction(IEnumeration enumeration, string name, Id <Parameter> id, SetParameter p) { Assert.That(p.Id, Is.EqualTo(id)); Assert.That(p.Name, Is.EqualTo(name)); Assert.That(p.TypeId, Is.EqualTo(ParameterType.ValueSetType.Of(enumeration.TypeId))); Assert.That(p.Options, Is.EquivalentTo(enumeration.Options)); foreach (var option in enumeration.Options) { Assert.That(p.GetName(option), Is.EqualTo(enumeration.GetName(option))); } }