예제 #1
0
        public void GetViewDataProperties_ReturnsNull_IfTypeDoesNotHaveAnyViewDataProperties()
        {
            // Arrange
            var type = typeof(TestController_NoViewDataProperties);

            // Act
            var result = ViewDataAttributePropertyProvider.GetViewDataProperties(type);

            // Assert
            Assert.Null(result);
        }
예제 #2
0
        public void GetViewDataProperties_ReturnsViewDataProperties_FromBaseTypes()
        {
            // Arrange
            var type = typeof(DerivedController);

            // Act
            var result = ViewDataAttributePropertyProvider.GetViewDataProperties(type);

            // Assert
            Assert.Collection(
                result.OrderBy(p => p.Key),
                property => Assert.Equal(nameof(BaseController.BaseProperty), property.PropertyInfo.Name),
                property => Assert.Equal(nameof(DerivedController.DeriviedProperty), property.PropertyInfo.Name));
        }
예제 #3
0
        public void GetViewDataProperties_UsesKeyFromViewDataAttribute()
        {
            // Arrange
            var type = typeof(PropertyWithKeyController);

            // Act
            var result = ViewDataAttributePropertyProvider.GetViewDataProperties(type);

            // Assert
            Assert.Collection(
                result.OrderBy(p => p.Key),
                property =>
            {
                Assert.Equal(nameof(PropertyWithKeyController.Different), property.PropertyInfo.Name);
                Assert.Equal("Test", property.Key);
            });
        }