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);
        }
 private void AssertTestable(CircuitProject project, string circuitName, bool isTestable)
 {
     ProjectTester.SwitchTo(project, circuitName);
     Assert.AreEqual(isTestable, CircuitTestSocket.IsTestable(project.ProjectSet.Project.LogicalCircuit),
                     "{0} should {1}be testable", project.ProjectSet.Project.LogicalCircuit.Name, isTestable ? "" : "not "
                     );
 }
        public void ConductorMapTwoWiresTwoConductorTest()
        {
            CircuitProject project = CircuitProject.Create(null);
            LogicalCircuit circuit = project.ProjectSet.Project.LogicalCircuit;
            Wire           wire1   = null;
            Wire           wire2   = null;

            project.InTransaction(() => wire1 = project.WireSet.Create(circuit, new GridPoint(1, 2), new GridPoint(3, 4)));
            project.InTransaction(() => wire2 = project.WireSet.Create(circuit, new GridPoint(5, 6), new GridPoint(7, 8)));
            Assert.IsNotNull(wire1);
            Assert.IsNotNull(wire2);

            ConductorMap target = new ConductorMap(circuit);

            Assert.AreEqual(2, target.Conductors.Count());

            Conductor conductor1;

            Assert.IsTrue(target.TryGetValue(new GridPoint(3, 4), out conductor1));
            Assert.AreEqual(1, conductor1.Wires.Count());
            Assert.AreEqual(2, conductor1.Points.Count());

            Conductor conductor2;

            Assert.IsTrue(target.TryGetValue(new GridPoint(3, 4), out conductor2));
            Assert.AreEqual(1, conductor2.Wires.Count());
            Assert.AreEqual(2, conductor2.Points.Count());
        }
        public void ConductorMapThreeWiresJoinTest()
        {
            CircuitProject project = CircuitProject.Create(null);
            LogicalCircuit circuit = project.ProjectSet.Project.LogicalCircuit;
            Wire           wire1   = null;
            Wire           wire2   = null;
            Wire           wire3   = null;

            project.InTransaction(() => wire1 = project.WireSet.Create(circuit, new GridPoint(1, 2), new GridPoint(3, 4)));
            project.InTransaction(() => wire2 = project.WireSet.Create(circuit, new GridPoint(5, 6), new GridPoint(7, 8)));

            ConductorMap target0 = new ConductorMap(circuit);

            Assert.AreEqual(2, target0.Conductors.Count());

            project.InTransaction(() => wire3 = project.WireSet.Create(circuit, new GridPoint(5, 6), new GridPoint(1, 2)));

            ConductorMap target = new ConductorMap(circuit);

            Assert.AreEqual(1, target.Conductors.Count());
            Conductor conductor;

            Assert.IsTrue(target.TryGetValue(new GridPoint(7, 8), out conductor));
            Assert.AreEqual(3, conductor.Wires.Count());
            Assert.AreEqual(4, conductor.Points.Count());
        }
        public void GraphicsArrayAddressBitWidthTest()
        {
            CircuitProject project = CircuitProject.Create(null);
            GraphicsArray  target  = null;

            project.InTransaction(() => {
                target = project.GraphicsArraySet.Create(1, 1, 1, 1);
                project.CircuitSymbolSet.Create(target, project.ProjectSet.Project.LogicalCircuit, 10, 10);
            });
            Assert.IsNotNull(target);
            Assert.AreEqual(1, target.AddressBitWidth);

            Func <int, int, int, int, int> abw = (int dataBitWidth, int bpp, int w, int h) => {
                project.InTransaction(() => {
                    target.DataBitWidth = dataBitWidth;
                    target.BitsPerPixel = bpp;
                    target.Width        = w;
                    target.Height       = h;
                });
                return(target.AddressBitWidth);
            };

            Assert.AreEqual(5, abw(8, 1, 10, 10));
            Assert.AreEqual(7, abw(1, 1, 10, 10));
            Assert.AreEqual(10, abw(1, 8, 10, 10));
            Assert.AreEqual(13, abw(8, 1, 320, 200));
            Assert.AreEqual(15, abw(8, 4, 320, 200));
            Assert.AreEqual(16, abw(8, 8, 320, 200));
            Assert.AreEqual(19, abw(8, GraphicsArray.MaxBitsPerPixel, GraphicsArray.MaxWidth, GraphicsArray.MaxHeight));
            Assert.AreEqual(22, abw(1, GraphicsArray.MaxBitsPerPixel, GraphicsArray.MaxWidth, GraphicsArray.MaxHeight));
        }
        public void CircuitProjectSaveLoadTest()
        {
            string dir  = Path.Combine(this.TestContext.TestRunDirectory, this.TestContext.TestName + DateTime.UtcNow.Ticks, "Some Test Sub Directory");
            string file = Path.Combine(dir, "My Test File.CircuitProject");

            // save in inexistent folder
            CircuitProject project1 = CircuitProject.Create(null);

            project1.InTransaction(() => {
                LogicalCircuit main        = project1.ProjectSet.Project.LogicalCircuit;
                CircuitButton button       = project1.CircuitButtonSet.Create("b", false, PinSide.Right);
                CircuitSymbol buttonSymbol = project1.CircuitSymbolSet.Create(button, main, 1, 2);
                Gate led = project1.GateSet.Gate(GateType.Led, 1, false);
                project1.CircuitSymbolSet.Create(led, main, 6, 2);
                Wire wire = project1.WireSet.Create(main, new GridPoint(3, 3), new GridPoint(6, 3));
            });
            Assert.IsTrue(!Directory.Exists(dir));
            project1.Save(file);
            Assert.IsTrue(File.Exists(file));
            CircuitProject project2 = CircuitProject.Create(file);

            Assert.IsTrue(ProjectTester.Equal(project1, project2));

            // save in existing folder and existing file.
            CircuitProject project3 = ProjectTester.Load(this.TestContext, Properties.Resources.Digital_Clock, null);

            Assert.IsTrue(File.Exists(file));
            project3.Save(file);
            CircuitProject project4 = CircuitProject.Create(file);

            File.Delete(file);
            Assert.IsTrue(ProjectTester.Equal(project3, project4));
        }
