public void ExceptionWhenGettingAllFlagsIsHandledCorrectly() { // Just like the Variation methods, AllFlagsState should not propagate exceptions from the // data store - we don't want to disrupt application code in that way. We'll just set the // FeatureFlagsState.Valid property to false to indicate that there was an issue, and log // the error. var ex = new Exception("fake-error"); var mockStore = new Mock <IDataStore>(); mockStore.Setup(s => s.GetAll(DataModel.Features)).Throws(ex); var configWithCustomStore = BasicConfig() .DataStore(mockStore.Object.AsSingletonFactory()) .Build(); using (var clientWithCustomStore = new LdClient(configWithCustomStore)) { var state = clientWithCustomStore.AllFlagsState(user); Assert.NotNull(state); Assert.False(state.Valid); AssertLogMessageRegex(true, Logging.LogLevel.Error, ex.Message); } }
public void ExceptionWhenGettingAllFlagsIsHandledCorrectly() { // Just like the Variation methods, AllFlagsState should not propagate exceptions from the // data store - we don't want to disrupt application code in that way. We'll just set the // FeatureFlagsState.Valid property to false to indicate that there was an issue, and log // the error. var ex = new Exception("fake-error"); var mockStore = new Mock <IDataStore>(); mockStore.Setup(s => s.GetAll(DataModel.Features)).Throws(ex); var configWithCustomStore = Configuration.Builder("sdk-key") .DataStore(new SpecificDataStoreFactory(mockStore.Object)) .DataSource(Components.ExternalUpdatesOnly) .Logging(testLogging) .Build(); using (var clientWithCustomStore = new LdClient(configWithCustomStore)) { var state = clientWithCustomStore.AllFlagsState(user); Assert.NotNull(state); Assert.False(state.Valid); Assert.True(logCapture.HasMessageWithRegex(Logging.LogLevel.Error, ex.Message)); } }