Пример #1
0
        public void Implicit_cast_to_keyvaluepair_of_string_type_should_set_key_property_to_value_of_name_property()
        {
            var instance =
                new RequiredMetadataItem("Foo", null);

            KeyValuePair <string, Type> pair = instance;

            pair.Key.ShouldEqual(instance.Name);
        }
        public void Implicit_cast_to_keyvaluepair_of_string_type_should_set_key_property_to_value_of_name_property()
        {
            var instance =
                new RequiredMetadataItem("Foo", null);

            KeyValuePair<string, Type> pair = instance;

            pair.Key.ShouldEqual(instance.Name);
        }
Пример #3
0
        public void Implicit_cast_to_keyvaluepair_of_string_type_should_set_value_property_to_value_of_type_property()
        {
            var instance =
                new RequiredMetadataItem(string.Empty, typeof(string));

            KeyValuePair <string, Type> pair = instance;

            pair.Value.ShouldEqual(instance.Type);
        }
        public void Implicit_cast_to_keyvaluepair_of_string_type_should_set_value_property_to_value_of_type_property()
        {
            var instance =
                new RequiredMetadataItem(string.Empty, typeof(string));

            KeyValuePair<string, Type> pair = instance;

            pair.Value.ShouldEqual(instance.Type);
        }
Пример #5
0
        public void Equals_should_return_false_when_type_is_not_identical_to_instance_being_compared_against()
        {
            var instance =
                new RequiredMetadataItem(string.Empty, typeof(string));

            var results =
                instance.Equals(new RequiredMetadataItem(string.Empty, typeof(object)));

            results.ShouldBeFalse();
        }
Пример #6
0
        public void Equals_should_return_false_when_name_is_not_identical_to_instance_being_compared_against()
        {
            var instance =
                new RequiredMetadataItem("Foo", null);

            var results =
                instance.Equals(new RequiredMetadataItem("Bar", null));

            results.ShouldBeFalse();
        }
Пример #7
0
        public void Equals_should_return_true_if_identical_to_instance_being_compared_against()
        {
            var instance =
                new RequiredMetadataItem("Name", typeof(string));

            var results =
                instance.Equals(new RequiredMetadataItem("Name", typeof(string)));

            results.ShouldBeTrue();
        }
        public void Equals_should_return_false_when_type_is_not_identical_to_instance_being_compared_against()
        {
            var instance =
                new RequiredMetadataItem(string.Empty, typeof(string));

            var results =
                instance.Equals(new RequiredMetadataItem(string.Empty, typeof(object)));

            results.ShouldBeFalse(); 
        }
        public void Equals_should_return_false_when_name_is_not_identical_to_instance_being_compared_against()
        {
            var instance =
                new RequiredMetadataItem("Foo", null);

            var results =
                instance.Equals(new RequiredMetadataItem("Bar", null));

            results.ShouldBeFalse();
        }
        public void Equals_should_return_true_if_identical_to_instance_being_compared_against()
        {
            var instance =
                new RequiredMetadataItem("Name", typeof(string));

            var results =
                instance.Equals(new RequiredMetadataItem("Name", typeof(string)));

            results.ShouldBeTrue();
        }
Пример #11
0
        public void Implicit_cast_to_keyvaluepair_of_string_type_should_not_throw_exception()
        {
            var instance =
                new RequiredMetadataItem();

            KeyValuePair <string, Type> pair;

            var exception =
                Catch.Exception(() => pair = instance);

            exception.ShouldBeNull();
        }
Пример #12
0
        private IList <RequiredMetadataItem> CreateRequiredMetadataItems(MetadataElementCollection elementCollection)
        {
            var items = new List <RequiredMetadataItem>();

            foreach (MetadataElement configurationMetadata in elementCollection)
            {
                var item = new RequiredMetadataItem(configurationMetadata.Name, GetType(configurationMetadata.Type));
                items.Add(item);
            }

            return(items);
        }
        public void Implicit_cast_to_keyvaluepair_of_string_type_should_not_throw_exception()
        {
            var instance =
                new RequiredMetadataItem();

            KeyValuePair<string, Type> pair;

            var exception =
                Catch.Exception(() => pair = instance);

            exception.ShouldBeNull();
        }
        public void RequireMetadata_should_add_required_metadata_object_to_required_metadata_collection_on_convention_when_called_with_name_and_type()
        {
            this.conventionBuilder
            .RequireMetadata <object>("Name");

            var convention =
                this.conventionBuilder.GetConvention();

            var expectedMetadata =
                new RequiredMetadataItem("Name", typeof(object));

            convention.RequiredMetadata.First().ShouldEqual(expectedMetadata);
        }
Пример #15
0
        /// <summary>
        /// Defines metadata that imports created by the convention needs to have satisfied, by using the provided name and type.
        /// </summary>
        /// <typeparam name="TMetadataType">The <see cref="Type"/> of the required metadata.</typeparam>
        /// <param name="name">A <see cref="string"/> containing the name of the required metadata.</param>
        /// <returns>Returns a reference to the same <see cref="ImportConventionBuilder{TImportConvention}"/> instance as the method was called on.</returns>
        /// <exception cref="ArgumentNullException">The value of the <paramref name="name"/> parameter was null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">The lenght of the <paramref name="name"/> parameter was zero.</exception>
        public ImportConventionBuilder <TImportConvention> RequireMetadata <TMetadataType>(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name", "The name cannot be null.");
            }

            if (name.Length == 0)
            {
                throw new ArgumentOutOfRangeException("name", "The name cannot be empty.");
            }

            var requiredMetadata =
                new RequiredMetadataItem(name, typeof(TMetadataType));

            this.ProvideValueFor(x => x.RequiredMetadata, requiredMetadata);

            return(this);
        }
        public void RequireMetadata_should_add_required_metadata_object_to_required_metadata_collection_on_convention_when_called_with_name_and_type()
        {
            this.conventionBuilder
                .RequireMetadata<object>("Name");

            var convention =
                this.conventionBuilder.GetBuiltInstance();

            var expectedMetadata =
                new RequiredMetadataItem("Name", typeof(object));

            convention.RequiredMetadata.First().ShouldEqual(expectedMetadata);
        }