Skip to content

Commit

Permalink
Support for multiple values valueset by the ExchangeHistory ;fixes ST…
Browse files Browse the repository at this point in the history
  • Loading branch information
Smiechowski Nathanael authored Dec 22, 2021
1 parent 8452934 commit f51e115
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
32 changes: 32 additions & 0 deletions DEHPCommon.Tests/Services/ExchangeHistoryServiceTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,5 +232,37 @@ public void VerifyClear()
this.service.ClearPending();
Assert.IsEmpty(this.service.PendingEntries);
}

[Test]
public void VerifyAppendWithMultipleValuesValueSets()
{
var values = new List<string>() { "-", "-", "-" };

var valueSet = new ParameterValueSet()
{
Computed = new ValueArray<string>(values)
};

var valueSetClone = valueSet.Clone(false);

var compoundParameterType = new CompoundParameterType()
{
Name = "testParameterType",
ShortName = "testParameterType",
Component =
{
new ParameterTypeComponent() { ParameterType = new DateParameterType() { Name = "date" } },
new ParameterTypeComponent() { ParameterType = new TextParameterType() { Name = "text" } },
new ParameterTypeComponent() { ParameterType = new SimpleQuantityKind() { Name = "number" } }
}
};

var parameter = new Parameter() { ParameterType = compoundParameterType, ValueSet = { valueSet }};
this.element.Parameter.Add(parameter);

Assert.DoesNotThrow(() => this.service.Append(valueSet, valueSetClone));

Assert.IsTrue(this.service.PendingEntries.LastOrDefault()?.Message.Contains(compoundParameterType.Name));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public void VerifyTreesGetBuilt()
this.viewModel.BuildTrees(iterationClone);
Assert.IsNotEmpty(this.viewModel.Things);
Assert.AreEqual(1, this.viewModel.Things.Count);Assert.IsEmpty(this.viewModel.Things.First().ContainedRows);
Assert.IsTrue(this.viewModel.Things.FirstOrDefault()?.IsExpanded);
}

[Test]
Expand Down
8 changes: 4 additions & 4 deletions DEHPCommon/Services/ExchangeHistory/ExchangeHistoryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public void Append(ParameterValueSetBase valueToUpdate, IValueSet newValue)

var newValueString = $"{prefix} {newValueRepresentation} [{scale}]";
var valueToUpdateString = $"{prefix} {oldValueRepresentation} [{scale}]";

this.Append($"Value: [{valueToUpdateString}] from Parameter [{parameter?.ModelCode()}] " +
$"has been updated to [{newValueString}]");
$"has been updated to [{newValueString}]");
}

/// <summary>
Expand Down Expand Up @@ -180,8 +180,8 @@ private static string GetValueSetValueRepresentation(ParameterBase parameter, IV
var cols = parameter.ParameterType.NumberOfValues;
return $"[{valueSet.Computed.Count / cols}x{cols}]";
}

return valueSet.Computed[0] ?? "-";
return valueSet.Computed.DefaultIfEmpty("-").Aggregate((x, y) => $"{x},{y}");
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ public virtual void BuildTrees(Iteration iteration = null)
this.Things.Add(new ElementDefinitionsBrowserViewModel(iteration ?? this.HubController.OpenIteration, this.HubController.Session));
}
}

if (this.Things.FirstOrDefault() is { } firstNode)
{
firstNode.IsExpanded = true;
}
}

/// <summary>
Expand Down

0 comments on commit f51e115

Please sign in to comment.