예제 #1
0
        public void GetVariablesRetrievesAListWithTFStageVariableArrayAndT()
        {
            var variables = new List <Variable>
            {
                new Variable {
                    ActualValue = 0, InitialValue = 0, Name = "T"
                },
                new Variable {
                    ActualValue = 0, InitialValue = 50000, Name = "TF"
                },
                new VariableArray {
                    Name = "NS", Variables = new List <Variable> {
                        new Variable {
                            Name = "NS", InitialValue = 0, ActualValue = 0
                        }
                    }
                }
            };

            var simulation = new Mock <ISimulation>();

            simulation.Setup(x => x.GetDiagrams()).Returns(new List <Diagram>());
            simulation.Setup(x => x.GetVariables()).Returns(variables);

            var stageSimulation = new StageSimulation(simulation.Object);

            List <StageVariable> result = stageSimulation.GetVariables();

            Assert.AreEqual(3, result.Count);
            Assert.AreEqual("T", result.ElementAt(0).Name);
            Assert.AreEqual("TF", result.ElementAt(1).Name);
            Assert.AreEqual("NS", result.ElementAt(2).Name);
        }
예제 #2
0
        public void CanContinueReturnsTrue()
        {
            var variables = new List <Variable>
            {
                new Variable {
                    ActualValue = 0, InitialValue = 0, Name = "T"
                },
                new Variable {
                    ActualValue = 0, InitialValue = 50000, Name = "TF"
                },
                new VariableArray {
                    Name = "NS", Variables = new List <Variable> {
                        new Variable {
                            Name = "NS", InitialValue = 0, ActualValue = 0
                        }
                    }
                }
            };

            var simulation = new Mock <ISimulation>();

            simulation.Setup(x => x.GetDiagrams()).Returns(new List <Diagram>());
            simulation.Setup(x => x.GetVariables()).Returns(variables);
            simulation.Setup(x => x.CanContinue()).Returns(true);

            var stageSimulation = new StageSimulation(simulation.Object);

            Assert.IsTrue(stageSimulation.CanContinue());
        }
예제 #3
0
        public void GetExecutionStatusOk()
        {
            var variables = new List <Variable>
            {
                new Variable {
                    ActualValue = 0, InitialValue = 0, Name = "T"
                },
                new Variable {
                    ActualValue = 0, InitialValue = 50000, Name = "TF"
                },
                new VariableArray {
                    Name = "NS", Variables = new List <Variable> {
                        new Variable {
                            Name = "NS", InitialValue = 0, ActualValue = 0
                        }
                    }
                }
            };

            var simulation = new Mock <ISimulation>();

            simulation.Setup(x => x.GetDiagrams()).Returns(new List <Diagram>());
            simulation.Setup(x => x.GetVariables()).Returns(variables);

            var stageSimulation = new StageSimulation(simulation.Object);

            var result = stageSimulation.GetExecutionStatus();

            Assert.AreEqual(false, result);
        }
예제 #4
0
        public void MustNotifyUITrueBecauseCanContinueIsFalse()
        {
            var variables = new List <Variable>
            {
                new Variable {
                    ActualValue = 20, InitialValue = 0, Name = "T"
                },
                new Variable {
                    ActualValue = 0, InitialValue = 50000, Name = "TF"
                },
                new VariableArray {
                    Name = "NS", Variables = new List <Variable> {
                        new Variable {
                            Name = "NS", InitialValue = 0, ActualValue = 0
                        }
                    }
                }
            };

            var simulation = new Mock <ISimulation>();

            simulation.Setup(x => x.GetDiagrams()).Returns(new List <Diagram>());
            simulation.Setup(x => x.GetVariables()).Returns(variables);

            var stageSimulation = new StageSimulation(simulation.Object);

            stageSimulation.StopExecution(true);

            Assert.IsTrue(stageSimulation.MustNotifyUI());
        }
예제 #5
0
 private void Execute(ISimulation simulation)
 {
     try
     {
         //logger.Info("Inicio Ejecutar");
         var simulationStage = new StageSimulation(simulation);
         this.StageSimulationActor.Tell(simulationStage);
         //logger.Info("Fin Ejecutar");
     }
     catch (Exception ex)
     {
         logger.Error(ex.Source + " - " + ex.Message + ": " + ex.StackTrace);
         throw ex;
     }
 }
예제 #6
0
        public void GetVariablesRetrievesAListWithVariableT()
        {
            var simulation = new Mock <ISimulation>();

            simulation.Setup(x => x.GetDiagrams()).Returns(new List <Diagram>());
            simulation.Setup(x => x.GetVariables()).Returns(new List <Variable> {
                new Variable {
                    ActualValue = 0, InitialValue = 0, Name = "T"
                }
            });

            var stageSimulation = new StageSimulation(simulation.Object);

            List <StageVariable> result = stageSimulation.GetVariables();

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("T", result.First().Name);
        }
예제 #7
0
        public void GetMainDiagramOk()
        {
            var variables = new List <Variable>
            {
                new Variable {
                    ActualValue = 0, InitialValue = 0, Name = "T"
                },
                new Variable {
                    ActualValue = 0, InitialValue = 50000, Name = "TF"
                },
                new VariableArray {
                    Name = "NS", Variables = new List <Variable> {
                        new Variable {
                            Name = "NS", InitialValue = 0, ActualValue = 0
                        }
                    }
                }
            };

            var diagrams = new List <Diagram>
            {
                new Diagram {
                    Name = "Principal", Nodes = new ObservableCollection <Node>()
                }
            };

            var simulation = new Mock <ISimulation>();

            simulation.Setup(x => x.GetDiagrams()).Returns(diagrams);
            simulation.Setup(x => x.GetVariables()).Returns(variables);

            var stageSimulation = new StageSimulation(simulation.Object);

            var result = stageSimulation.GetMainDiagram();

            Assert.AreEqual(diagrams.First(), result);
        }