/// <summary> /// Update value-set for a not-compound parameter. /// </summary> /// <param name="valueSet">The value set to update</param> /// <param name="row">The value row containing the information. If null the data is retrieved from the current row.</param> /// <remarks> /// If <paramref name="row"/> is null, it means the parameter is not compound, not option dependent and not state dependent. /// </remarks> private void UpdateSimpleValueSet(ParameterSubscriptionValueSet valueSet, ParameterValueBaseRowViewModel row = null) { valueSet.ValueSwitch = row == null ? this.Switch.Value : row.Switch.Value; valueSet.Manual = row == null ? new ValueArray <string>(new List <string> { ValueSetConverter.ToValueSetString(this.Manual, this.ParameterType) }) : new ValueArray <string>(new List <string> { ValueSetConverter.ToValueSetString(row.Manual, this.ParameterType) }); }
/// <summary> /// Update value-set for a not-compound parameter. /// </summary> /// <param name="valueSet">The value set to update</param> /// <param name="row">The value row containing the information. If null the data is retrieved from the current row.</param> /// <remarks> /// If <paramref name="row"/> is null, it means the parameter is not compound, not option dependent and not state dependent. /// </remarks> private void UpdateScalarValueSet(ParameterValueSetBase valueSet, ParameterValueBaseRowViewModel row = null) { valueSet.ValueSwitch = row == null ? this.Switch.Value : row.Switch.Value; valueSet.Computed = row == null ? new ValueArray <string>(new List <string> { this.Computed }) : new ValueArray <string>(new List <string> { row.Computed }); valueSet.Manual = row == null ? new ValueArray <string>(new List <string> { this.Manual.ToValueSetString(this.ParameterType) }) : new ValueArray <string>(new List <string> { row.Manual.ToValueSetString(this.ParameterType) }); valueSet.Reference = row == null ? new ValueArray <string>(new List <string> { this.Reference.ToValueSetString(this.ParameterType) }) : new ValueArray <string>(new List <string> { ValueSetConverter.ToValueSetString(row.Reference, this.ParameterType) }); }
public void VerifyThatRowBuiltCorrectly() { var row = new ParameterRowViewModel(this.cptParameter, this.session.Object, null); var option1Row = row.ContainedRows.OfType <ParameterOptionRowViewModel>().Single(x => x.ActualOption == this.option1); var option2Row = row.ContainedRows.OfType <ParameterOptionRowViewModel>().Single(x => x.ActualOption == this.option2); var o1s1Row = option1Row.ContainedRows.OfType <ParameterStateRowViewModel>() .Single(x => x.ActualState == this.actualState1); var o1s2Row = option1Row.ContainedRows.OfType <ParameterStateRowViewModel>() .Single(x => x.ActualState == this.actualState2); var o2s1Row = option2Row.ContainedRows.OfType <ParameterStateRowViewModel>() .Single(x => x.ActualState == this.actualState1); var o2s2Row = option2Row.ContainedRows.OfType <ParameterStateRowViewModel>() .Single(x => x.ActualState == this.actualState2); var o1s1c1Row = o1s1Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().First(); var o1s1c2Row = o1s1Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().Last(); var o1s2c1Row = o1s2Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().First(); var o1s2c2Row = o1s2Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().Last(); var o2s1c1Row = o2s1Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().First(); var o2s1c2Row = o2s1Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().Last(); var o2s2c1Row = o2s2Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().First(); var o2s2c2Row = o2s2Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().Last(); // option row Assert.IsFalse(option1Row.IsEditable()); Assert.IsFalse(option2Row.IsEditable()); // state row Assert.IsFalse(o1s1Row.IsEditable()); Assert.IsFalse(o1s2Row.IsEditable()); Assert.IsFalse(o2s1Row.IsEditable()); Assert.IsFalse(o2s2Row.IsEditable()); // component row Assert.IsTrue(o1s1c1Row.IsEditable()); Assert.IsTrue(o1s2c1Row.IsEditable()); Assert.IsTrue(o2s1c1Row.IsEditable()); Assert.IsTrue(o2s2c1Row.IsEditable()); o1s1c1Row.Switch = ParameterSwitchKind.REFERENCE; o1s1c2Row.Switch = ParameterSwitchKind.REFERENCE; o1s2c1Row.Switch = ParameterSwitchKind.REFERENCE; o1s2c2Row.Switch = ParameterSwitchKind.REFERENCE; o2s1c1Row.Switch = ParameterSwitchKind.REFERENCE; o2s1c2Row.Switch = ParameterSwitchKind.REFERENCE; o2s2c1Row.Switch = ParameterSwitchKind.REFERENCE; o2s2c2Row.Switch = ParameterSwitchKind.REFERENCE; o1s1c2Row.Reference = new ReactiveList <EnumerationValueDefinition> { this.enum1 }; o1s2c2Row.Reference = new ReactiveList <EnumerationValueDefinition> { this.enum1 }; o2s1c2Row.Reference = new ReactiveList <EnumerationValueDefinition> { this.enum2 }; o2s2c2Row.Reference = new ReactiveList <EnumerationValueDefinition> { this.enum2 }; var o1s1Set = this.cptParameter.ValueSet.Single(x => x.ActualOption == this.option1 && x.ActualState == this.actualState1); var o1s2Set = this.cptParameter.ValueSet.Single(x => x.ActualOption == this.option1 && x.ActualState == this.actualState2); var o2s1Set = this.cptParameter.ValueSet.Single(x => x.ActualOption == this.option2 && x.ActualState == this.actualState1); var o2s2Set = this.cptParameter.ValueSet.Single(x => x.ActualOption == this.option2 && x.ActualState == this.actualState2); row.UpdateValueSets(o1s1Set); row.UpdateValueSets(o1s2Set); row.UpdateValueSets(o2s1Set); row.UpdateValueSets(o2s2Set); Assert.AreEqual(o1s1Set.ValueSwitch, o1s1c1Row.Switch); Assert.AreEqual(o1s2Set.ValueSwitch, o1s2c1Row.Switch); Assert.AreEqual(o2s1Set.ValueSwitch, o2s1c1Row.Switch); Assert.AreEqual(o2s2Set.ValueSwitch, o2s2c1Row.Switch); Assert.AreEqual(o1s1Set.Reference[0], o1s1c1Row.Reference); Assert.AreEqual(o1s2Set.Reference[0], o1s2c1Row.Reference); Assert.AreEqual(o2s1Set.Reference[0], o2s1c1Row.Reference); Assert.AreEqual(o2s2Set.Reference[0], o2s2c1Row.Reference); Assert.AreEqual(o1s1Set.Reference[1], ValueSetConverter.ToValueSetString(o1s1c2Row.Reference, o1s1c2Row.ParameterType)); Assert.AreEqual(o1s2Set.Reference[1], ValueSetConverter.ToValueSetString(o1s2c2Row.Reference, o1s2c2Row.ParameterType)); Assert.AreEqual(o2s1Set.Reference[1], ValueSetConverter.ToValueSetString(o2s1c2Row.Reference, o2s1c2Row.ParameterType)); Assert.AreEqual(o2s2Set.Reference[1], ValueSetConverter.ToValueSetString(o2s2c2Row.Reference, o2s2c2Row.ParameterType)); }
public void VerifyThatRowIsBuiltCorrectlyCompoundNoOptionWithState() { this.cptParameter.IsOptionDependent = false; this.cptParameter.ValueSet.Clear(); this.valueset1.ActualOption = null; this.valueset2.ActualOption = null; this.cptParameter.ValueSet.Add(this.valueset1); this.cptParameter.ValueSet.Add(this.valueset2); this.subscription = new ParameterSubscription(Guid.NewGuid(), null, this.uri); this.cptParameter.ParameterSubscription.Add(subscription); this.subscription.ValueSet.Add(new ParameterSubscriptionValueSet(Guid.NewGuid(), null, this.uri) { SubscribedValueSet = this.valueset1 }); this.subscription.ValueSet.Add(new ParameterSubscriptionValueSet(Guid.NewGuid(), null, this.uri) { SubscribedValueSet = this.valueset2 }); var row = new ParameterSubscriptionRowViewModel(this.subscription, this.session.Object, null); var s1Row = row.ContainedRows.OfType <ParameterStateRowViewModel>().Single(x => x.ActualState == this.actualState1); var s2Row = row.ContainedRows.OfType <ParameterStateRowViewModel>().Single(x => x.ActualState == this.actualState2); var s1c1Row = s1Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().First(); var s1c2Row = s1Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().Last(); var s2c1Row = s2Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().First(); var s2c2Row = s2Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().Last(); // state row Assert.IsFalse(s1Row.IsEditable()); Assert.IsFalse(s1Row.IsEditable()); // component row Assert.IsTrue(s1c1Row.IsEditable()); Assert.IsTrue(s1c2Row.IsEditable()); Assert.IsTrue(s2c1Row.IsEditable()); Assert.IsTrue(s2c2Row.IsEditable()); s1c1Row.Switch = ParameterSwitchKind.MANUAL; s1c2Row.Switch = ParameterSwitchKind.MANUAL; s2c1Row.Switch = ParameterSwitchKind.MANUAL; s2c2Row.Switch = ParameterSwitchKind.MANUAL; s1c2Row.Manual = new ReactiveList <EnumerationValueDefinition> { this.enum1 }; s2c2Row.Manual = new ReactiveList <EnumerationValueDefinition> { this.enum2 }; var s1Set = this.subscription.ValueSet.Single(x => x.ActualState == this.actualState1); var s2Set = this.subscription.ValueSet.Single(x => x.ActualState == this.actualState2); row.UpdateValueSets(this.subscription); Assert.AreEqual(s1Set.ValueSwitch, s1c1Row.Switch); Assert.AreEqual(s2Set.ValueSwitch, s2c2Row.Switch); Assert.AreEqual(s1Set.Manual[0], s1c1Row.Manual); Assert.AreEqual(s2Set.Manual[0], s2c1Row.Manual); Assert.AreEqual(s1Set.Manual[1], ValueSetConverter.ToValueSetString(s1c2Row.Manual, s1c2Row.ParameterType)); Assert.AreEqual(s2Set.Manual[1], ValueSetConverter.ToValueSetString(s2c2Row.Manual, s2c2Row.ParameterType)); }
public void VerifyThatRowIsBuiltCorrectlyCompoundOptionNoState() { this.cptParameter.StateDependence = null; this.cptParameter.ValueSet.Clear(); this.valueset1.ActualState = null; this.valueset3.ActualState = null; this.cptParameter.ValueSet.Add(this.valueset1); this.cptParameter.ValueSet.Add(this.valueset3); this.subscription = new ParameterSubscription(Guid.NewGuid(), null, this.uri); this.cptParameter.ParameterSubscription.Add(subscription); this.subscription.ValueSet.Add(new ParameterSubscriptionValueSet(Guid.NewGuid(), null, this.uri) { SubscribedValueSet = this.valueset1 }); this.subscription.ValueSet.Add(new ParameterSubscriptionValueSet(Guid.NewGuid(), null, this.uri) { SubscribedValueSet = this.valueset3 }); var row = new ParameterSubscriptionRowViewModel(this.subscription, this.session.Object, null); var option1Row = row.ContainedRows.OfType <ParameterOptionRowViewModel>().Single(x => x.ActualOption == this.option1); var option2Row = row.ContainedRows.OfType <ParameterOptionRowViewModel>().Single(x => x.ActualOption == this.option2); var o1c1Row = option1Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().First(); var o1c2Row = option1Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().Last(); var o2c1Row = option2Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().First(); var o2c2Row = option2Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().Last(); // option row Assert.IsFalse(option1Row.IsEditable()); Assert.IsFalse(option1Row.IsEditable()); // component row Assert.IsTrue(o1c1Row.IsEditable()); Assert.IsTrue(o1c2Row.IsEditable()); Assert.IsTrue(o2c1Row.IsEditable()); Assert.IsTrue(o2c2Row.IsEditable()); o1c1Row.Switch = ParameterSwitchKind.MANUAL; o1c2Row.Switch = ParameterSwitchKind.MANUAL; o2c1Row.Switch = ParameterSwitchKind.MANUAL; o2c2Row.Switch = ParameterSwitchKind.MANUAL; o1c2Row.Manual = new ReactiveList <EnumerationValueDefinition> { this.enum1 }; o2c2Row.Manual = new ReactiveList <EnumerationValueDefinition> { this.enum2 }; var o1Set = this.subscription.ValueSet.Single(x => x.ActualOption == this.option1); var o2Set = this.subscription.ValueSet.Single(x => x.ActualOption == this.option2); row.UpdateValueSets(this.subscription); Assert.AreEqual(o1Set.ValueSwitch, o1c1Row.Switch); Assert.AreEqual(o2Set.ValueSwitch, o2c2Row.Switch); Assert.AreEqual(o1Set.Manual[0], o1c1Row.Manual); Assert.AreEqual(o2Set.Manual[0], o2c1Row.Manual); Assert.AreEqual(o1Set.Manual[1], ValueSetConverter.ToValueSetString(o1c2Row.Manual, o1c2Row.ParameterType)); Assert.AreEqual(o2Set.Manual[1], ValueSetConverter.ToValueSetString(o2c2Row.Manual, o2c2Row.ParameterType)); }
public void VerifyThatUpdateValueSetWorksCompoundOptionState() { this.subscription = new ParameterSubscription(Guid.NewGuid(), null, this.uri); this.cptParameter.ParameterSubscription.Add(subscription); this.subscription.ValueSet.Add(new ParameterSubscriptionValueSet(Guid.NewGuid(), null, this.uri) { SubscribedValueSet = this.valueset1 }); this.subscription.ValueSet.Add(new ParameterSubscriptionValueSet(Guid.NewGuid(), null, this.uri) { SubscribedValueSet = this.valueset2 }); this.subscription.ValueSet.Add(new ParameterSubscriptionValueSet(Guid.NewGuid(), null, this.uri) { SubscribedValueSet = this.valueset3 }); this.subscription.ValueSet.Add(new ParameterSubscriptionValueSet(Guid.NewGuid(), null, this.uri) { SubscribedValueSet = this.valueset4 }); var row = new ParameterSubscriptionRowViewModel(this.subscription, this.session.Object, null); var option1Row = row.ContainedRows.OfType <ParameterOptionRowViewModel>().Single(x => x.ActualOption == this.option1); var option2Row = row.ContainedRows.OfType <ParameterOptionRowViewModel>().Single(x => x.ActualOption == this.option2); var o1s1Row = option1Row.ContainedRows.OfType <ParameterStateRowViewModel>() .Single(x => x.ActualState == this.actualState1); var o1s2Row = option1Row.ContainedRows.OfType <ParameterStateRowViewModel>() .Single(x => x.ActualState == this.actualState2); var o2s1Row = option2Row.ContainedRows.OfType <ParameterStateRowViewModel>() .Single(x => x.ActualState == this.actualState1); var o2s2Row = option2Row.ContainedRows.OfType <ParameterStateRowViewModel>() .Single(x => x.ActualState == this.actualState2); var o1s1c1Row = o1s1Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().First(); var o1s1c2Row = o1s1Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().Last(); var o1s2c1Row = o1s2Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().First(); var o1s2c2Row = o1s2Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().Last(); var o2s1c1Row = o2s1Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().First(); var o2s1c2Row = o2s1Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().Last(); var o2s2c1Row = o2s2Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().First(); var o2s2c2Row = o2s2Row.ContainedRows.OfType <ParameterComponentValueRowViewModel>().Last(); // option row Assert.IsFalse(option1Row.IsEditable()); Assert.IsFalse(option2Row.IsEditable()); // state row Assert.IsFalse(o1s1Row.IsEditable()); Assert.IsFalse(o1s2Row.IsEditable()); Assert.IsFalse(o2s1Row.IsEditable()); Assert.IsFalse(o2s2Row.IsEditable()); // component row Assert.IsTrue(o1s1c1Row.IsEditable()); Assert.IsTrue(o1s2c1Row.IsEditable()); Assert.IsTrue(o2s1c1Row.IsEditable()); Assert.IsTrue(o2s2c1Row.IsEditable()); o1s1c1Row.Switch = ParameterSwitchKind.REFERENCE; o1s1c2Row.Switch = ParameterSwitchKind.REFERENCE; o1s2c1Row.Switch = ParameterSwitchKind.REFERENCE; o1s2c2Row.Switch = ParameterSwitchKind.REFERENCE; o2s1c1Row.Switch = ParameterSwitchKind.REFERENCE; o2s1c2Row.Switch = ParameterSwitchKind.REFERENCE; o2s2c1Row.Switch = ParameterSwitchKind.REFERENCE; o2s2c2Row.Switch = ParameterSwitchKind.REFERENCE; o1s1c2Row.Manual = new ReactiveList <EnumerationValueDefinition> { this.enum1 }; o1s2c2Row.Manual = new ReactiveList <EnumerationValueDefinition> { this.enum1 }; o2s1c2Row.Manual = new ReactiveList <EnumerationValueDefinition> { this.enum2 }; o2s2c2Row.Manual = new ReactiveList <EnumerationValueDefinition> { this.enum2 }; var o1s1Set = this.subscription.ValueSet.Single(x => x.ActualOption == this.option1 && x.ActualState == this.actualState1); var o1s2Set = this.subscription.ValueSet.Single(x => x.ActualOption == this.option1 && x.ActualState == this.actualState2); var o2s1Set = this.subscription.ValueSet.Single(x => x.ActualOption == this.option2 && x.ActualState == this.actualState1); var o2s2Set = this.subscription.ValueSet.Single(x => x.ActualOption == this.option2 && x.ActualState == this.actualState2); row.UpdateValueSets(this.subscription); Assert.AreEqual(o1s1Set.ValueSwitch, o1s1c1Row.Switch); Assert.AreEqual(o1s2Set.ValueSwitch, o1s2c1Row.Switch); Assert.AreEqual(o2s1Set.ValueSwitch, o2s1c1Row.Switch); Assert.AreEqual(o2s2Set.ValueSwitch, o2s2c1Row.Switch); Assert.AreEqual(o1s1Set.Manual[0], o1s1c1Row.Manual); Assert.AreEqual(o1s2Set.Manual[0], o1s2c1Row.Manual); Assert.AreEqual(o2s1Set.Manual[0], o2s1c1Row.Manual); Assert.AreEqual(o2s2Set.Manual[0], o2s2c1Row.Manual); Assert.AreEqual(o1s1Set.Manual[1], ValueSetConverter.ToValueSetString(o1s1c2Row.Manual, o1s1c2Row.ParameterType)); Assert.AreEqual(o1s2Set.Manual[1], ValueSetConverter.ToValueSetString(o1s2c2Row.Manual, o1s2c2Row.ParameterType)); Assert.AreEqual(o2s1Set.Manual[1], ValueSetConverter.ToValueSetString(o2s1c2Row.Manual, o2s1c2Row.ParameterType)); Assert.AreEqual(o2s2Set.Manual[1], ValueSetConverter.ToValueSetString(o2s2c2Row.Manual, o2s2c2Row.ParameterType)); }