public void DobriParametri(int id1, int id2, Enums.ConsumerRezim rezim1, Enums.ConsumerRezim rezim2) { cg.ChangeConsumerState(id1, rezim1); cg.ChangeConsumerState(id2, rezim2); Assert.AreEqual(num, ConsumerGUI.rezimBuffer.Count()); Assert.AreEqual(rezim1, ConsumerGUI.rezimBuffer[id1]); Assert.AreEqual(rezim2, ConsumerGUI.rezimBuffer[id2]); Assert.AreEqual(cg.ReturnTotal(), mockConsumer1.Object.EnergyConsumption); cg.ChangeConsumerState(id2, rezim1); Assert.AreEqual(rezim1, ConsumerGUI.rezimBuffer[id1]); Assert.AreEqual(rezim1, ConsumerGUI.rezimBuffer[id2]); Assert.AreEqual(cg.ReturnTotal(), mockConsumer1.Object.EnergyConsumption + mockConsumer2.Object.EnergyConsumption); }
private void BtnChange_Click(object sender, RoutedEventArgs e) { //parsirati unos svaki ChannelFactory <ISolarPanelGUI> SolarPanelChannel = new ChannelFactory <ISolarPanelGUI>("ISolarPanelGUI"); ISolarPanelGUI proxySP = SolarPanelChannel.CreateChannel(); ChannelFactory <IEVChargerGUI> EVChargerChannel = new ChannelFactory <IEVChargerGUI>("IEVChargerGUI"); IEVChargerGUI proxyEV = EVChargerChannel.CreateChannel(); ChannelFactory <IConsumerGUI> ConsumerChannel = new ChannelFactory <IConsumerGUI>("IConsumerGUI"); IConsumerGUI proxyConsumer = ConsumerChannel.CreateChannel(); ChannelFactory <IUtilityGUI> UtilityChannel = new ChannelFactory <IUtilityGUI>("IUtilityGUI"); IUtilityGUI proxyUtility = UtilityChannel.CreateChannel(); double sunIntensity = 0; var consumerRezim = Common.Enums.ConsumerRezim.OFF; int consumerID = 0; var ev = Common.Enums.BatteryRezim.PRAZNJENJE; double util = 0; if (txtSun.Text != null && txtSun.Text != "") { if (double.TryParse(txtSun.Text, out sunIntensity) && sunIntensity >= 0 && sunIntensity <= 1) { proxySP.ChangeSunIntensity(sunIntensity); txtSun.Text = ""; } else { throw new ArgumentOutOfRangeException("Intenzitet Sunca mora biti broj u intervalu 0-1!"); } } if (txtConsumerId.Text != null && txtConsumerId.Text != "") { if (Int32.TryParse(txtConsumerId.Text, out consumerID)) { if (cmbBoxConsumer.Text != null && cmbBoxConsumer.Text != "") { switch (cmbBoxConsumer.Text) { case "ON": consumerRezim = Enums.ConsumerRezim.ON; break; default: consumerRezim = Enums.ConsumerRezim.OFF; break; } Trace.TraceInformation("GUI sending: Consumer id-" + consumerID + ", state-" + consumerRezim.ToString()); proxyConsumer.ChangeConsumerState(consumerID, consumerRezim); txtConsumerId.Text = ""; } } else { throw new ArgumentOutOfRangeException("Id potrosaca mora biti nenegativan broj!"); } } if (cmbBoxBatteryRegime.Text != null && cmbBoxBatteryRegime.Text != "") { switch (cmbBoxBatteryRegime.Text) { case "PUNJENJE": ev = Enums.BatteryRezim.PUNJENJE; break; default: ev = Enums.BatteryRezim.PRAZNJENJE; break; } Trace.TraceInformation("GUI to EV: " + Convert.ToBoolean(cmbBoxBatteryOnPlug.Text) + " " + ev.ToString()); proxyEV.SendRegime(Convert.ToBoolean(cmbBoxBatteryOnPlug.Text), ev); } if (txtUtilityPrice.Text != null && txtUtilityPrice.Text != "") { if (double.TryParse(txtUtilityPrice.Text, out util) && util >= 0) { util = double.Parse(txtUtilityPrice.Text); proxyUtility.SendPrice(util); txtUtilityPrice.Text = ""; } else { throw new ArgumentOutOfRangeException("Cena elektrodistribucije mora biti pozitivan broj!"); } } }