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));
        }
 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 CircuitTestSocketBuildTruthTable1Test()
        {
            ProjectTester.SwitchTo(this.CircuitProject, "1 Bit Wire");
            CircuitTestSocket      s1        = new CircuitTestSocket(this.CircuitProject.ProjectSet.Project.LogicalCircuit);
            ExpressionParser       parser    = new ExpressionParser(s1);
            Predicate <TruthState> predicate = parser.Parse("q=x", true);
            double             progress      = -1;
            bool               truncated;
            IList <TruthState> table1 = s1.BuildTruthTable(
                p => { Assert.IsTrue(0 <= p && p <= 100); progress = p; },
                () => true,
                null,
                2,
                out truncated
                );

            Assert.IsTrue(Math.Abs(progress - 100) < 2);
            Assert.IsTrue(!truncated);
            Assert.IsTrue(table1 != null && table1.Count == 2);
            Assert.IsTrue(table1[0].Input[0] == 0 && table1[0].Output[0] == 0);
            Assert.IsTrue(table1[1].Input[0] == 1 && table1[1].Output[0] == 1);

            IList <TruthState> table2 = s1.BuildTruthTable(
                p => { Assert.IsTrue(0 <= p && p <= 100); progress = p; },
                () => true,
                predicate,
                2,
                out truncated
                );

            Assert.IsTrue(Math.Abs(progress - 100) < 2);
            Assert.IsTrue(!truncated);
            Assert.IsTrue(table2 != null && table2.Count == 0);
        }
        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 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");
        }
Пример #7
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");
        }
Пример #8
0
        public void ConvertDescription2NoteTest()
        {
            string projectText = Properties.Resources.From2_0_0_6Conversion;

            this.AssertFileVersion(projectText, "http://LogicCircuit.net/2.0.0.6/CircuitProject.xsd");
            ProjectTester tester = new ProjectTester(this.TestContext, projectText, "Test Circuit");

            Assert.AreEqual("Project Description\n<xml>text</xml>", tester.Project.Note);
            Assert.AreEqual("Test Circuit description\n<xml>node</xml>", tester.Project.LogicalCircuit.Note);
        }
Пример #9
0
        public void SensorSeriesTest()
        {
            ProjectTester tester = new ProjectTester(this.TestContext, Properties.Resources.SensorTests, "Series Test");
            OutputSocket  target = new OutputSocket(tester.Output[0]);

            for (int i = 0; i < 2000; i++)
            {
                Assert.IsTrue(tester.CircuitState.Evaluate(true));
                int result = target.BinaryInt();
                Assert.AreEqual(i < 0x14 ? i * 2 + 1 : 0x27, result);
            }
        }
Пример #10
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);
        }
Пример #11
0
        public void ProbeConvertionTest()
        {
            string projectText = Properties.Resources.ProbeConvertTest;

            this.AssertFileVersion(projectText);
            ProjectTester tester = new ProjectTester(this.TestContext, projectText, null);

            Assert.AreEqual <int>(3, tester.CircuitProject.CircuitProbeSet.Count(), "Expecting 3 probes");
            Assert.AreEqual(3, tester.CircuitProject.CircuitSymbolSet.Where(symbol => symbol.Circuit is CircuitProbe).Count(), "Expecting 3 probe symbols");
            List <CircuitSymbol> symbols = tester.CircuitProject.CircuitProbeSet.Select(probe => tester.CircuitProject.CircuitSymbolSet.SelectByCircuit(probe).First()).ToList();

            Assert.AreEqual(3, symbols.Count);
            Assert.AreEqual(2, symbols.Where(symbol => symbol.LogicalCircuit == tester.CircuitProject.ProjectSet.Project.LogicalCircuit).Count(), "Expecting 2 symbols on main diagram");
        }
Пример #12
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());
        }
Пример #13
0
 private static bool Equal <T>(TableSnapshot <T> x, TableSnapshot <T> y) where T : struct
 {
     return(ProjectTester.EqualCount(x, y) && x.Zip(y, (RowId xr, RowId yr) => {
         T xd, yd;
         x.GetData(xr, out xd);
         y.GetData(yr, out yd);
         foreach (IField <T> field in x.Fields)
         {
             if (field.Compare(ref xd, ref yd) != 0)
             {
                 return false;
             }
         }
         return true;
     }).All(r => r));
 }
