public void ShouldThrowWhenKeyWasNotFound() { // Arrange var section = Substitute.For <IConfigurationSection>(); var sut = new SectionBaseWrapper(section); // Act var ex = Record.Exception(() => sut.ReadIntWrapper("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.ReadIntWrapper(key)); // Assert Assert.IsType <FormatException>(ex); }
public void ShouldReadValueFromSection() { // Arrange const int expected = 123; const string key = "key"; var section = Substitute.For <IConfigurationSection>(); section[key].Returns("123"); var sut = new SectionBaseWrapper(section); // Act var actual = sut.ReadIntWrapper(key); // Assert Assert.Equal(expected, actual); }