public void Show()
        {
            var factory    = new Mock <IWindowFactory>();
            var controller = new Mock <IWindowController>();

            var obj        = new WindowService();
            var privateObj = new PrivateObject(obj);

            try {
                //Factory 無し
                obj.Show();
                Assert.Fail();
            } catch (InvalidOperationException) { }

            //Factory セット
            Assert.IsTrue(obj.SetWindowFactory(factory.Object));
            Assert.AreEqual(factory.Object, privateObj.GetProperty("WindowFactory"));

            //Factory Use
            obj.Show();
            Assert.AreEqual(eWindowStateTypes.Initializeing, obj.WindowState);

            try {
                //Controller 無し
                obj.Show();
                Assert.Fail();
            } catch (InvalidOperationException) { }

            //Controller セット
            Assert.IsTrue(obj.SetWindowController(controller.Object));
            Assert.AreEqual(controller.Object, privateObj.GetProperty("WindowController"));

            try {
                //初期化未完
                obj.Show();
                Assert.Fail();
            } catch (InvalidOperationException) { }

            //初期化完了
            controller.Raise(x => x.Initialized += null, new EventArgs());
            Assert.AreEqual(eWindowStateTypes.Shown, obj.WindowState);

            obj.Show();

            //Controller 削除
            Assert.IsTrue(obj.SetWindowController(null));
            Assert.AreEqual(null, privateObj.GetProperty("WindowController"));

            obj.Dispose();

            var disposable = privateObj.GetProperty("Disposable") as System.Reactive.Disposables.CompositeDisposable;

            Assert.AreEqual(0, disposable.Count);
        }
        public void Dispose()
        {
            var obj        = new WindowService();
            var privateObj = new PrivateObject(obj);

            obj.Dispose();

            var disposable = privateObj.GetProperty("Disposable") as System.Reactive.Disposables.CompositeDisposable;

            Assert.AreEqual(0, disposable.Count);
        }
Ejemplo n.º 3
0
 private void DisposeWindowService(WindowService windowService)
 => windowService.Dispose();