Пример #7
0
 private static void GuaranteeGlyph(CircuitProject circuitProject)
 {
     foreach (CircuitSymbol symbol in circuitProject.ProjectSet.Project.LogicalCircuit.CircuitSymbols())
     {
         symbol.GuaranteeGlyph();
     }
 }
        public void ExpressionParserVariableParseTest()
        {
            CircuitProject    project = ProjectTester.Load(this.TestContext, Properties.Resources.Digital_Clock, "4 bit adder");
            CircuitTestSocket socket  = new CircuitTestSocket(project.ProjectSet.Project.LogicalCircuit);
            ExpressionParser  parser  = new ExpressionParser(socket);
            TruthState        state   = new TruthState(socket.Inputs.Count(), socket.Outputs.Count());

            for (int i = 0; i < state.Result.Length; i++)
            {
                state.Result[i] = 0x5555555555555555L;
            }
            bool success = state.Unpack(socket.Outputs.Select(o => o.Function.ParameterCount).ToArray());

            Assert.IsTrue(success);

            state.Input[this.InputIndex(socket, "c")]    = 1;
            state.Input[this.InputIndex(socket, "x1")]   = 5;
            state.Input[this.InputIndex(socket, "x2")]   = 4;
            state.Output[this.OutputIndex(socket, "s")]  = 9;
            state.Output[this.OutputIndex(socket, "c'")] = 1;

            this.Valid(parser, state, 1, "c");
            this.Valid(parser, state, 5, "x1");
            this.Valid(parser, state, 4, "x2");
            this.Valid(parser, state, 9, "s");
            this.Valid(parser, state, 1, "\"c'\"");

            this.Invalid(parser, state, "d");
            this.Invalid(parser, state, "\"c'");
            this.Invalid(parser, state, "\"c'\\");
            this.Invalid(parser, state, "\"c'\\\"\"");
        }
        public void ExpressionParserVariableCaseParseTest()
        {
            CircuitProject project = ProjectTester.Load(this.TestContext, Properties.Resources.Digital_Clock, "4 bit adder");
            Pin            x1 = null, x2 = null, s = null, c = null;

            foreach (Pin pin in project.PinSet.SelectByCircuit(project.ProjectSet.Project.LogicalCircuit))
            {
                switch (pin.Name)
                {
                case "x1":
                    x1 = pin;
                    break;

                case "x2":
                    x2 = pin;
                    break;

                case "s":
                    s = pin;
                    break;

                case "c'":
                    c = pin;
                    break;
                }
            }
            Assert.IsNotNull(x1);
            Assert.IsNotNull(x2);
            Assert.IsNotNull(s);
            Assert.IsNotNull(c);
            project.InTransaction(() => {
                x1.Name = "variant";
                x2.Name = "vaRIAnt";
                s.Name  = "VAriaNT";
                c.Name  = "VARIANT";
            });

            CircuitTestSocket socket = new CircuitTestSocket(project.ProjectSet.Project.LogicalCircuit);
            ExpressionParser  parser = new ExpressionParser(socket);
            TruthState        state  = new TruthState(socket.Inputs.Count(), socket.Outputs.Count());

            for (int i = 0; i < state.Result.Length; i++)
            {
                state.Result[i] = 0x5555555555555555L;
            }
            state.Unpack(socket.Outputs.Select(o => o.Function.ParameterCount).ToArray());

            state.Input[this.InputIndex(socket, "c")]         = 1;
            state.Input[this.InputIndex(socket, "variant")]   = 5;
            state.Input[this.InputIndex(socket, "vaRIAnt")]   = 4;
            state.Output[this.OutputIndex(socket, "VAriaNT")] = 9;
            state.Output[this.OutputIndex(socket, "VARIANT")] = 1;

            this.Valid(parser, state, 1, "c");
            this.Valid(parser, state, 5, "variant");
            this.Valid(parser, state, 4, "vaRIAnt");
            this.Valid(parser, state, 9, "VAriaNT");
            this.Valid(parser, state, 1, "VARIANT");
        }
