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));
        }
Пример #2
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)
                );
        }