Пример #14
0
            public ClockSocket(ProjectTester tester)
            {
                this.Tester = tester;
                Assert.AreEqual(5, this.Tester.Input.Length);
                Assert.AreEqual(3, this.Tester.Output.Length);

                this.clock = new InputSocket(tester.Input[0]);
                this.mPlus = new InputSocket(tester.Input[1]);
                this.hPlus = new InputSocket(tester.Input[2]);
                this.s0    = new InputSocket(tester.Input[2]);
                this.clr   = new InputSocket(tester.Input[3]);

                this.h = new OutputSocket(tester.Output[0]);
                this.m = new OutputSocket(tester.Output[1]);
                this.s = new OutputSocket(tester.Output[2]);
            }
Пример #15
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");
        }
Пример #16
0
        public void SensorRandomTest()
        {
            ProjectTester tester = new ProjectTester(this.TestContext, Properties.Resources.SensorTests, "Random Test");
            OutputSocket  target = new OutputSocket(tester.Output[0]);
            HashSet <int> values = new HashSet <int>();

            for (int i = 0; i < 5000; i++)
            {
                Assert.IsTrue(tester.CircuitState.Evaluate(true));
                values.Add(target.BinaryInt());
            }
            Assert.IsTrue(1 < values.Count);
            int max = 1 << target.BitWidth;

            // If this fail, it is possible to ignore.
            Assert.AreEqual(max, values.Count);
        }
Пример #17
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);
        }
Пример #18
0
        public void CircuitMapDeepWireLoopTest()
        {
            ProjectTester tester = new ProjectTester(this.TestContext, Properties.Resources.CircuitMapTests, "DeepWireLoopTest");
            InputSocket   input  = new InputSocket(tester.Input[0]);
            OutputSocket  target = new OutputSocket(tester.Output[0]);
            Action <int>  test   = value => {
                input.Value = value;
                tester.CircuitState.Evaluate(true);
                Assert.AreEqual(value, target.BinaryInt());
            };

            tester.CircuitProject.InOmitTransaction(() => {
                for (int i = 0; i < 10; i++)
                {
                    test(i & 1);
                }
            });
        }
        public void VisualElementLoadProjectTesterTest()
        {
            ProjectTester tester = new ProjectTester(this.TestContext, Properties.Resources.VisualElementLoadTest, null);

            Assert.AreEqual(1, tester.Input.Length);
            Assert.AreEqual(1, tester.Output.Length);
            Assert.IsTrue(tester.Input.All(f => f != null));
            Assert.IsTrue(tester.Output.All(f => f != null));

            Assert.IsTrue(tester.CircuitState.Evaluate(true));
            Assert.AreEqual(1, tester.Input[0].Value);
            Assert.AreEqual(2, tester.Output[0].Pack());

            tester.CircuitProject.InTransaction(() => tester.Input[0].Value = 0);
            Assert.IsTrue(tester.CircuitState.Evaluate(true));
            Assert.AreEqual(0, tester.Input[0].Value);
            Assert.AreEqual(1, tester.Output[0].Pack());
        }
Пример #20
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);
        }
Пример #21
0
        public ProjectTester(TestContext testContext, string projectText, string initialCircuit)
        {
            this.CircuitProject = ProjectTester.Load(testContext, projectText, initialCircuit);

            // Create map and state
            this.CircuitMap   = new CircuitMap(this.CircuitProject.ProjectSet.Project.LogicalCircuit);
            this.CircuitState = this.CircuitMap.Apply(CircuitRunner.HistorySize);

            // Init controlling points of the main circuit: constants and probes
            List <CircuitSymbol> inputSymbol = new List <CircuitSymbol>();

            foreach (CircuitSymbol symbol in this.Project.LogicalCircuit.CircuitSymbols())
            {
                if (symbol.Circuit is Constant)
                {
                    inputSymbol.Add(symbol);
                }
            }
            CircuitSymbolComparer circuitSymbolComparer = new CircuitSymbolComparer(true);

            inputSymbol.Sort(circuitSymbolComparer);
            this.Input = inputSymbol.Select(s => this.CircuitMap.FunctionConstant(s)).ToArray();

            List <CircuitSymbol> outputSymbol = new List <CircuitSymbol>();

            foreach (CircuitSymbol symbol in this.Project.LogicalCircuit.CircuitSymbols())
            {
                if (symbol.Circuit is CircuitProbe)
                {
                    outputSymbol.Add(symbol);
                }
            }
            outputSymbol.Sort(circuitSymbolComparer);
            this.Output = outputSymbol.Select(s => this.CircuitMap.FunctionProbe(s)).ToArray();

            this.CircuitMap.TurnOn();
        }