Пример #10
0
 // Constructor
 public CircuitButton(CircuitProject store, RowId rowIdCircuitButton, RowId rowIdCircuit) : base(store, rowIdCircuit)
 {
     Debug.Assert(!rowIdCircuitButton.IsEmpty);
     this.CircuitButtonRowId = rowIdCircuitButton;
     // Link back to record. Assuming that a transaction is started
     this.Table.SetField(this.CircuitButtonRowId, CircuitButtonData.CircuitButtonField.Field, this);
     this.InitializeCircuitButton();
 }
Пример #11
0
 // Constructor
 public Gate(CircuitProject store, RowId rowIdGate, RowId rowIdCircuit) : base(store, rowIdCircuit)
 {
     Debug.Assert(!rowIdGate.IsEmpty);
     this.GateRowId = rowIdGate;
     // Link back to record. Assuming that a transaction is started
     this.Table.SetField(this.GateRowId, GateData.GateField.Field, this);
     this.InitializeGate();
 }
        public void ConductorMapEmptyTest()
        {
            CircuitProject project = CircuitProject.Create(null);
            LogicalCircuit circuit = project.ProjectSet.Project.LogicalCircuit;
            ConductorMap   target  = new ConductorMap(circuit);

            Assert.AreEqual(0, target.Conductors.Count());
        }
Пример #13
0
 // Constructor
 public Sound(CircuitProject store, RowId rowIdSound, RowId rowIdCircuit) : base(store, rowIdCircuit)
 {
     Debug.Assert(!rowIdSound.IsEmpty);
     this.SoundRowId = rowIdSound;
     // Link back to record. Assuming that a transaction is started
     this.Table.SetField(this.SoundRowId, SoundData.SoundField.Field, this);
     this.InitializeSound();
 }
Пример #14
0
 // Constructor
 public Sensor(CircuitProject store, RowId rowIdSensor, RowId rowIdCircuit) : base(store, rowIdCircuit)
 {
     Debug.Assert(!rowIdSensor.IsEmpty);
     this.SensorRowId = rowIdSensor;
     // Link back to record. Assuming that a transaction is started
     this.Table.SetField(this.SensorRowId, SensorData.SensorField.Field, this);
     this.InitializeSensor();
 }
Пример #15
0
 // Constructor
 public Constant(CircuitProject store, RowId rowIdConstant, RowId rowIdCircuit) : base(store, rowIdCircuit)
 {
     Debug.Assert(!rowIdConstant.IsEmpty);
     this.ConstantRowId = rowIdConstant;
     // Link back to record. Assuming that a transaction is started
     this.Table.SetField(this.ConstantRowId, ConstantData.ConstantField.Field, this);
     this.InitializeConstant();
 }
Пример #16
0
 // Constructor
 public LogicalCircuit(CircuitProject store, RowId rowIdLogicalCircuit, RowId rowIdCircuit) : base(store, rowIdCircuit)
 {
     Debug.Assert(!rowIdLogicalCircuit.IsEmpty);
     this.LogicalCircuitRowId = rowIdLogicalCircuit;
     // Link back to record. Assuming that a transaction is started
     this.Table.SetField(this.LogicalCircuitRowId, LogicalCircuitData.LogicalCircuitField.Field, this);
     this.InitializeLogicalCircuit();
 }
