private string GetConfigValue(EConfigKey key) { var section = EConfigSection.SAROMSettings.ToString(); var keyString = key.ToString(); var value = this.configuration.GetSection(section)[keyString]; if (string.IsNullOrWhiteSpace(value)) { throw new Exception( $"Configuration value for key {keyString} not found!"); } return(value); }
public void Create_Throws_If_Key_Is_Not_Set_In_Configuration(EConfigKey key) { // Arrange var section = EConfigSection.SAROMSettings.ToString(); this.configurationMock .Setup(x => x.GetSection(section)[key.ToString()]) .Returns(""); var operation = new Operation("Test", "1234", DateTime.Now); // Act // Assert var exception = Assert.Throws <Exception>(() => this.repository.Create(operation)); Assert.That( exception.Message, Is.EqualTo($"Configuration value for key {key.ToString()} not found!") ); }