public override void Save(ValuesDictionary valuesDictionary) { int num = 0; ValuesDictionary keyValues = new ValuesDictionary(); foreach (Point3 point in devices) { keyValues.SetValue <Point3>(num.ToString(), point); ++num; } valuesDictionary.SetValue <ValuesDictionary>("Devices", keyValues); num = 0; ValuesDictionary valuePairs = new ValuesDictionary(); foreach (KeyValuePair <Point3, List <Point3> > point3s in MutiDevices) { ValuesDictionary datas = new ValuesDictionary(); ValuesDictionary itemv = new ValuesDictionary(); int nnum = 0; foreach (Point3 point in point3s.Value) { itemv.SetValue(nnum.ToString(), point); ++nnum; } datas.SetValue("Point", point3s.Key); datas.SetValue("Data", itemv); valuePairs.SetValue(num.ToString(), datas); ++num; } valuesDictionary.SetValue("MutiDevices", valuePairs); ValuesDictionary valuePairs1 = new ValuesDictionary(); num = 0; foreach (KeyValuePair <Point3, NewMutiBlockCheck.TranmitResult> keyValuePair in tranmitPoints) { ValuesDictionary valuePairs2 = new ValuesDictionary(); int y = 0; ValuesDictionary poins = new ValuesDictionary(); foreach (Point3 point in keyValuePair.Value.blocks) { poins.Add(y.ToString(), point); ++y; } valuePairs2.SetValue("savePoint", keyValuePair.Value.savePoint); valuePairs2.SetValue("connPoint", keyValuePair.Value.connectPoint); valuePairs2.SetValue("pa", keyValuePair.Value.pa); valuePairs2.SetValue("pb", keyValuePair.Value.pb); valuePairs2.SetValue("directionIsX", keyValuePair.Value.directionIsX); valuePairs2.SetValue("blocks", poins); valuePairs1.SetValue(num.ToString(), valuePairs2); ++num; } valuesDictionary.SetValue("tranmitPoints", valuePairs1); }
public async Task GetExistingVariableWithTrailingDotShouldFail() { // Arrange var variableName = "variableName1"; var variableValue = "value1"; ValuesDictionary.Add(variableName, new PlainText() { Text = variableValue }); var target = GetTarget(); // Act await target.GetVariableAsync($"{variableName}.", CancellationToken).ShouldThrowAsync <ArgumentException>(); }
public async Task GetVariableWithJsonInvalidPropertyWithTwoLevelsShouldReturnNull() { // Arrange var variableName = "variableName1"; ValuesDictionary.Add(variableName, new PlainText() { Text = "{\"plan\": \"Premium\",\"details\": {\"address\": \"Rua X\"}}" }); var target = GetTarget(); // Act var actual = await target.GetVariableAsync("*****@*****.**", CancellationToken); // Assert actual.ShouldBeNull(); }
public async Task GetVariableWithJsonPropertyShouldSucceed() { // Arrange var variableName = "variableName1"; ValuesDictionary.Add(variableName, new PlainText() { Text = "{\"plan\": \"Premium\",\"details\": {\"address\": \"Rua X\"}}" }); var target = GetTarget(); // Act var actual = await target.GetVariableAsync("variableName1@plan", CancellationToken); // Assert actual.ShouldBe("Premium"); }
public async Task GetNonExistingVariableShouldReturnNull() { // Arrange var variableName = "variableName1"; var variableValue = "value1"; ValuesDictionary.Add(variableName, new PlainText() { Text = variableValue }); var target = GetTarget(); // Act var actual = await target.GetVariableAsync("variableName2", CancellationToken); // Assert actual.ShouldBeNull(); }
public async Task GetExistingVariableWithContextSourceShouldSucceed() { // Arrange var variableName = "variableName1"; var variableValue = "value1"; ValuesDictionary.Add(variableName, new PlainText() { Text = variableValue }); var target = GetTarget(); // Act var actual = await target.GetVariableAsync($"context.{variableName}", CancellationToken); // Assert actual.ShouldBe(variableValue); }