Пример #17
0
 // Constructor
 public GraphicsArray(CircuitProject store, RowId rowIdGraphicsArray, RowId rowIdCircuit) : base(store, rowIdCircuit)
 {
     Debug.Assert(!rowIdGraphicsArray.IsEmpty);
     this.GraphicsArrayRowId = rowIdGraphicsArray;
     // Link back to record. Assuming that a transaction is started
     this.Table.SetField(this.GraphicsArrayRowId, GraphicsArrayData.GraphicsArrayField.Field, this);
     this.InitializeGraphicsArray();
 }
Пример #18
0
 // Constructor
 protected Circuit(CircuitProject store, RowId rowIdCircuit)
 {
     Debug.Assert(!rowIdCircuit.IsEmpty);
     this.CircuitProject = store;
     this.CircuitRowId   = rowIdCircuit;
     // Link back to record. Assuming that a transaction is started
     this.Table.SetField(this.CircuitRowId, CircuitData.CircuitField.Field, this);
     this.InitializeCircuit();
 }
Пример #19
0
        private void CircuitMapCleanUpTest(CircuitProject circuitProject, string logicalCircuitName, int expectedFunctions)
        {
            ProjectTester.SwitchTo(circuitProject, logicalCircuitName);

            CircuitMap   map   = new CircuitMap(circuitProject.ProjectSet.Project.LogicalCircuit);
            CircuitState state = map.Apply(CircuitRunner.HistorySize);

            Assert.AreEqual(expectedFunctions, state.Functions.Count(), "wrong number of functions");
        }
Пример #20
0
        public static LogicalCircuit SwitchTo(CircuitProject circuitProject, string logicalCircuitName)
        {
            Assert.IsNotNull(logicalCircuitName);
            LogicalCircuit circuit = circuitProject.LogicalCircuitSet.FindByName(logicalCircuitName);

            Assert.IsNotNull(circuit, "Circuit {0} not found in the project", logicalCircuitName);
            if (circuitProject.ProjectSet.Project.LogicalCircuit != circuit)
            {
                circuitProject.InOmitTransaction(() => circuitProject.ProjectSet.Project.LogicalCircuit = circuit);
            }
            ProjectTester.GuaranteeGlyph(circuitProject);
            return(circuit);
        }
Пример #21
0
        // Constructor
        public GraphicsArraySet(CircuitProject store)
        {
            ITableSnapshot table = store.Table("GraphicsArray");

            if (table != null)
            {
                Debug.Assert(store.IsFrozen, "The store should be frozen");
                this.Table = (TableSnapshot <GraphicsArrayData>)table;
            }
            else
            {
                Debug.Assert(!store.IsFrozen, "In order to create table, the store should not be frozen");
                this.Table = GraphicsArrayData.CreateTable(store);
            }
            this.InitializeGraphicsArraySet();
        }
Пример #22
0
        public void CircuitMapCleanUpTest()
        {
            CircuitProject circuitProject = ProjectTester.Load(this.TestContext, Properties.Resources.CircuitMapCleanUpTest, null);

            this.CircuitMapCleanUpTest(circuitProject, "1. Empty 1", 0);
            Assert.AreEqual(0, circuitProject.ProjectSet.Project.LogicalCircuit.CircuitSymbols().Count());

            this.CircuitMapCleanUpTest(circuitProject, "2. Empty 2", 0);
            Assert.AreEqual(7, circuitProject.ProjectSet.Project.LogicalCircuit.CircuitSymbols().Count());

            this.CircuitMapCleanUpTest(circuitProject, "3. Single Out", 3);
            Assert.AreEqual(4, circuitProject.ProjectSet.Project.LogicalCircuit.CircuitSymbols().Count());

            this.CircuitMapCleanUpTest(circuitProject, "4. Chain Out", 8);
            Assert.AreEqual(11, circuitProject.ProjectSet.Project.LogicalCircuit.CircuitSymbols().Count());
        }
Пример #23
0
        // Constructor
        public LogicalCircuitSet(CircuitProject store)
        {
            ITableSnapshot table = store.Table("LogicalCircuit");

            if (table != null)
            {
                Debug.Assert(store.IsFrozen, "The store should be frozen");
                this.Table = (TableSnapshot <LogicalCircuitData>)table;
            }
            else
            {
                Debug.Assert(!store.IsFrozen, "In order to create table, the store should not be frozen");
                this.Table = LogicalCircuitData.CreateTable(store);
            }
            this.InitializeLogicalCircuitSet();
        }
