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); }
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); }
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); }