public void CallLoggingActionOnErrorIfSet() { var wrappedToggle = new FeatureToggleThatThrowsAnException(); string log = ""; var sut = new DefaultToEnabledOnErrorDecorator(wrappedToggle, ex => log += ex.Message); try { var isEnabled = sut.FeatureEnabled; } catch { // ignore exception so we can assert that the specified action was called } Assert.Equal("Exception for testing purposes", log); }