Пример #24
0
        private void CircuitMapPerfTest(string project, string initialCircuit, int maxCount, int maxSeconds)
        {
            CircuitProject circuitProject = ProjectTester.Load(this.TestContext, project, initialCircuit);
            Stopwatch      stopwatch      = new Stopwatch();

            stopwatch.Start();
            for (int i = 0; i < maxCount; i++)
            {
                CircuitMap   circuitMap   = new CircuitMap(circuitProject.ProjectSet.Project.LogicalCircuit);
                CircuitState circuitState = circuitMap.Apply(CircuitRunner.HistorySize);
                Assert.IsNotNull(circuitState);
                circuitMap.TurnOn();
            }
            stopwatch.Stop();
            this.TestContext.WriteLine("{0} CircuitMap(s) created and applied in {1} - {2:N2} sec per each map", maxCount, stopwatch.Elapsed, stopwatch.Elapsed.TotalSeconds / maxCount);
            Assert.IsTrue(stopwatch.Elapsed < new TimeSpan(0, 0, maxSeconds), "CircuitMap was created and applied successfully but too slow");
        }
        public void CircuitProjectCreateItemsTest()
        {
            CircuitProject project = new CircuitProject();

            Assert.IsTrue(project.StartTransaction());
            LogicalCircuit logicalCircuit = project.LogicalCircuitSet.Create();
            Pin            pin1           = project.PinSet.Create(logicalCircuit, PinType.Input, 1);
            Pin            pin2           = project.PinSet.Create(logicalCircuit, PinType.Output, 10);

            Assert.AreEqual(1, project.LogicalCircuitSet.Count());
            Assert.AreEqual(2, project.PinSet.Count());
            Assert.AreEqual(2, project.DevicePinSet.Count());

            Constant constant = project.ConstantSet.Create(3, 7, PinSide.Right);

            Assert.AreEqual(1, project.ConstantSet.Count());
            Assert.AreEqual(3, project.DevicePinSet.Count());

            CircuitButton button = project.CircuitButtonSet.Create("a", false, PinSide.Right);

            Assert.AreEqual(1, project.CircuitButtonSet.Count());
            Assert.AreEqual(4, project.DevicePinSet.Count());

            Memory rom = project.MemorySet.Create(false, 2, 8);

            Assert.AreEqual(1, project.MemorySet.Count());
            Assert.AreEqual(6, project.DevicePinSet.Count());

            Memory ram = project.MemorySet.Create(true, 4, 4);

            Assert.AreEqual(2, project.MemorySet.Count());
            Assert.AreEqual(10, project.DevicePinSet.Count());

            Splitter splitter = project.SplitterSet.Create(8, 4, true);

            Assert.AreEqual(1, project.SplitterSet.Count());
            Assert.AreEqual(15, project.DevicePinSet.Count());

            CircuitSymbol symbol = project.CircuitSymbolSet.Create(constant, logicalCircuit, 10, 15);

            Assert.AreEqual(1, project.CircuitSymbolSet.Count());

            Wire wire = project.WireSet.Create(logicalCircuit, new GridPoint(10, 20), new GridPoint(30, 40));

            Assert.AreEqual(1, project.WireSet.Count());
        }
Пример #26
0
        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);
        }
        public void ConductorMapOneWireTest()
        {
            CircuitProject project = CircuitProject.Create(null);
            LogicalCircuit circuit = project.ProjectSet.Project.LogicalCircuit;
            Wire           wire    = null;

            project.InTransaction(() => wire = project.WireSet.Create(circuit, new GridPoint(1, 2), new GridPoint(3, 4)));
            Assert.IsNotNull(wire);
            ConductorMap target = new ConductorMap(circuit);

            Assert.AreEqual(1, target.Conductors.Count());
            Conductor conductor;
            bool      success = target.TryGetValue(new GridPoint(3, 4), out conductor);

            Assert.IsTrue(success);
            Assert.AreEqual(1, conductor.Wires.Count());
            Assert.AreSame(wire, conductor.Wires.First());
        }
        public void CircuitProjectCreateTest()
        {
            CircuitProject target = new CircuitProject();

            Assert.IsTrue(target.IsFrozen);
            Assert.IsFalse(target.ProjectSet.Any());
            Assert.IsFalse(target.CircuitSet.Any());
            Assert.IsFalse(target.DevicePinSet.Any());
            Assert.IsFalse(target.GateSet.Any());
            Assert.IsFalse(target.LogicalCircuitSet.Any());
            Assert.IsFalse(target.PinSet.Any());
            Assert.IsFalse(target.ConstantSet.Any());
            Assert.IsFalse(target.CircuitButtonSet.Any());
            Assert.IsFalse(target.MemorySet.Any());
            Assert.IsFalse(target.SplitterSet.Any());
            Assert.IsFalse(target.CircuitSymbolSet.Any());
            Assert.IsFalse(target.WireSet.Any());

            Assert.IsTrue(target.StartTransaction());
        }
