public void CanAddSimpleProperty()
		{
			var mapdoc = new HbmMapping();
			var component = new HbmDynamicComponent();
			var mapper = new DynamicComponentMapper(component, For<Person>.Property(p => p.Info), mapdoc);
			var dynObject = new { Pizza = 5 };
			mapper.Property(dynObject.GetType().GetProperty("Pizza"), x => { });

			Assert.That(component.Properties.Single(), Is.TypeOf<HbmProperty>().And.Property("Name").EqualTo("Pizza"));
		}
		public void CanAddSimpleProperty()
		{
			var mapdoc = new HbmMapping();
			var component = new HbmDynamicComponent();
			var mapper = new DynamicComponentMapper(component, For<Person>.Property(p => p.Info), mapdoc);
			var dynObject = new { Pizza = 5 };
			mapper.Property(dynObject.GetType().GetProperty("Pizza"), x => { });

			component.Properties.Single().Should().Be.OfType<HbmProperty>().And.ValueOf.Name.Should().Be.EqualTo("Pizza");
		}
        public void WebGridDataSourceWithNestedPropertySortsCorrectly() {
            // Arrange
            var element1 = new { Foo = new { Bar = "val2" } };
            var element2 = new { Foo = new { Bar = "val1" } };
            var element3 = new { Foo = new { Bar = "val3" } };
            IEnumerable<dynamic> values = new[] { element1, element2, element3 };

            var dataSource = new WebGridDataSource(new WebGrid(GetContext()), values: values, elementType: element1.GetType(), canSort: true, canPage: false);

            // Act 
            var rows = dataSource.GetRows(new SortInfo { SortColumn = "Foo.Bar", SortDirection = SortDirection.Descending }, 0);

            // Assert
            Assert.AreEqual(rows.ElementAt(0).Value.Foo.Bar, "val3");
            Assert.AreEqual(rows.ElementAt(1).Value.Foo.Bar, "val2");
            Assert.AreEqual(rows.ElementAt(2).Value.Foo.Bar, "val1");
        }
        public void ReturnsExistingModelMetadata()
        {
            // Arrange
            object model = new { foo = "fooValue", bar = "barValue" };
            ModelMetadata originalMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => model, model.GetType());
            ViewDataDictionary vdd = new ViewDataDictionary(model) { ModelMetadata = originalMetadata };

            // Act
            ModelMetadata metadata = vdd.ModelMetadata;

            // Assert
            Assert.Same(originalMetadata, metadata);
        }
        public void FabricatesModelMetadataFromModelWhenModelMetadataHasNotBeenSet()
        {
            // Arrange
            object model = new { foo = "fooValue", bar = "barValue" };
            ViewDataDictionary vdd = new ViewDataDictionary(model);

            // Act
            ModelMetadata metadata = vdd.ModelMetadata;

            // Assert
            Assert.NotNull(metadata);
            Assert.Equal(model.GetType(), metadata.ModelType);
        }