Ejemplo n.º 1
0
        public void GetAdapterType_role_names_are_case_insensitive()
        {
            Type correct = typeof(ABuilder3);

            Assert.Equal(correct, Adaptable.GetAdapterType(typeof(A), "Builder"));
            Assert.Equal(correct, Adaptable.GetAdapterType(typeof(A), "builder"));
        }
Ejemplo n.º 2
0
        public void GetAdapterType_should_be_equivalent_to_name_adapters_or_use_builder_attribute()
        {
            Type correct = typeof(ABuilder3);

            // Using the BuilderAttribute
            Assert.Equal(correct, Adaptable.GetBuilderType(typeof(A)));
            Assert.Equal(correct, Adaptable.GetAdapterType(typeof(A), "Builder"));

            // Using the AdapterAttribute
            Assert.Equal(correct, Adaptable.GetBuilderType(typeof(B)));
            Assert.Equal(correct, Adaptable.GetAdapterType(typeof(B), "Builder"));
        }
Ejemplo n.º 3
0
    // Gets an adaptable from a string
    public Adaptable GetAdaptable(string key)
    {
        Adaptable result = null;

        if (adaptables.ContainsKey(key))
        {
            adaptables.TryGetValue(key, out result);
        }
        else
        {
            Debug.Log("Error: Adaptable Not Found: " + key);
        }

        return(result);
    }
Ejemplo n.º 4
0
 public void GetActivationConstructor_gets_implicit_default_public_constructor()
 {
     Assert.NotNull(Adaptable.GetActivationConstructor(typeof(S)));
     Assert.Equal(1, typeof(S).GetConstructors(
                      BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Length);
 }
Ejemplo n.º 5
0
        public void GetBuilderType_prevents_builder_type_that_specifies_builder_Type()
        {
            var result = Adaptable.GetBuilderType(typeof(D));

            Assert.Null(result);
        }
Ejemplo n.º 6
0
 public void GetAdapterType_works_with_builder_role_name()
 {
     Assert.Equal(typeof(EBuilder), Adaptable.GetAdapterType(typeof(E), "Builder"));
 }
Ejemplo n.º 7
0
 public void GetBuilderType_should_apply_implicitly_builder()
 {
     Assert.Equal(typeof(EBuilder), Adaptable.GetBuilderType(typeof(E)));
 }
Ejemplo n.º 8
0
        public void GetBuilderType_can_use_derived_builder_class()
        {
            var result = Adaptable.GetBuilderType(typeof(H));

            Assert.Equal(typeof(HBuilder), result);
        }
Ejemplo n.º 9
0
        public void GetBuilderType_ensures_cannot_use_self_as_builder_adapter()
        {
            var result = Adaptable.GetBuilderType(typeof(C));

            Assert.Null(result);
        }