Esempio n. 1
0
        public void CreatePipeline_Calls_Registered_Callbacks_In_Correct_Order()
        {
            var callback_1 = new MockPipelineCallback();
            var callback_2 = new MockPipelineCallback();
            var callback_3 = new MockPipelineCallback();

            _PipelineBuilder.RegisterCallback(callback_2.Callback, 0);
            _PipelineBuilder.RegisterCallback(callback_3.Callback, 1);
            _PipelineBuilder.RegisterCallback(callback_1.Callback, -1);

            callback_1.Action = r => {
                Assert.AreEqual(0, callback_2.CallCount, "2nd callback called before 1st");
                Assert.AreEqual(0, callback_3.CallCount, "3rd callback called before 1st");
            };
            callback_2.Action = r => {
                Assert.AreEqual(1, callback_1.CallCount, "1st callback not called before 2nd");
                Assert.AreEqual(0, callback_3.CallCount, "3rd callback called before 2nd");
            };
            callback_3.Action = r => {
                Assert.AreEqual(1, callback_1.CallCount, "1st callback not called before 3rd");
                Assert.AreEqual(1, callback_2.CallCount, "2nd callback not called before 3rd");
            };

            _PipelineBuilder.CreatePipeline(_Environment.Object);

            Assert.AreEqual(1, callback_1.CallCount);
            Assert.AreEqual(1, callback_2.CallCount);
            Assert.AreEqual(1, callback_3.CallCount);
        }
Esempio n. 2
0
        public void DeregisterCallback_Does_Nothing_If_Passed_Same_Handle_Twice()
        {
            var callback = new MockPipelineCallback();
            var handle   = _PipelineBuilder.RegisterCallback(callback.Callback, 0);

            _PipelineBuilder.DeregisterCallback(handle);
            _PipelineBuilder.DeregisterCallback(handle);
        }
Esempio n. 3
0
        public void CreatePipeline_Does_Not_Call_Callbacks_That_Have_Been_Removed()
        {
            var callback = new MockPipelineCallback();
            var handle   = _PipelineBuilder.RegisterCallback(callback.Callback, 0);

            _PipelineBuilder.DeregisterCallback(handle);

            _PipelineBuilder.CreatePipeline(_Environment.Object);

            Assert.AreEqual(0, callback.CallCount);
        }
Esempio n. 4
0
        public void CreatePipeline_Passes_Environment_To_New_Instance_Of_Pipeline()
        {
            var callback = new MockPipelineCallback();

            callback.Action = (env) => _Pipeline.Verify(r => r.Construct(_Environment.Object), Times.Never);
            _PipelineBuilder.RegisterCallback(callback.Callback, 0);

            _PipelineBuilder.CreatePipeline(_Environment.Object);

            _Pipeline.Verify(r => r.Construct(_Environment.Object), Times.Once);
        }
Esempio n. 5
0
        public void CreatePipeline_Calls_Registered_Callback()
        {
            var callback = new MockPipelineCallback();

            _PipelineBuilder.RegisterCallback(callback.Callback, 0);

            _PipelineBuilder.CreatePipeline(_Environment.Object);

            Assert.AreEqual(1, callback.CallCount);
            Assert.AreEqual(1, callback.AllEnvironments.Count);
            Assert.AreSame(_Environment.Object, callback.LastEnvironment);
        }
Esempio n. 6
0
        public void CreatePipeline_Calls_Optional_HostFinalCallback_Action_After_Calling_Registered_Callbacks()
        {
            var hostFinalCallbackCalled = false;
            var callback = new MockPipelineCallback();

            _PipelineBuilder.RegisterCallback(callback.Callback, 0);
            Action hostFinalCallback = () => {
                Assert.AreEqual(1, callback.CallCount);
                hostFinalCallbackCalled = true;
            };

            _Environment.Object.Properties[ApplicationStartupKey.HostFinalCallback] = hostFinalCallback;

            _PipelineBuilder.CreatePipeline(_Environment.Object);

            Assert.IsTrue(hostFinalCallbackCalled);
        }
Esempio n. 7
0
        public void RegisterCallback_Returns_Handle()
        {
            var callback = new MockPipelineCallback();

            Assert.IsNotNull(_PipelineBuilder.RegisterCallback(callback.Callback, 0));
        }