Пример #1
0
        public void CreateAndUpdateProcedure()
        {
            // Arrange
            Token temp = new Token(10, 15);

            ArrangementProcedure procedure1 = new ArrangementProcedure();

            procedure1.AddToken(temp, 0);
            procedure1.AddResorce(new WorkerResource());
            procedure1.AddResorce(new CadResource());
            procedure1.AddResorce(new TechincalSupportResource());
            procedure1.Update(new ModelingTime());

            ArrangementProcedure procedure2;

            // Act
            procedure2 = SaveTester <ArrangementProcedure> .StartSaveTest(procedure1);

            // Asserts
            Assert.AreEqual((procedure1).Description, (procedure2).Description);
            Assert.AreEqual((procedure1).InputQuantity, (procedure2).InputQuantity);
            Assert.AreEqual((procedure1).OutputQuantity, (procedure2).OutputQuantity);
            Assert.AreEqual((procedure1).ResourceCount, (procedure2).ResourceCount);
            Assert.AreEqual((procedure1).TokenCollector, (procedure2).TokenCollector);
        }
Пример #2
0
        public void SaveSubProcessTest()
        {
            Process process    = new Process();
            Process subprocess = new Process();

            TracingProcedure procedure = new TracingProcedure();

            procedure.AddResorce(new CadResource());
            procedure.AddResorce(new WorkerResource());
            procedure.AddResorce(new TechincalSupportResource());

            ArrangementProcedure procedure2 = new ArrangementProcedure();

            procedure2.AddResorce(new CadResource());
            procedure2.AddResorce(new WorkerResource());
            procedure2.AddResorce(new TechincalSupportResource());

            subprocess.Blocks.Add(procedure);
            subprocess.Blocks.Add(procedure2);
            subprocess.Connections.Connect(procedure, 0, procedure2, 0);

            subprocess.StartBlock = procedure;
            subprocess.EndBlock   = procedure2;

            process.Blocks.Add(subprocess);
            process.StartBlock = subprocess;
            process.EndBlock   = subprocess;


            //act

            //добавляем на стартовый блок токен
            process.AddToken(new Token(0, complexity: 1), 0);
            //double i = 0;
            ModelingTime modelingTime = new ModelingTime()
            {
                Delta = 1, Now = 0
            };

            //цикл до тех пор, пока на выходе не появится токен
            for (modelingTime.Now = 0; modelingTime.Now < 1000 && !process.EndBlockHasOutputToken; modelingTime.Now += modelingTime.Delta)
            {
                process.Update(modelingTime);
            }

            Process process2 = SaveTester <Process> .StartSaveTest(process);

            // Asserts
            Assert.AreEqual(process, process2);
        }
Пример #3
0
        public void UpdateWithResTest()
        {
            // arrange
            ArrangementProcedure procedure = new ArrangementProcedure();

            procedure.AddResorce(new WorkerResource()
            {
                //Name = "Alleshka",
                //Position = "Работяга",
                WorkerQualification = Qualification.FirstCategory
            });
            procedure.AddResorce(new CadResource()
            {
            });
            procedure.AddResorce(new TechincalSupportResource()
            {
                Frequency = 1.5,
                Ram       = 2,
                Vram      = 1
            });
            procedure.AddToken(new Token(bornTime: 0, complexity: 1000), 0);
            Token token = null;

            // act
            ModelingTime modelingTime = new ModelingTime()
            {
                Delta = 1, Now = 0
            };

            for (modelingTime.Now = 0; modelingTime.Now < 40 && token == null; modelingTime.Now += modelingTime.Delta)
            {
                procedure.Update(modelingTime);
                token = procedure.GetOutputToken(0);
                procedure.ClearOutputs();
            }

            // Asserts
            Assert.AreNotEqual(token, null);
            if (modelingTime.Now < 10 || modelingTime.Now > 11)
            {
                Assert.Fail();
            }
        }