public void SetDefaultKey_uses_the_default_description_if_no_DescriptionAttribute_is_supplied()
        {
            string description = "default";

            Key.Expect(item => item.SetValue(string.Empty, description));
            EngineAttribute.Expect(item => item.SetDefaultKey(null, null, null))
            .CallOriginalMethod(OriginalCallOptions.NoExpectation);
            EngineAttribute.SetDefaultKey(Key, ComponentType, description);
        }
Esempio n. 2
0
        public void SetName_does_not_call_SetValue_if_the_DisplayNameAttribute_is_supplied_but_the_DisplayName_is_empty()
        {
            string description = string.Empty;

            EngineAttribute.Expect(item => item.GetAttribute <DisplayNameAttribute>(ComponentType))
            .Return(new DisplayNameAttribute(description));
            EngineAttribute.Expect(item => item.SetName(null, null))
            .CallOriginalMethod(OriginalCallOptions.NoExpectation);
            EngineAttribute.SetName(Key, ComponentType);
        }
Esempio n. 3
0
        public void SetName_uses_the_DisplayNameAttribute_DisplayName_if_it_is_supplied_and_not_null_or_empty()
        {
            string description = "nondefault";

            Key.Expect(item => item.SetValue("Name", description));
            EngineAttribute.Expect(item => item.GetAttribute <DisplayNameAttribute>(ComponentType))
            .Return(new DisplayNameAttribute(description));
            EngineAttribute.Expect(item => item.SetName(null, null))
            .CallOriginalMethod(OriginalCallOptions.NoExpectation);
            EngineAttribute.SetName(Key, ComponentType);
        }
        public void SetDefaultKey_uses_the_DescriptionAttribute_description_if_it_is_supplied_and_not_null_or_empty()
        {
            string defaultDescription = "default";
            string description        = "nondefault";

            Key.Expect(item => item.SetValue(string.Empty, description));
            EngineAttribute.Expect(item => item.GetAttribute <DescriptionAttribute>(ComponentType))
            .Return(new DescriptionAttribute(description));
            EngineAttribute.Expect(item => item.SetDefaultKey(null, null, null))
            .CallOriginalMethod(OriginalCallOptions.NoExpectation);
            EngineAttribute.SetDefaultKey(Key, ComponentType, defaultDescription);
        }
Esempio n. 5
0
        /*
         * Build an attribute based on a value. Search in the static fields for the value.
         * */
        public static Logical GetLogicalAttribute(String value)
        {
            Domain.Entities.Attribute attribute = null;

            if (fuel.Contains(value))
            {
                attribute = new EngineAttribute(value);
            }
            if (colors.Contains(value))
            {
                attribute = new ColorAttribute(value);
            }
            if (vehicleClass.Contains(value))
            {
                attribute = new ClassAttribute(value);
            }
            if (transmission.Contains(value))
            {
                attribute = new TransmissionAttribute(value);
            }

            if (value.Contains("seater"))
            {
                attribute = new SeatsAttribute(value);
            }
            if (value.Equals("gps"))
            {
                attribute = new GPSAttribute();
            }
            if (value.Equals("sunroof"))
            {
                attribute = new SunroofAttribute();
            }

            if (attribute == null)
            {
                throw new ParseException($"Attribute {value} not found!");
            }

            return(new LogicalAttribute(attribute));
        }
Esempio n. 6
0
 public void SetName_does_not_call_SetValue_if_no_DisplayNameAttribute_is_supplied()
 {
     EngineAttribute.Expect(item => item.SetName(null, null))
     .CallOriginalMethod(OriginalCallOptions.NoExpectation);
     EngineAttribute.SetName(Key, ComponentType);
 }