コード例 #1
0
        public void RukovanjeKapacitetom2(ShesMetode shes)
        {
            if (shes == null)
            {
                throw new ArgumentNullException("Parametri ne mogu da budu NULL!");
            }
            int             a        = this.Rezim;
            Shes            sss      = Shes.Instance();
            List <Baterija> baterije = shes.PreuzmiBaterijeIzBaze();
            double          kapMin   = 0;

            lock (baterijaLock)
            {
                for (int i = 0; i < baterije.Count; i++)
                {
                    kapMin = baterije[i].Kapacitet * 60;
                    if (a == 1)
                    {
                        kapMin++;
                    }
                    else if (a == 2)
                    {
                        kapMin--;
                    }
                    kapMin = kapMin / 60;
                    baterije[i].Kapacitet = kapMin;

                    shes.AzurirajBateriju(baterije[i]);
                    shes.PreuzmiPodatkeOdBaterije(baterije[i].Kapacitet, a, baterije[i].Ime, sss.Vreme);
                }
            }
            Thread.Sleep(1000);
        }
        public void DodajPotrosacPrekoKonzole()
        {
            IShes      ishes      = new ShesRepozitorijum();
            ShesMetode shesMetode = new ShesMetode(ishes);

            Console.WriteLine("Unesite naziv novog potrosaca\n");
            string naziv = Console.ReadLine();

            Console.WriteLine("Unesite potrosnju potrosaca\n");
            string potrosnjaString = Console.ReadLine();


            List <Potrosac> lista      = shesMetode.VratiListuPotrosaca();
            bool            validacija = ValidacijaDodatogPotrosaca(lista, naziv, potrosnjaString);

            if (validacija)
            {
                double potrosnja = Double.Parse(potrosnjaString);
                shesMetode.DodajPotrosac(naziv, potrosnja);
                Console.WriteLine("Uspesno ste dodali potrosac.");
            }
            else
            {
                return;
            }
        }
コード例 #3
0
        public void SacuvajIzmereneVrednostiPanelaUBazu()
        {
            IShes      shesRepo   = new FakeShesRepozitorijum();
            ShesMetode shesMetode = new ShesMetode(shesRepo);

            shesMetode.IzmereneSnagePanelaDodaj(s1.Ime, s.Vreme, 200);
            Assert.AreEqual(_BROJ_IZMERENIH_VREDNOSTI_PANELA, shesMetode.BrojIzmerenihSnagaSPanela());
        }
コード例 #4
0
        public void PotrosnjaPotrosacaDobriParametri()
        {
            Mock <IShes> shesRepo = new Mock <IShes>();
            ShesMetode   shes     = new ShesMetode(shesRepo.Object);
            double       rezultat = shes.PotrosnjaPotrosaca(potrosaci);

            Assert.IsNotNull(rezultat);
        }
コード例 #5
0
        public void PotrosnjaProizvodnjaBaterijeDobriParametri(double?vreme)
        {
            Mock <IShes> shesRepo = new Mock <IShes>();
            ShesMetode   shes     = new ShesMetode(shesRepo.Object);
            double       rezultat = shes.PotrosnjaProizvodnjaBaterije(baterije, vreme);

            Assert.IsNotNull(rezultat);
        }
コード例 #6
0
        public void ValidacijaDatumaTrue(string datum)
        {
            Mock <IShes> shesRepo = new Mock <IShes>();
            ShesMetode   shes     = new ShesMetode(shesRepo.Object);
            bool         rezultat = shes.ValidacijaDatuma(datum, prviDatum, poslednjiDatum);

            Assert.IsTrue(rezultat);
        }
コード例 #7
0
        public void GrafikEnergijaBaterije()
        {
            Mock <IShes> shesRepo = new Mock <IShes>();
            ShesMetode   shes     = new ShesMetode(shesRepo.Object);
            double       rez      = shes.GrafikEnergijaBaterija(DateTime.Now, listaE1, listaE2, listaE3);

            Assert.IsNotNull(rez);
        }
コード例 #8
0
        public void ValidacijaVremenaZaRezimBaterije()
        {
            IShes      rep   = new FakeShesRepozitorijum();
            ShesMetode s     = new ShesMetode(rep);
            int        rezim = s.ValidacijaVremenaZaRezim();

            Assert.IsNotNull(rezim);
        }
コード例 #9
0
        public void PreuzimanjePodatakaOdBaterije()
        {
            IShes      rep    = new FakeShesRepozitorijum();
            ShesMetode metode = new ShesMetode(rep);

            metode.PreuzmiPodatkeOdBaterije(15.00, 1, "baterija1", DateTime.Now);
            Assert.AreEqual(vrednost, metode.BrojIzmerenihKapacitetaBaterija());
        }
コード例 #10
0
        public void GrafikPotrosnja()
        {
            Mock <IShes> shesRepo = new Mock <IShes>();
            ShesMetode   shes     = new ShesMetode(shesRepo.Object);
            double       rez      = shes.GrafikPotrosnja(DateTime.Now, listaGrafDouble);

            Assert.IsNotNull(rez);
        }
