public void GetDynamicMemberNames_ReturnsEmptyListForEmptyViewDataDictionary()
        {
            // Arrange
            ViewDataDictionary        vd  = new ViewDataDictionary();
            DynamicViewDataDictionary dvd = new DynamicViewDataDictionary(() => vd);

            // Act
            IEnumerable <string> result = dvd.GetDynamicMemberNames();

            // Assert
            Assert.Empty(result);
        }
Esempio n. 2
0
        public void GetDynamicMemberNames_ReturnsEmptyListForEmptyViewDataDictionary()
        {
            // Arrange
            ViewDataDictionary        vd  = new ViewDataDictionary();
            DynamicViewDataDictionary dvd = new DynamicViewDataDictionary(() => vd);

            // Act
            var result = dvd.GetDynamicMemberNames();

            // Assert
            Assert.AreEqual(0, result.Count());
        }
        public void GetDynamicMemberNames_ReturnsKeyNamesForFilledViewDataDictionary()
        {
            // Arrange
            ViewDataDictionary vd = new ViewDataDictionary()
            {
                { "Prop1", 1 }, { "Prop2", 2 }
            };
            DynamicViewDataDictionary dvd = new DynamicViewDataDictionary(() => vd);

            // Act
            var result = dvd.GetDynamicMemberNames();

            // Assert
            Assert.Equal(new[] { "Prop1", "Prop2" }, result.OrderBy(s => s).ToArray());
        }
        public void GetDynamicMemberNames_ReflectsChangesToDynamicObject()
        {
            // Arrange
            ViewDataDictionary vd = new ViewDataDictionary();

            vd["OldProp"] = 123;
            DynamicViewDataDictionary dvd = new DynamicViewDataDictionary(() => vd);

            ((dynamic)dvd).NewProp = "foo";

            // Act
            var result = dvd.GetDynamicMemberNames();

            // Assert
            Assert.Equal(new[] { "NewProp", "OldProp" }, result.OrderBy(s => s).ToArray());
        }
        public void GetDynamicMemberNames_ReflectsChangesToUnderlyingViewDataDictionary()
        {
            // Arrange
            ViewDataDictionary vd = new ViewDataDictionary();

            vd["OldProp"] = 123;
            DynamicViewDataDictionary dvd = new DynamicViewDataDictionary(() => vd);

            vd["NewProp"] = "somevalue";

            // Act
            var result = dvd.GetDynamicMemberNames();

            // Assert
            Assert.Equal(new[] { "NewProp", "OldProp" }, result.OrderBy(s => s).ToArray());
        }
        public void GetDynamicMemberNames_ReflectsChangesToDynamicObject() {
            // Arrange
            ViewDataDictionary vd = new ViewDataDictionary();
            vd["OldProp"] = 123;
            DynamicViewDataDictionary dvd = new DynamicViewDataDictionary(() => vd);
            ((dynamic)dvd).NewProp = "foo";

            // Act
            var result = dvd.GetDynamicMemberNames();

            // Assert
            CollectionAssert.AreEqual(new[] { "NewProp", "OldProp" }, result.OrderBy(s => s).ToList());
        }
        public void GetDynamicMemberNames_ReturnsKeyNamesForFilledViewDataDictionary() {
            // Arrange
            ViewDataDictionary vd = new ViewDataDictionary() {
                { "Prop1", 1 },
                { "Prop2", 2 }
            };
            DynamicViewDataDictionary dvd = new DynamicViewDataDictionary(() => vd);

            // Act
            var result = dvd.GetDynamicMemberNames();

            // Assert
            CollectionAssert.AreEqual(new[] { "Prop1", "Prop2" }, result.OrderBy(s => s).ToList());
        }
        public void GetDynamicMemberNames_ReturnsEmptyListForEmptyViewDataDictionary() {
            // Arrange
            ViewDataDictionary vd = new ViewDataDictionary();
            DynamicViewDataDictionary dvd = new DynamicViewDataDictionary(() => vd);

            // Act
            var result = dvd.GetDynamicMemberNames();

            // Assert
            Assert.AreEqual(0, result.Count());
        }
        public void GetDynamicMemberNames_ReflectsChangesToUnderlyingViewDataDictionary()
        {
            // Arrange
            ViewDataDictionary vd = new ViewDataDictionary();
            vd["OldProp"] = 123;
            DynamicViewDataDictionary dvd = new DynamicViewDataDictionary(() => vd);
            vd["NewProp"] = "somevalue";

            // Act
            var result = dvd.GetDynamicMemberNames();

            // Assert
            Assert.Equal(new[] { "NewProp", "OldProp" }, result.OrderBy(s => s).ToArray());
        }
        public void GetDynamicMemberNames_ReturnsEmptyListForEmptyViewDataDictionary()
        {
            // Arrange
            ViewDataDictionary vd = new ViewDataDictionary();
            DynamicViewDataDictionary dvd = new DynamicViewDataDictionary(() => vd);

            // Act
            IEnumerable<string> result = dvd.GetDynamicMemberNames();

            // Assert
            Assert.Empty(result);
        }