public void ShouldThrowWhenRegisteringCallbackAfterCompletion()
        {
            var promise = new OperationPromise <TestResponse>(0, new TestOperation());

            promise.Complete(new TestResponse());

            Action action = () => promise.Then(t => t.Method());

            action.ShouldThrow <InvalidOperationException>();
        }
        public void ShouldRegisterCallback()
        {
            var promise = new OperationPromise <TestResponse>(0, new TestOperation());

            Action <TestResponse> callback = response => response.Method();

            promise.Then(callback);

            promise.Callbacks.ShouldContain(callback);
            promise.IsCompleted.ShouldBeFalse();
        }
        public void ShouldInvokeCallbacksOnComplete()
        {
            var promise = new OperationPromise <TestResponse>(0, new TestOperation());

            promise.Then(t => t.Method());

            var response = new TestResponse();

            promise.Complete(response);

            promise.Response.ShouldBe(response);
            promise.IsCompleted.ShouldBeTrue();

            response.MethodInvokeCount.ShouldBe(1);
        }