Пример #29
0
        public void XmlLoadReadElementTextTest()
        {
            string      text = Properties.Resources.XmlLoadReadElementTextTest;
            XmlDocument xml  = new XmlDocument();

            xml.LoadXml(text);
            Assert.AreEqual(@"http://LogicCircuit.net/1.0.0.2/CircuitProject.xsd", xml.DocumentElement.NamespaceURI);

            CircuitProject circuitProject = ProjectTester.Load(this.TestContext, text, null);

            Assert.IsNotNull(circuitProject);

            Assert.AreEqual(1, circuitProject.CircuitButtonSet.Count());
            CircuitButton button = circuitProject.CircuitButtonSet.First();

            Assert.AreEqual(@"<a>", button.Notation);
            Assert.AreEqual(@"<a>b</a>", button.Note);
            Assert.AreEqual(1, circuitProject.CircuitSymbolSet.SelectByCircuit(button).Count());
            CircuitSymbol buttonSymbol = circuitProject.CircuitSymbolSet.SelectByCircuit(button).First();

            Assert.AreEqual(3, buttonSymbol.X);
            Assert.AreEqual(8, buttonSymbol.Y);

            Assert.AreEqual(2, circuitProject.CircuitSymbolSet.Count());
            CircuitSymbol ledSymbol = circuitProject.CircuitSymbolSet.First(s => s != buttonSymbol);

            Assert.IsNotNull(ledSymbol);
            Assert.AreEqual(9, ledSymbol.X);
            Assert.AreEqual(8, ledSymbol.Y);

            Assert.AreEqual(1, circuitProject.WireSet.Count());
            Wire wire = circuitProject.WireSet.First();

            Assert.IsNotNull(wire);
            Assert.AreEqual(5, wire.X1);
            Assert.AreEqual(9, wire.Y1);
            Assert.AreEqual(9, wire.X2);
            Assert.AreEqual(9, wire.Y1);
        }
Пример #30
0
        public static bool Equal(CircuitProject x, CircuitProject y)
        {
            Assert.IsNotNull(x);
            Assert.IsNotNull(y);

            return(
                ProjectTester.Equal(x.ProjectSet.Table, y.ProjectSet.Table) &&
                ProjectTester.Equal(x.CollapsedCategorySet.Table, y.CollapsedCategorySet.Table) &&
                ProjectTester.EqualCount(x.CircuitSet.Table, y.CircuitSet.Table) &&
                ProjectTester.EqualCount(x.DevicePinSet.Table, y.DevicePinSet.Table) &&
                ProjectTester.EqualCount(x.GateSet.Table, y.GateSet.Table) &&
                ProjectTester.Equal(x.LogicalCircuitSet.Table, y.LogicalCircuitSet.Table) &&
                ProjectTester.Equal(x.PinSet.Table, y.PinSet.Table) &&
                ProjectTester.Equal(x.ConstantSet.Table, y.ConstantSet.Table) &&
                ProjectTester.Equal(x.ConstantSet.Table, y.ConstantSet.Table) &&
                ProjectTester.Equal(x.CircuitButtonSet.Table, y.CircuitButtonSet.Table) &&
                ProjectTester.Equal(x.MemorySet.Table, y.MemorySet.Table) &&
                ProjectTester.Equal(x.LedMatrixSet.Table, y.LedMatrixSet.Table) &&
                ProjectTester.Equal(x.SplitterSet.Table, y.SplitterSet.Table) &&
                ProjectTester.Equal(x.CircuitSymbolSet.Table, y.CircuitSymbolSet.Table) &&
                ProjectTester.Equal(x.WireSet.Table, y.WireSet.Table) &&
                ProjectTester.Equal(x.TextNoteSet.Table, y.TextNoteSet.Table)
                );
        }