public void EndWaiting_WillCloseWindow_Always()
        {
            var waitIndicator = new Fake_WaitIndicator();
            waitIndicator.BeginWaiting(0, 0, 0, 0);

            waitIndicator.EndWaiting();

            Assert.IsTrue(waitIndicator.CreatedWindow.CalledClose);
        }
        public void BeginWaiting_WillShowWindow_Always()
        {
            var waitIndicator = new Fake_WaitIndicator();
            var dummyAppearance = new Mock<IWaitIndicatorAppearance>();

            waitIndicator.BeginWaiting(dummyAppearance.Object, 0, 0, 0, 0);

            Assert.IsTrue(waitIndicator.CreatedWindow.CalledShow);
            waitIndicator.EndWaiting();
        }
        public void EndWaiting_WillCloseWindow_Always()
        {
            var waitIndicator = new Fake_WaitIndicator();

            waitIndicator.BeginWaiting(0, 0, 0, 0);

            waitIndicator.EndWaiting();

            Assert.IsTrue(waitIndicator.CreatedWindow.CalledClose);
        }
        public void EndWaiting_WillCloseWindowInSeparateThread_Always()
        {
            int callerThreadId = Thread.CurrentThread.ManagedThreadId;
            var waitIndicator = new Fake_WaitIndicator();
            waitIndicator.BeginWaiting(0, 0, 0, 0);

            waitIndicator.EndWaiting();

            Assert.AreNotEqual(callerThreadId, waitIndicator.CreatedWindow.CalledCloseThreadId);
        }
        public void EndWaiting_WillAbortBackgroundGuiThread_Always()
        {
            var waitIndicator = new Fake_WaitIndicator();
            waitIndicator.ForcedThreadExecutionMillisecs = 2000;
            waitIndicator.BeginWaiting(0, 0, 0, 0);

            waitIndicator.EndWaiting();

            Assert.IsFalse(waitIndicator.IsThreadRunning);
        }
        public void EndWaiting_WillAbortBackgroundGuiThread_Always()
        {
            var waitIndicator = new Fake_WaitIndicator();
            waitIndicator.ForcedThreadExecutionMillisecs = 2000;
            var dummyAppearance = new Mock<IWaitIndicatorAppearance>();
            waitIndicator.BeginWaiting(dummyAppearance.Object, 0, 0, 0, 0);

            waitIndicator.EndWaiting();

            Assert.IsFalse(waitIndicator.IsThreadRunning);
        }
        public void EndWaiting_WillAbortBackgroundGuiThread_Always()
        {
            var waitIndicator = new Fake_WaitIndicator();

            waitIndicator.ForcedThreadExecutionMillisecs = 2000;
            waitIndicator.BeginWaiting(0, 0, 0, 0);

            waitIndicator.EndWaiting();

            Assert.IsFalse(waitIndicator.IsThreadRunning);
        }
        public void EndWaiting_WillCloseWindowInSeparateThread_Always()
        {
            int callerThreadId = Thread.CurrentThread.ManagedThreadId;
            var waitIndicator  = new Fake_WaitIndicator();

            waitIndicator.BeginWaiting(0, 0, 0, 0);

            waitIndicator.EndWaiting();

            Assert.AreNotEqual(callerThreadId, waitIndicator.CreatedWindow.CalledCloseThreadId);
        }
        public void BeginWaiting_WillShowWindowInSeparateThread_Always()
        {
            var waitIndicator = new Fake_WaitIndicator();
            int callerThreadId = Thread.CurrentThread.ManagedThreadId;
            var dummyAppearance = new Mock<IWaitIndicatorAppearance>();

            waitIndicator.BeginWaiting(dummyAppearance.Object, 0, 0, 0, 0);

            Assert.AreEqual(ApartmentState.STA, waitIndicator.CreatedWindow.CalledShowApartmentState);
            Assert.AreNotEqual(callerThreadId, waitIndicator.CreatedWindow.CalledShowThreadId);
            waitIndicator.EndWaiting();
        }
        public void BeginWaiting_WillShowWindowAtSpecifiedSizeAndPosition_Always()
        {
            var waitIndicator = new Fake_WaitIndicator();
            var dummyAppearance = new Mock<IWaitIndicatorAppearance>();

            waitIndicator.BeginWaiting(dummyAppearance.Object, 10, 20, 30, 40);

            Assert.AreEqual(10, waitIndicator.CreatedWindow.CalledShowLeft);
            Assert.AreEqual(20, waitIndicator.CreatedWindow.CalledShowTop);
            Assert.AreEqual(30, waitIndicator.CreatedWindow.CalledShowWidth);
            Assert.AreEqual(40, waitIndicator.CreatedWindow.CalledShowHeight);
            waitIndicator.EndWaiting();
        }
        public void EndWaiting_WontDeadlock_WhenCalledMoreThanOnce()
        {
            var waitIndicator = new Fake_WaitIndicator();
            waitIndicator.ForcedThreadExecutionMillisecs = 2000;
            var dummyAppearance = new Mock<IWaitIndicatorAppearance>();
            waitIndicator.BeginWaiting(dummyAppearance.Object, 0, 0, 0, 0);

            waitIndicator.EndWaiting();
            waitIndicator.EndWaiting();
        }