コード例 #11
0
        public void StanjePotrosacaTest()
        {
            IShes      shesRepo   = new FakeShesRepozitorijum();
            ShesMetode shesMetode = new ShesMetode(shesRepo);

            shesMetode.StanjePotrosacaa(listaPotrosaca);
            Assert.AreEqual(1, shesMetode.BrojStanjaPotrosacaIzBaza());
        }
コード例 #12
0
        public void SacuvajVrednostiZaElektrodistribucijuUBazu()
        {
            IShes      shesRepo   = new FakeShesRepozitorijum();
            ShesMetode shesMetode = new ShesMetode(shesRepo);

            shesMetode.SacuvajElektroDistribucijaPodatke(DateTime.Now, -1, 5.2);
            Assert.AreEqual(_BROJ_IZMERENIH_VREDNOSTI_PANELA, shesMetode.BrojElektrodistribucijaPodatakaBaza());
        }
コード例 #13
0
        public void ProizvodnjaSolarnihPanelaDobriParametri(double?vreme)
        {
            Mock <ISolarniPanel> panel    = new Mock <ISolarniPanel>();
            Mock <IShes>         shesRepo = new Mock <IShes>();
            ShesMetode           shes     = new ShesMetode(shesRepo.Object);
            double rezultat = shes.ProizvodnjaSolarnihPanela(panel.Object, solarniPaneli, vreme);

            Assert.IsNotNull(rezultat);
        }
        public void RukovanjeKapacitetom2Test(ShesMetode shess)
        {
            IBaterija bat = new BaterijaMetode();

            Assert.Throws <ArgumentNullException>(() =>
            {
                bat.RukovanjeKapacitetom2(shess);
            });
        }
コード例 #15
0
        public void ObrisiPotrosacTest(string naziv)
        {
            Mock <IShes> shesRepo = new Mock <IShes>();
            ShesMetode   shes     = new ShesMetode(shesRepo.Object);

            Assert.Throws <ArgumentNullException>(() =>
            {
                shes.ObrisiPotrosac(naziv);
            });
        }
コード例 #16
0
        public void BrojIzmerenihKapacitetaBaterije()
        {
            Mock <IShes> shesRepo = new Mock <IShes>();

            shesRepo.Setup(x => x.BrojIzmerenihKapaciteta()).Returns(1);
            ShesMetode shesMetode = new ShesMetode(shesRepo.Object);
            int        result     = shesMetode.BrojIzmerenihKapacitetaBaterija();

            Assert.AreEqual(1, result);
        }
コード例 #17
0
        public void BrojPodatakaElektrodistribucija()
        {
            Mock <IShes> shesRepository = new Mock <IShes>();

            shesRepository.Setup(x => x.BrojPodatakaElektrodistribucija()).Returns(3);
            ShesMetode shesMetode = new ShesMetode(shesRepository.Object);
            int        result     = shesMetode.BrojElektrodistribucijaPodatakaBaza();

            Assert.AreEqual(3, result);
        }
コード例 #18
0
        public void RukovanjeKapacitetom()
        {
            IShes      IShess = new ShesRepozitorijum();
            ShesMetode shes   = new ShesMetode(IShess);

            while (true)
            {
                RukovanjeKapacitetom2(shes);
            }
        }
コード例 #19
0
        public void BrojStanjaPotrosaca()
        {
            Mock <IShes> shesRepository = new Mock <IShes>();

            shesRepository.Setup(x => x.VratiBrojStanjaPotrosaca()).Returns(3);
            ShesMetode shesMetode = new ShesMetode(shesRepository.Object);
            int        result     = shesMetode.BrojStanjaPotrosacaIzBaza();

            Assert.AreEqual(3, result);
        }
コード例 #20
0
        public void ProizvodnjaSolarnihPanelaLosiParametri3(ISolarniPanel p, List <SolarniPanel> solarniPaneli, double?vreme)
        {
            Mock <IShes> shesRepo = new Mock <IShes>();
            ShesMetode   shes     = new ShesMetode(shesRepo.Object);

            Assert.Throws <ArgumentNullException>(() =>
            {
                shes.ProizvodnjaSolarnihPanela(p, solarniPaneli, vreme);
            });
        }
コード例 #21
0
        public void BrojPanela()
        {
            Mock <IShes> shesRepository = new Mock <IShes>();

            shesRepository.Setup(x => x.VratiBrojIzmerenihSnagaPanela()).Returns(3);
            ShesMetode shesMetode = new ShesMetode(shesRepository.Object);
            int        result     = shesMetode.BrojIzmerenihSnagaSPanela();

            Assert.AreEqual(3, result);
        }
