示例#1
0
        public void MakePetriNetWithCycleTest()
        {
            // Arrange
            ImportedEventLog elog = CSVImport.MakeDataFrame(cycleNetCsv);

            elog.SetActivity("act");
            elog.SetCaseId("id");
            WorkflowLog    wlog       = new WorkflowLog(elog);
            RelationMatrix matrix     = new RelationMatrix(wlog);
            IPetriNet      exampleNet = PNMLImport.Deserialize(cycleNetPnml);

            // Act
            IPetriNet madeNet = Alpha.MakePetriNet(matrix);

            // Assert
            Assert.IsNotNull(exampleNet);
            Assert.AreEqual(exampleNet.EndPlace.Id, madeNet.EndPlace.Id);
            Assert.AreEqual(exampleNet.StartPlace.Id, madeNet.StartPlace.Id);
            Assert.AreEqual(exampleNet.Places.Count, madeNet.Places.Count);
            Assert.AreEqual(exampleNet.Transitions.Count, madeNet.Transitions.Count);

            foreach (IPlace p in exampleNet.Places)
            {
                Assert.IsTrue(madeNet.Places.Exists(a => a.Id == p.Id));
            }
            foreach (ITransition t in exampleNet.Transitions)
            {
                Assert.IsTrue(madeNet.Transitions.Exists(a => a.Id == t.Id &&
                                                         a.Activity == t.Activity &&
                                                         a.InputPlaces.Count == t.InputPlaces.Count &&
                                                         a.OutputPlaces.Count == t.OutputPlaces.Count));
            }
        }
示例#2
0
        public void PNMLExportTest()
        {
            // Arrange
            IPetriNet loadedNet;
            IPetriNet exampleNet = MakeEasyPetriNet();

            // Act
            string filepath = "." + separator + PNMLExport.Serialize(exampleNet);

            loadedNet = PNMLImport.Deserialize(filepath);

            // Assert
            Assert.IsNotNull(loadedNet);
            Assert.AreEqual(loadedNet.EndPlace.Id, exampleNet.EndPlace.Id);
            Assert.AreEqual(loadedNet.StartPlace.Id, exampleNet.StartPlace.Id);
            Assert.AreEqual(loadedNet.Places.Count, exampleNet.Places.Count);
            Assert.AreEqual(loadedNet.Transitions.Count, exampleNet.Transitions.Count);

            foreach (IPlace p in loadedNet.Places)
            {
                exampleNet.Places.Exists(a => a.Id == p.Id);
            }
            foreach (ITransition t in loadedNet.Transitions)
            {
                exampleNet.Transitions.Exists(a => a.Id == t.Id &&
                                              a.Activity == t.Activity &&
                                              a.InputPlaces.Count == t.InputPlaces.Count &&
                                              a.OutputPlaces.Count == t.OutputPlaces.Count);
            }

            // Cleanup
            File.Delete(filepath);
        }
示例#3
0
        public void PNMLImportTest()
        {
            // Arrange
            IPetriNet loadedNet;
            IPetriNet exampleNet = MakeEasyPetriNet();

            // Act
            loadedNet = PNMLImport.Deserialize(PNMLpath);

            // Assert
            Assert.IsNotNull(loadedNet);
            Assert.AreEqual(loadedNet.EndPlace.Id, exampleNet.EndPlace.Id);
            Assert.AreEqual(loadedNet.StartPlace.Id, exampleNet.StartPlace.Id);
            Assert.AreEqual(loadedNet.Places.Count, exampleNet.Places.Count);
            Assert.AreEqual(loadedNet.Transitions.Count, exampleNet.Transitions.Count);

            foreach (IPlace p in loadedNet.Places)
            {
                Assert.IsTrue(exampleNet.Places.Exists(a => a.Id == p.Id));
            }
            foreach (ITransition t in loadedNet.Transitions)
            {
                Assert.IsTrue(exampleNet.Transitions.Exists(a => a.Id == t.Id &&
                                                            a.Activity == t.Activity &&
                                                            a.InputPlaces.Count == t.InputPlaces.Count &&
                                                            a.OutputPlaces.Count == t.OutputPlaces.Count));
            }
        }
示例#4
0
 private IPetriNet MakeCycleNetPetriNet()
 {
     return(PNMLImport.Deserialize(cycleNetCorrectPnml));
 }