public void Test_Increase_Radiator_Rotation()
        {
            ExternalCoolantLoopData ec = new ExternalCoolantLoopData();

            ec.SeedData();
            ec.ProcessData();
            Assert.Equal(1, ec.RadiatorRotation);
        }
        public void Test_Nominal_Operation()
        {
            ExternalCoolantLoopData ec = new ExternalCoolantLoopData();

            ec.SeedData();
            ec.ProcessData();
            Assert.Equal(SystemStatus.On, ec.Status);
        }
        public void Test_LineAPressure_High()
        {
            ExternalCoolantLoopData ec = new ExternalCoolantLoopData();

            ec.SeedData();
            ec.LineAPressure = 2861;
            ec.ProcessData();
            Assert.Equal(SystemStatus.Trouble, ec.Status);
        }
        public void Test_LineBPressure_Over_Max()
        {
            ExternalCoolantLoopData ec = new ExternalCoolantLoopData();

            ec.SeedData();
            ec.LineBPressure = 3311;
            ec.ProcessData();
            Assert.False(ec.PumpBOn);
        }
        public void Test_OutflowTemp_High()
        {
            ExternalCoolantLoopData ec = new ExternalCoolantLoopData();

            ec.SeedData();
            ec.OutputFluidTemperature = 5;
            ec.ProcessData();
            Assert.Equal(26, ec.MixValvePosition);
        }
        public void Test_Radiator_Not_Deployed()
        {
            ExternalCoolantLoopData ec = new ExternalCoolantLoopData();

            ec.SeedData();
            ec.RadiatorDeployed = false;
            ec.ProcessData();
            Assert.Equal(SystemStatus.Trouble, ec.Status);
        }
        public void Test_PumpB_Failure()
        {
            ExternalCoolantLoopData ecl = new ExternalCoolantLoopData();

            ecl.SeedData();
            ecl.PumpBOn = false;
            ecl.ProcessData();
            Assert.Equal(SystemStatus.Trouble, ecl.Status);
        }
        public void Test_Change_Status_From_Trouble_To_On()
        {
            ExternalCoolantLoopData ec = new ExternalCoolantLoopData();

            ec.SeedData();
            ec.Status = SystemStatus.Trouble;
            ec.ProcessData();
            Assert.Equal(SystemStatus.On, ec.Status);
        }
        public void Test_Change_Radiator_Rotation_Direction()
        {
            ExternalCoolantLoopData ec = new ExternalCoolantLoopData();

            ec.SeedData();
            ec.RadiatorRotation = 205;
            ec.ProcessData();
            Assert.False(ec.radiatorRotationIncreasing);
        }
        public void Test_Radiator_Rotation_Not_Deployed()
        {
            ExternalCoolantLoopData ec = new ExternalCoolantLoopData();

            ec.SeedData();
            ec.RadiatorDeployed = false;
            ec.RadiatorRotation = 11;
            ec.ProcessData();
            Assert.Equal(0, ec.RadiatorRotation);
        }
        public void Should_be_able_to_get_current_value_via_creator_extension(int value)
        {
            var data = new ExternalCoolantLoopData {
                LineAPressure = value
            };
            var alert = data.CreateAlert(a => a.LineAPressure);

            alert.IsSafe.Should().BeTrue();

            alert.CurrentValue.Should().Be(value);
        }
        public void Should_be_able_to_infer_metadata_attributes_using_extension_method()
        {
            var data  = new ExternalCoolantLoopData();
            var alert = data.CreateAlert(a => a.LineAPressure);

            alert.AlertLevel.Should().Be(AlertLevel.Safe, because: "invoking CreateAlert with no parameters should create a 'Safe' alert");

            alert.Metadata.Should().NotBeNull();

            alert.Metadata.IdealRange.Should().NotBeNull(because: "this property has an {0} applied", nameof(IdealRangeAttribute));
            alert.Metadata.TotalRange.Should().NotBeNull(because: "this property has a {0} applied", nameof(RangeAttribute));
            alert.Metadata.IdealValue.Should().NotBeNull(because: "this property has an {0} applied", nameof(IdealValueAttribute));
            alert.Metadata.UnitType.Should().NotBeNullOrEmpty(because: "this property has a {0} applied", nameof(UnitTypeAttribute));
        }