コード例 #22
0
        public void ValidacijaDatumaLosiParametri3(string datum)
        {
            Mock <IShes> shesRepo = new Mock <IShes>();
            ShesMetode   shes     = new ShesMetode(shesRepo.Object);

            Assert.Throws <ArgumentNullException>(() =>
            {
                shes.ValidacijaDatuma(datum, prviDatum, poslednjiDatum);
            });
        }
コード例 #23
0
        public void PotrosnjaProizvodnjaBaterijeLosiParametri2(double?vreme)
        {
            Mock <IShes> shesRepo = new Mock <IShes>();
            ShesMetode   shes     = new ShesMetode(shesRepo.Object);

            Assert.Throws <ArgumentNullException>(() =>
            {
                shes.PotrosnjaProizvodnjaBaterije(baterije, vreme);
            });
        }
コード例 #24
0
        public void PosaljiKomanduLosiParametri1(IBaterija ibaterija)
        {
            Mock <IShes> shesRepo = new Mock <IShes>();
            ShesMetode   shes     = new ShesMetode(shesRepo.Object);

            Assert.Throws <ArgumentNullException>(() =>
            {
                shes.PosaljiKomanduNaBateriju(ibaterija);
            });
        }
コード例 #25
0
        public void PotrosnjaPotrosacaLosiParametri(List <Potrosac> potrosaci)
        {
            Mock <IShes> shesRepo = new Mock <IShes>();
            ShesMetode   shes     = new ShesMetode(shesRepo.Object);

            Assert.Throws <ArgumentNullException>(() =>
            {
                shes.PotrosnjaPotrosaca(potrosaci);
            });
        }
コード例 #26
0
        public void PreuzimanjeBaterijeIzBaze()
        {
            Mock <IShes> shesRepo = new Mock <IShes>();

            shesRepo.Setup(x => x.PreuzmiBaterije()).Returns(baterije);
            ShesMetode      shesMetode = new ShesMetode(shesRepo.Object);
            List <Baterija> lista      = shesMetode.PreuzmiBaterijeIzBaze();

            Assert.IsNotNull(lista);
            Assert.AreEqual(baterije.Count, lista.Count);
            Assert.AreEqual(baterije.ElementAt(0), lista.ElementAt(0));
        }
コード例 #27
0
        public void VratiListuPotrosacaTest()
        {
            Mock <IShes> shesRepo = new Mock <IShes>();

            shesRepo.Setup(x => x.VratiListuPotrosacaRepo()).Returns(listaPotrosaca);
            ShesMetode      shesMetode = new ShesMetode(shesRepo.Object);
            List <Potrosac> lista      = shesMetode.VratiListuPotrosaca();

            Assert.IsNotNull(lista);
            Assert.AreEqual(listaPotrosaca.Count, lista.Count);
            Assert.AreEqual(listaPotrosaca.ElementAt(0), lista.ElementAt(0));
        }
コード例 #28
0
        public void PreuzmiPanele()
        {
            Mock <IShes> shesRepository = new Mock <IShes>();

            shesRepository.Setup(x => x.PreuzmiPanele()).Returns(solarniPaneli);
            ShesMetode          shesMetode = new ShesMetode(shesRepository.Object);
            List <SolarniPanel> result     = shesMetode.PreuzmiSolarnePanele();

            Assert.IsNotNull(result);
            Assert.AreEqual(solarniPaneli.Count, result.Count);
            Assert.AreEqual(solarniPaneli.ElementAt(0), result.ElementAt(0));
            Assert.AreEqual(solarniPaneli.ElementAt(1), result.ElementAt(1));
        }
コード例 #29
0
        public void VratiListuStanjaPotrosaca()
        {
            Mock <IShes> shesRepository = new Mock <IShes>();

            shesRepository.Setup(x => x.VratiListuStanjaPotrosaca()).Returns(listaStanja);
            ShesMetode             shesMetode = new ShesMetode(shesRepository.Object);
            List <PotrosaciStanje> result     = shesMetode.VratiStanjaPotrosacaIzBaze();

            Assert.IsNotNull(result);
            Assert.AreEqual(listaStanja.Count, result.Count);
            Assert.AreEqual(listaStanja.ElementAt(0), result.ElementAt(0));
            Assert.AreEqual(listaStanja.ElementAt(1), result.ElementAt(1));
        }
コード例 #30
0
        public void PreuzmiIzmereneVrednostiPanele()
        {
            Mock <IShes> shesRepository = new Mock <IShes>();

            shesRepository.Setup(x => x.VratiIzmereneVrednostiPanela()).Returns(panelIzme);
            ShesMetode shesMetode = new ShesMetode(shesRepository.Object);
            List <PanelIzmereneVrednosti> result = shesMetode.PreuzmiIzmereneVrednostiPanela();

            Assert.IsNotNull(result);
            Assert.AreEqual(panelIzme.Count, result.Count);
            Assert.AreEqual(panelIzme.ElementAt(0), result.ElementAt(0));
            Assert.AreEqual(panelIzme.ElementAt(1), result.ElementAt(1));
        }