Пример #1
0
        public void SizeDictionariesCanBeLoadedWithReflection()
        {
            SizesSet  sizesSet                   = new SizesFastFood();
            Type      fastFoodType               = sizesSet.GetType();
            FieldInfo regularSizeInfo            = fastFoodType.GetField("Regular");
            Dictionary <string, Beverage> result = (Dictionary <string, Beverage>)regularSizeInfo.GetValue(sizesSet);

            Assert.True(result.ContainsKey("Small"));
        }
        public void All_Fields_Are_Contained_In_Sources()
        {
            SizesSet sizes = new SizesFastFood();

            FieldInfo[] fields = sizes.GetType().GetFields();
            foreach (FieldInfo field in fields)
            {
                Assert.Contains(field.Name, sizes.Sources);
            }
        }
        public void All_Sources_Have_Fields()
        {
            SizesSet sizes = new SizesFastFood();

            FieldInfo[]   fields     = sizes.GetType().GetFields();
            List <string> fieldNames = new List <string>();

            foreach (FieldInfo field in fields)
            {
                fieldNames.Add(field.Name);
            }
            foreach (string source in sizes.Sources)
            {
                Assert.Contains(source, fieldNames);
            }
        }