Exemplo n.º 13
0
        /// <summary>
        /// This method simulates generating real-world data and inserting it into the database.
        /// </summary>
        /// <returns> </returns>
        private void SimulateDataGeneration()
        {
            CancellationToken token = _cancellationTokenSource.Token;

            this.Started?.Invoke(this, EventArgs.Empty);
            bool isFirst = true;

            while (!token.IsCancellationRequested)
            {
                Thread.Sleep(TimeSpan.FromSeconds(3));

                if (token.IsCancellationRequested)
                {
                    break;
                }

                using var scope = ServiceProvider.CreateScope();
                using var db    = scope.ServiceProvider.GetRequiredService <OrbitDbContext>();

                if (isFirst)
                {
                    db.InsertSeedData();
                    isFirst = false;
                    db.SaveChanges();
                    continue;
                }

                #region Get data from context

                WasteWaterStorageTankData wasteTank      = db.WasteWaterStorageTankData.Last();
                UrineSystemData           urineSystem    = db.UrineProcessorData.Last();
                WaterProcessorData        waterProcessor = db.WaterProcessorData.Last();
                PowerSystemData           power          = db.PowerSystemData.Last();
                AtmosphereData            atmo           = db.AtmosphereData.Last();
                CarbonDioxideRemediation  co2            = db.CarbonDioxideRemoverData.Last();
                ExternalCoolantLoopData   eloop          = db.ExternalCoolantLoopData.Last();
                InternalCoolantLoopData   iloop          = db.InternalCoolantLoopData.Last();
                OxygenGenerator           o2             = db.OxygenGeneratorData.Last();
                WaterGeneratorData        h20            = db.WaterGeneratorData.Last();

                #endregion Get data from context


                #region Process the data

                urineSystem.ProcessData(wasteTank.Level);
                wasteTank.ProcessData(urineSystem.Status, waterProcessor.SystemStatus);
                waterProcessor.ProcessData(wasteTank.Level);
                power.ProcessData();
                atmo.ProcessData();
                co2.ProcessData();
                eloop.ProcessData();
                iloop.ProcessData();
                o2.ProcessData();
                h20.ProcessData();

                #endregion Process the data


                #region Generate new data sets

                var nextUrineSystem = new UrineSystemData(urineSystem);
                var nextWasteTank   = new WasteWaterStorageTankData {
                    Level = wasteTank.Level
                };
                var nextWaterProcessor = new WaterProcessorData(waterProcessor);
                var nextPower          = new PowerSystemData(power);
                var nextAtmo           = new AtmosphereData(atmo);
                var nextCo2            = new CarbonDioxideRemediation(co2);
                var nextEloop          = new ExternalCoolantLoopData(eloop);
                var nextIloop          = new InternalCoolantLoopData(iloop);
                var nextO2             = new OxygenGenerator(o2);
                var nextH20            = new WaterGeneratorData(h20);

                #endregion Generate new data sets


                #region Save new data sets to context

                db.UrineProcessorData.Add(nextUrineSystem);
                db.WasteWaterStorageTankData.Add(nextWasteTank);
                db.WaterProcessorData.Add(nextWaterProcessor);
                db.PowerSystemData.Add(nextPower);
                db.AtmosphereData.Add(nextAtmo);
                db.CarbonDioxideRemoverData.Add(nextCo2);
                db.ExternalCoolantLoopData.Add(nextEloop);
                db.InternalCoolantLoopData.Add(nextIloop);
                db.OxygenGeneratorData.Add(nextO2);
                db.WaterGeneratorData.Add(nextH20);

                db.SaveChanges();

                #endregion Save new data sets to context
            }

            this.Stopped?.Invoke(this, EventArgs.Empty);
        }