Ejemplo n.º 1
0
        public void ValidateUdiEntityType()
        {
            var types = UdiParser.GetKnownUdiTypes();

            foreach (var fi in typeof(Constants.UdiEntityType).GetFields(BindingFlags.Public | BindingFlags.Static))
            {
                // IsLiteral determines if its value is written at
                //   compile time and not changeable
                // IsInitOnly determine if the field can be set
                //   in the body of the constructor
                // for C# a field which is readonly keyword would have both true
                //   but a const field would have only IsLiteral equal to true
                if (fi.IsLiteral && fi.IsInitOnly == false)
                {
                    var value = fi.GetValue(null).ToString();

                    if (types.ContainsKey(value) == false)
                    {
                        Assert.Fail("Error in class Constants.UdiEntityType, type \"{0}\" is not declared by GetTypes.", value);
                    }
                    types.Remove(value);
                }
            }

            Assert.AreEqual(0, types.Count, "Error in class Constants.UdiEntityType, GetTypes declares types that don't exist ({0}).", string.Join(",", types.Keys.Select(x => "\"" + x + "\"")));
        }