コード例 #1
0
            public void ShouldThrowWhenValueWasNotSet()
            {
                // Arrange
                var section = Substitute.For <IConfigurationSection>();
                var sut     = new SectionBaseWrapper(section);

                // Act
                var ex = Record.Exception(() => sut.ReadBoolWrapper("non.existing"));

                // Assert
                Assert.IsType <KeyNotFoundException>(ex);
            }
コード例 #2
0
            public void ShouldThrowWhenValueCannotBeParsed()
            {
                // Arrange
                const string key = "key";

                var section = Substitute.For <IConfigurationSection>();

                section[key].Returns("abc");

                var sut = new SectionBaseWrapper(section);

                // Act
                var ex = Record.Exception(() => sut.ReadBoolWrapper(key));

                // Assert
                Assert.IsType <FormatException>(ex);
            }
コード例 #3
0
            public void ShouldReturnCorrectValueWhenFound(bool expected)
            {
                // Arrange
                const string key = "key";

                var section = Substitute.For <IConfigurationSection>();

                section[key].Returns(expected.ToString());

                var sut = new SectionBaseWrapper(section);

                // Act
                var actual = sut.ReadBoolWrapper(key);

                // Assert
                Assert.Equal(expected, actual);
            }