Beispiel #1
0
        public void TimeSimulatorStartTest()
        {
            // Arrange
            var timeSimulator = new TimeSimulator();
            int callCount     = 0;

            // Act
            timeSimulator.Start(DateTime.Now, 43200, 1, (DateTime d) =>
            {
                callCount++;
                timeSimulator.IsReportingProgress = false;
            });
            timeSimulator.Wait();

            // Assert
            Assert.IsTrue(callCount > 0 && callCount < 4, "There should be between 1 and 3 calls");
        }
Beispiel #2
0
        internal static void Start()
        {
            var name          = Args.Value(Constants.Name);
            var nsEndpoint    = Args.Value(Constants.NameServerEndpoint);
            var timeSimulator = new TimeSimulator();

            int year           = Args.Value(Constants.Year).To <int>();
            int month          = Args.Value(Constants.Month).To <int>();
            int day            = Args.Value(Constants.Day).To <int>();
            int timeMultiplier = Args.Value(Constants.TimeMultiplier).To <int>();
            int duration       = Args.Value(Constants.Duration).To <int>();

            Logger = new LoggerClient(Args.Value(Constants.LoggerServerName), name, nsEndpoint);
            var client = new DiseaseSimulatorClient(name, nsEndpoint, Logger)
            {
                Client = new RequestClient(true, false)
            };

            Logger?.WriteLine($"{Constants.Year}: {year}", client.SystemRegistration.Id);
            Logger?.WriteLine($"{Constants.Month}: {month}", client.SystemRegistration.Id);
            Logger?.WriteLine($"{Constants.Day}: {day}", client.SystemRegistration.Id);
            Logger?.WriteLine($"{Constants.TimeMultiplier}: {timeMultiplier}", client.SystemRegistration.Id);
            Logger?.WriteLine($"{Constants.Duration}: {duration}", client.SystemRegistration.Id);

            Logger?.WriteLine($"{name} has started.");
            Console.WriteLine("Simulator: " + name);


            string endpoint = Args.Value(Constants.Endpoint);

            Logger?.WriteLine($"{Constants.Endpoint}: {endpoint}");

            var startDate = new DateTime(year, month, day);

            Logger?.WriteLine($"{Constants.StartDate}: {startDate.ToLongDateString()}");

            var reportAction = new ReportAction(client.SystemRegistration, timeSimulator, new Random(), new DiseaseRecordGenerator(), client, endpoint);

            timeSimulator.Start(startDate, timeMultiplier, duration, reportAction.Action);
            timeSimulator.Wait();
        }