public void CircuitStateEndDefinitionTest()
        {
            ProjectTester.InitResources();
            CircuitProject project      = CircuitProject.Create(null);
            CircuitButton  button       = null;
            CircuitSymbol  buttonSymbol = null;
            Gate           led          = null;
            CircuitSymbol  ledSymbol    = null;

            project.InTransaction(() => {
                button       = project.CircuitButtonSet.Create("b", false, PinSide.Right);
                buttonSymbol = project.CircuitSymbolSet.Create(button, project.ProjectSet.Project.LogicalCircuit, 1, 1);
                led          = project.GateSet.Gate(GateType.Led, 1, false);
                ledSymbol    = project.CircuitSymbolSet.Create(led, project.ProjectSet.Project.LogicalCircuit, 5, 1);
            });

            CircuitState   target         = new CircuitState(3);
            int            buttonResult   = target.ReserveState();
            FunctionButton functionButton = new FunctionButton(target, new CircuitSymbol[] { buttonSymbol }, buttonResult);
            FunctionLed    functionLed    = new FunctionLed(target, new CircuitSymbol[] { ledSymbol }, buttonResult);

            target.EndDefinition();

            Assert.IsTrue(functionButton.Dependent != null && functionButton.Dependent.Length == 1 && functionButton.Dependent[0] == functionLed);
            Assert.IsTrue(functionLed.Dependent == null);
        }
        public static CircuitProject Load(TestContext testContext, string projectText, string initialCircuit)
        {
            // First save project text to test directory
            string path = Path.Combine(testContext.TestRunDirectory, string.Format("{0}.{1}.{2}.xml", testContext.FullyQualifiedTestClassName, testContext.TestName, DateTime.UtcNow.Ticks));

            File.WriteAllText(path, projectText, Encoding.UTF8);
            // Load it from test directory
            CircuitProject circuitProject = CircuitProject.Create(path);

            File.Delete(path);
            ProjectTester.InitResources();
            if (initialCircuit != null)
            {
                ProjectTester.SwitchTo(circuitProject, initialCircuit);
            }
            ProjectTester.GuaranteeGlyph(circuitProject);
            return(circuitProject);
        }