示例#1
0
 public void SetupTests()
 {
     _terminalOut = new TerminalModel("", typeof(int), Direction.East, TerminalKind.Output, 0);
     _terminalIn  = new TerminalModel("", typeof(int), Direction.East, TerminalKind.Input, 0);
     _wireMoq     = new Mock <WireModel>(_terminalIn, _terminalOut);
     _terminalOut.ConnectWire(_wireMoq.Object);
 }
示例#2
0
        public void TestDisconnectWire_DisconnectWireOnConnectedWireInvoked()
        {
            var terminalModelInput  = new TerminalModel("", typeof(int), Direction.North, TerminalKind.Input, 0);
            var terminalModelOutput = new TerminalModel("", typeof(int), Direction.North, TerminalKind.Output, 0);
            var wireMoq             = new Mock <WireModel>(terminalModelInput, terminalModelOutput);

            terminalModelInput.ConnectWire(wireMoq.Object);
            terminalModelInput.DisconnectWire(wireMoq.Object);
            Assert.AreEqual(0, terminalModelInput.ConnectedWires.Count);
        }
示例#3
0
        public void TestOnTerminalPropertyChanged_ConnectedWireChanged_SemanticsChangedInvoked()
        {
            var terminalModelInput  = new TerminalModel("", typeof(int), Direction.North, TerminalKind.Input, 0);
            var terminalModelOutput = new TerminalModel("", typeof(int), Direction.North, TerminalKind.Output, 0);
            var wireMoq             = new Mock <WireModel>(terminalModelInput, terminalModelOutput);
            var semanticsChanged    = false;

            terminalModelInput.SemanticsChanged += () => semanticsChanged = true;
            terminalModelInput.ConnectWire(wireMoq.Object);

            Assert.IsTrue(semanticsChanged);
        }
示例#4
0
        /// <inheritdoc/>
        public Action Execute(object parameter)
        {
            if (parameter is TerminalModel toTerminal)
            {
                var wire = new WireModel();
                _fromTerminal.ConnectWire(wire, toTerminal);
                var wireViewModel = new Wire(wire, new WirePathingAlgorithum())
                {
                    DoAnimationWhenViewIsLoaded = _animateWireWhenLoaded,
                };
                _diagram.AddWire(wireViewModel);
                return(() =>
                {
                    _fromTerminal.DisconnectWire(wire, toTerminal);
                    _diagram.RemoveWire(wireViewModel);
                });
            }

            return(() => { });
        }