private FactoryContext CreateFactoryContext(SenderFactory customFactory)
        {
            FactoryContext factoryContext = new FactoryContext();

            factoryContext.SetSenderFactory(customFactory);

            return(factoryContext);
        }
        public void Test_CustomSender_FactoryNotCalled_WhenNotRequested()
        {
            ApiStatus apiStatus = new ApiStatus();

            FactoryContext factoryContext = new FactoryContext();

            bool factoryCalled = false;
            Func <IReadOnlyConfiguration, ErrorCallback, MockSender> customFactory =
                (IReadOnlyConfiguration readOnlyConfig, ErrorCallback callback) =>
            {
                factoryCalled = true;

                return(new MockSender());
            };

            Configuration config = new Configuration();

            if (!Configuration.TryLoadConfigurationFromJson(FileSenderConfigJson, out config, apiStatus))
            {
                Assert.Fail("Failed to parse pseudolocalized configuration JSON: " + apiStatus.ErrorMessage);
            }

            TempFileDisposable interactionDisposable = new TempFileDisposable();

            this.TestCleanup.Add(interactionDisposable);

            TempFileDisposable observationDisposable = new TempFileDisposable();

            this.TestCleanup.Add(observationDisposable);

            config["interaction.file.name"] = interactionDisposable.Path;
            config["observation.file.name"] = observationDisposable.Path;

            factoryContext.SetSenderFactory(customFactory);

            LiveModel liveModel = new LiveModel(config, factoryContext);

            liveModel.Init();

            Assert.IsFalse(factoryCalled, "Custom factory should not be called unless BINDING_SENDER is selected in configuration.");
        }