示例#1
0
        public void CanOpenCloseOutputWindow()
        {
            var windowManMock = new Mock <IWindowManagerEx>();
            var vm            = GetInstance(cont => cont.ComposeExportedValue <IWindowManagerEx>(windowManMock.Object));

            var conductorMock = new Mock <IConductor>();
            var node          = new ColorInputNode();
            var window        = new VideoOutputViewModel(node.Outputs[0])
            {
                Parent = conductorMock.Object
            };

            ((IActivate)window).Activate();
            conductorMock.Setup(c => c.DeactivateItem(window, true))
            .Callback(() => ((IDeactivate)window).Deactivate(close: true))
            .Verifiable();

            vm.OpenWindow(window);
            windowManMock.Verify(w => w.ShowWindow(window, vm));
            Assert.Equal(window, vm.OpenWindows.Single());

            vm.CloseWindows(node);
            conductorMock.Verify();
            Assert.Empty(vm.OpenWindows);

            vm.OpenWindow(window);
            vm.OpenWindow(window);
            Assert.Equal(window, vm.OpenWindows.Single());

            window.TryClose();
            conductorMock.Verify(c => c.DeactivateItem(window, true), Times.Exactly(2));
            Assert.Empty(vm.OpenWindows);
        }
示例#2
0
        public void ViewfulPipeline()
        {
            var input = new VideoInputNode {
                FileName = new FilePath(@"..\..\..\..\resources\americanFootball_352x240_125.yuv")
            };
            Func <Node, Node> makeNode = n => {
                Node n2 = new InverterNode();
                n2.Inputs[0].Source = n.Outputs[0];
                return(n2);
            };
            Node graph = makeNode(makeNode(makeNode(input)));

            IoC.GetInstance = delegate { return(new EventAggregator()); };
            var output = new VideoOutputViewModel(graph.Outputs[0]);

            var sw = Stopwatch.StartNew();

            new PipelineDriver().RenderTicks(new[] { graph }, tickCount: input.TickCount)
            .ForEach(dic => output.Handle(new TickRenderedMessage(dic)));
            Console.WriteLine(sw.ElapsedMilliseconds + " ms");
        }