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 }
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); }