public void TestChangeToProcessing() { CarbonDioxideRemediation co2 = new CarbonDioxideRemediation(); co2.SeedData(); co2.ProcessData(); Assert.Equal(SystemStatus.Processing, co2.Status); }
public void TestChangeToStandby() { CarbonDioxideRemediation co2 = new CarbonDioxideRemediation(); co2.SeedData(); co2.Co2Level = 1; co2.ProcessData(); Assert.Equal(SystemStatus.Standby, co2.Status); }
public void TestStandbyFanOff() { CarbonDioxideRemediation co2 = new CarbonDioxideRemediation(); co2.SeedData(); co2.Co2Level = 1; co2.ProcessData(); Assert.False(co2.FanOn); }
public void TestFanTrouble() { CarbonDioxideRemediation co2 = new CarbonDioxideRemediation(); co2.SeedData(); co2.Status = SystemStatus.Processing; co2.FanOn = false; co2.ProcessData(); Assert.Equal(SystemStatus.Trouble, co2.Status); }
public void TestProcessingTrouble_FanOff() { CarbonDioxideRemediation co2 = new CarbonDioxideRemediation(); co2.SeedData(); co2.Status = SystemStatus.Processing; co2.Bed2Temperature = 230; co2.ProcessData(); Assert.Equal(SystemStatus.Trouble, co2.Status); }
public void TestSimulateProcessing() { CarbonDioxideRemediation co2 = new CarbonDioxideRemediation(); co2.SeedData(); co2.Status = SystemStatus.Processing; co2.FanOn = true; co2.Bed2Temperature = 240; co2.ProcessData(); Assert.Equal(SystemStatus.Processing, co2.Status); }
public void TestProcessingTrouble_HighRegeneratingBedTemp() { CarbonDioxideRemediation co2 = new CarbonDioxideRemediation(); co2.SeedData(); co2.Status = SystemStatus.Processing; co2.FanOn = true; co2.Bed2Temperature = 260; co2.ProcessData(); co2.Status.Should().Be(SystemStatus.Trouble, "bed 2 is regenerating, so it should be hot and bed 1 cold"); }
public void TestProcessingTrouble_LowRegeneratingBedTemp() { CarbonDioxideRemediation co2 = new CarbonDioxideRemediation(); co2.SeedData(); co2.Status = SystemStatus.Processing; co2.FanOn = true; co2.Bed2Temperature = 21; co2.ProcessData(); Assert.Equal(SystemStatus.Trouble, co2.Status); }
public void TestAbsorbingBedChangeToBed2() { CarbonDioxideRemediation co2 = new CarbonDioxideRemediation(); co2.SeedData(); co2.Status = SystemStatus.Processing; co2.FanOn = true; co2.Bed2Temperature = 230; co2.count = 31; co2.ProcessData(); Assert.Equal(BedOptions.Bed2, co2.AbsorbingBed); }
public void TestProcessingTrouble_HighCo2Output() { CarbonDioxideRemediation co2 = new CarbonDioxideRemediation(); co2.SeedData(); co2.Status = SystemStatus.Processing; co2.FanOn = true; co2.Bed2Temperature = 230; co2.Co2OutputLevel = 5; co2.ProcessData(); Assert.Equal(SystemStatus.Trouble, co2.Status); }
/// <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); }