Example #1
0
        public void RemoveInput_AddAndRemoveInput_OperatorContainsNewInputAfterUndo()
        {
            const string newInputName = "newTestInput";
            var          newInput     = new MetaInput(Guid.NewGuid(), newInputName, BasicMetaTypes.FloatMeta, new Float(0.0f), false);

            _operator.Definition.AddInput(newInput);
            var inputToRemove      = _operator.Inputs.Find(input => input.Name == newInputName);
            var removeInputCommand = new RemoveInputCommand(_operator, inputToRemove);

            removeInputCommand.Do();
            removeInputCommand.Undo();
            Assert.IsNotNull(_operator.Inputs.Find(input => input.Name == newInputName));
        }
Example #2
0
        public void RemoveInput_AddAndRemoveInputWithInGoingConnection_ConnectionsAreRestoredAfterUndo()
        {
            const string newInputName = "newTestInput";
            var          newInput     = new MetaInput(Guid.NewGuid(), newInputName, BasicMetaTypes.FloatMeta, new Float(0.0f), false);

            _operator.Definition.AddInput(newInput);

            var internalOp    = _parentOperator.InternalOps.Find(op => op.Definition.ID == _operator.Definition.ID);
            var internalInput = _operator.Definition.Inputs.Find(input => input.Name == newInputName);
            var inputToRemove = _operator.Inputs.Find(input => input.Name == newInputName);

            _operator.Definition.Connections       = new[] { new MetaConnection(Guid.Empty, internalInput.ID, Guid.Empty, _operator.Definition.Outputs[0].ID) }.ToList();
            _parentOperator.Definition.Connections = new[] { (new MetaConnection(Guid.Empty, _parentOperator.Definition.Inputs[0].ID, internalOp.ID, internalInput.ID)) }.ToList();

            var removeInputCommand = new RemoveInputCommand(_operator, inputToRemove);

            removeInputCommand.Do();
            removeInputCommand.Undo();

            Assert.IsNotNull(_operator.Definition.Connections.Find(connection => connection.SourceOpPartID == internalInput.ID && connection.TargetOpPartID == _operator.Definition.Outputs[0].ID));
            Assert.IsNotNull(_parentOperator.Definition.Connections.Find(connection => connection.TargetOpID == internalOp.ID && connection.TargetOpPartID == internalInput.ID));
        }