Just Code‎ > ‎

C# - Assert that Type have no settable properties

posted Dec 4, 2013, 4:30 AM by Peter Henell   [ updated Dec 5, 2013, 12:44 AM ]

[Test]
        [MSTest.TestMethod]
        public void ShouldAssertThatNoSettableFieldsAreAdded()
        {
            var allProperties = typeof(ColumnDataTypeDefinition).GetProperties(
                  System.Reflection.BindingFlags.Public  
                | System.Reflection.BindingFlags.Instance);

            Assert.That(allProperties.All(x => x.GetSetMethod() == null));

            Assert.That(allProperties.Count(), Is.EqualTo(8));
        }
Comments