Пример #22
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)
                );
        }
        public void CircuitTestSocketBuildTruthTable5Test()
        {
            ProjectTester.SwitchTo(this.CircuitProject, "8 bit adder");
            CircuitTestSocket      s1        = new CircuitTestSocket(this.CircuitProject.ProjectSet.Project.LogicalCircuit);
            ExpressionParser       parser    = new ExpressionParser(s1);
            Predicate <TruthState> predicate = parser.Parse("outC << 8 | s = inC + a + b && v = !(a & 0x80 != b & 0x80 || a & 0x80 == s & 0x80)", true);
            double             progress      = -1;
            bool               truncated;
            int                maxSize = 128;
            IList <TruthState> table1  = s1.BuildTruthTable(
                p => { Assert.IsTrue(0 <= p && p <= 100); progress = p; },
                () => true,
                null,
                maxSize,
                out truncated
                );

            Assert.IsTrue(truncated);
            Assert.IsTrue(table1 != null && table1.Count == maxSize);
            foreach (TruthState state in table1)
            {
                Assert.IsFalse(predicate(state));
            }

            IList <TruthState> table2 = s1.BuildTruthTable(
                p => { Assert.IsTrue(0 <= p && p <= 100); progress = p; },
                () => true,
                predicate,
                1,
                out truncated
                );

            Assert.IsTrue(Math.Abs(progress - 100) < 2);
            Assert.IsTrue(!truncated);
            Assert.IsTrue(table2 != null && table2.Count == 0);
        }
        public void CircuitTestSocketConstructorTest()
        {
            ProjectTester.SwitchTo(this.CircuitProject, "Unconnected");
            CircuitTestSocket s1 = new CircuitTestSocket(this.CircuitProject.ProjectSet.Project.LogicalCircuit);

            Assert.AreEqual(0, s1.Inputs.Count());
            Assert.AreEqual(0, s1.Outputs.Count());

            ProjectTester.SwitchTo(this.CircuitProject, "1 Bit Wire");
            CircuitTestSocket s2 = new CircuitTestSocket(this.CircuitProject.ProjectSet.Project.LogicalCircuit);

            Assert.AreEqual(1, s2.Inputs.Count());
            Assert.AreEqual(1, s2.Outputs.Count());
            Assert.AreEqual(1, s2.Inputs.Sum(i => i.Pin.BitWidth));
            Assert.AreEqual(1, s2.Outputs.Sum(i => i.Pin.BitWidth));

            ProjectTester.SwitchTo(this.CircuitProject, "8 bit adder");
            CircuitTestSocket s3 = new CircuitTestSocket(this.CircuitProject.ProjectSet.Project.LogicalCircuit);

            Assert.AreEqual(3, s3.Inputs.Count());
            Assert.AreEqual(3, s3.Outputs.Count());
            Assert.AreEqual(17, s3.Inputs.Sum(i => i.Pin.BitWidth));
            Assert.AreEqual(10, s3.Outputs.Sum(i => i.Pin.BitWidth));
        }
 public TestSocket(ProjectTester tester)
 {
     this.Tester = tester;
     Assert.IsTrue(this.Tester.Input.Length == this.Tester.Output.Length);
 }
Пример #26
0
 public FunctionSocket(ProjectTester tester)
 {
     this.Tester = tester;
     Assert.IsTrue(this.Tester.Input.Length <= 32);
 }