private static void CheckNotCorrupt(EnumParameter p, Guid value, IEnumeration enumeration) { Assert.That(p.Corrupted, Is.False); Assert.That(p.DisplayValue((a, b) => ""), Is.EqualTo(enumeration.GetName(value))); Assert.That(p.Value, Is.EqualTo(value)); Assert.That(Guid.TryParse(p.ValueAsString(), out Guid guid), Is.True); Assert.That(guid, Is.EqualTo(p.Value)); }
public string GetName(Guid value) { if (value == Guid.Empty) { return(InvalidValue); } else { return(m_enumeration.GetName(value)); } }
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))); } }
public string GetName(Guid value) { return(m_enumeration.GetName(value)); }
private static void CheckSetParameter(Tuple <Guid, string>[] options, IEnumeration enumeration, Id <Parameter> id, string def, bool corrupt) { string name = "testSetParameter"; var setParameter = enumeration.ParameterSet(name, id, def); Assert.That(setParameter.Corrupted, Is.EqualTo(corrupt)); Assert.That(setParameter.ValueAsString(), Is.EqualTo(def ?? enumeration.DefaultValue.Transformed(s => s, g => enumeration.GetName(g)))); Assert.That(setParameter.Id, Is.EqualTo(id)); Assert.That(setParameter.Name, Is.EqualTo(name)); Assert.That(setParameter.TypeId, Is.EqualTo(ParameterType.ValueSetType.Of(enumeration.TypeId))); Assert.That(setParameter, Is.InstanceOf <ISetParameter>()); Assert.That((setParameter as ISetParameter).Options, Is.EquivalentTo(options.Select(o => o.Item1))); }