Пример #1
0
        public void ShouldAssertAllPropertiesInitialized()
        {
            // Arrange
            var initializedClass = new SomeClass()
            {
                Id = 1, Name = "dave", ReferenceType = new MemoryStream()
            };
            var unnitializedClass0 = new SomeClass()
            {
                Id = 1, Name = "dave", ReferenceType = null
            };
            var unnitializedClass1 = new SomeClass()
            {
                Name = "dave", ReferenceType = new MemoryStream()
            };
            var unnitializedClass2 = new SomeClass()
            {
                Id = 1, ReferenceType = new MemoryStream()
            };

            // Act/Assert
            Assert.DoesNotThrow(initializedClass.AssertAllPropertiesInitialize);
            Assert.Throws <AssertionException>(() => unnitializedClass0.AssertAllPropertiesInitialize());
            Assert.Throws <AssertionException>(() => unnitializedClass1.AssertAllPropertiesInitialize());
            Assert.Throws <AssertionException>(() => unnitializedClass2.AssertAllPropertiesInitialize());
        }