Beispiel #1
0
        public void ReaderCCCL_UpisiUBazu_Jedan_FilePostoji()
        {
            ReaderCCCL _readerCCCL = new ReaderCCCL();
            Logger     l           = new Logger();

            _readerCCCL.DeadbandList.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_CUSTOM, 1), new Podatak(Data.Code.CodeSpisak.CODE_LIMITSET, 2)));
            string expected = "CODE_CUSTOM 1 CODE_LIMITSET 2";
            string actual;
            var    myfile = File.Create(_readerCCCL.File);

            myfile.Close();
            //Act
            _readerCCCL.UpisiUBazu(l);

            //Post act arange
            using (StreamReader sr = new StreamReader(_readerCCCL.File))
            {
                // Read the stream to a string, and write the string to the console.
                actual = sr.ReadLine();
            }

            //Assert
            Assert.AreEqual(expected, actual);

            //Post assert cleanup
            File.Delete(_readerCCCL.File);
        }
Beispiel #2
0
        public void ReaderCCCL_Deadband()
        {
            //Arange

            ReaderCCCL _readerCCCL = new ReaderCCCL();

            File.Delete(_readerCCCL.File);
            Logger l = new Logger();
            List <Tuple <Podatak, Podatak> > buffer = new List <Tuple <Podatak, Podatak> >();
            List <Tuple <Podatak, Podatak> > baza   = new List <Tuple <Podatak, Podatak> >();
            List <Tuple <Podatak, Podatak> > expectedDeadbandList = new List <Tuple <Podatak, Podatak> >();

            baza.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_CUSTOM, 1), new Podatak(Data.Code.CodeSpisak.CODE_LIMITSET, 2)));
            baza.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_CUSTOM, 3), new Podatak(Data.Code.CodeSpisak.CODE_LIMITSET, 4)));
            buffer.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_CUSTOM, 1), new Podatak(Data.Code.CodeSpisak.CODE_LIMITSET, 2)));
            buffer.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_CUSTOM, 3), new Podatak(Data.Code.CodeSpisak.CODE_LIMITSET, 4)));
            buffer.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_CUSTOM, 15), new Podatak(Data.Code.CodeSpisak.CODE_LIMITSET, 22)));
            buffer.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_CUSTOM, 69), new Podatak(Data.Code.CodeSpisak.CODE_LIMITSET, 72)));
            buffer.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_CUSTOM, 15), new Podatak(Data.Code.CodeSpisak.CODE_LIMITSET, 22)));
            buffer.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_CUSTOM, 36), new Podatak(Data.Code.CodeSpisak.CODE_LIMITSET, 49)));
            expectedDeadbandList.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_CUSTOM, 15), new Podatak(Data.Code.CodeSpisak.CODE_LIMITSET, 22)));
            expectedDeadbandList.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_CUSTOM, 69), new Podatak(Data.Code.CodeSpisak.CODE_LIMITSET, 72)));
            expectedDeadbandList.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_CUSTOM, 36), new Podatak(Data.Code.CodeSpisak.CODE_LIMITSET, 49)));
            _readerCCCL.Buffer = baza;
            _readerCCCL.UpisiUBazu(l);
            _readerCCCL.Buffer = buffer;

            //Act
            _readerCCCL.Deadband(l);

            //Assert
            CollectionAssert.AreEqual(expectedDeadbandList, _readerCCCL.DeadbandList);
        }
        public void ReplicatorReceiver_Prosledi()
        {
            //Arange
            ReaderCACD                   rCACD = new ReaderCACD();
            ReaderCCCL                   rCCCL = new ReaderCCCL();
            ReaderCSCM                   rCSCM = new ReaderCSCM();
            ReaderCCCS                   rCCCS = new ReaderCCCS();
            Logger                       l     = new Logger();
            ReplicatorReceiver           _replicatorReceiver   = new ReplicatorReceiver();
            List <CollectionDescription> collectionDescription = new List <CollectionDescription>();

            Podatak[] p        = new Podatak[1];
            int       brojac   = 0;
            Podatak   podatak1 = new Podatak(Code.CodeSpisak.CODE_ANALOG, 1);
            Podatak   podatak2 = new Podatak(Code.CodeSpisak.CODE_DIGITAL, 1);
            Podatak   podatak3 = new Podatak(Code.CodeSpisak.CODE_CUSTOM, 1);
            Podatak   podatak4 = new Podatak(Code.CodeSpisak.CODE_LIMITSET, 1);
            Podatak   podatak5 = new Podatak(Code.CodeSpisak.CODE_SOURCE, 1);
            Podatak   podatak6 = new Podatak(Code.CodeSpisak.CODE_CONSUMER, 1);
            Podatak   podatak7 = new Podatak(Code.CodeSpisak.CODE_SINGLENOE, 1);
            Podatak   podatak8 = new Podatak(Code.CodeSpisak.CODE_MULTIPLENODE, 1);

            HistoricalCollection hc = new HistoricalCollection();

            p[0] = podatak1;
            hc.ReceiverProperty = p;
            collectionDescription.Add(new CollectionDescription(brojac++, DataSet.DataSetSpisak.CACD, hc));
            p[0] = podatak2;
            hc.ReceiverProperty = p;
            collectionDescription.Add(new CollectionDescription(brojac++, DataSet.DataSetSpisak.CACD, hc));
            p[0] = podatak3;
            hc.ReceiverProperty = p;
            collectionDescription.Add(new CollectionDescription(brojac++, DataSet.DataSetSpisak.CCCL, hc));
            p[0] = podatak4;
            hc.ReceiverProperty = p;
            collectionDescription.Add(new CollectionDescription(brojac++, DataSet.DataSetSpisak.CCCL, hc));
            p[0] = podatak5;
            hc.ReceiverProperty = p;
            collectionDescription.Add(new CollectionDescription(brojac++, DataSet.DataSetSpisak.CCCS, hc));
            p[0] = podatak6;
            hc.ReceiverProperty = p;
            collectionDescription.Add(new CollectionDescription(brojac++, DataSet.DataSetSpisak.CCCS, hc));
            p[0] = podatak7;
            hc.ReceiverProperty = p;
            collectionDescription.Add(new CollectionDescription(brojac++, DataSet.DataSetSpisak.CSCM, hc));
            p[0] = podatak8;
            hc.ReceiverProperty = p;
            collectionDescription.Add(new CollectionDescription(brojac++, DataSet.DataSetSpisak.CSCM, hc));
            _replicatorReceiver.Cd = collectionDescription;

            //Act
            _replicatorReceiver.Prosledi(rCACD, rCCCL, rCSCM, rCCCS, l);

            //Assert
            Assert.AreEqual(_replicatorReceiver.Cd[0].Hc.ReceiverProperty[0], rCACD.Buffer[0].Item1);
        }
Beispiel #4
0
        public void ReaderCCCL_UpisiUBazu_Vise_FilePostoji()
        {
            //Arange
            ReaderCCCL _readerCCCL = new ReaderCCCL();
            List <Tuple <Podatak, Podatak> > buffer = new List <Tuple <Podatak, Podatak> >();
            Logger l = new Logger();

            buffer.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_CUSTOM, 1), new Podatak(Data.Code.CodeSpisak.CODE_LIMITSET, 2)));
            buffer.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_CUSTOM, 3), new Podatak(Data.Code.CodeSpisak.CODE_LIMITSET, 4)));
            _readerCCCL.DeadbandList = buffer;
            string expected = "CODE_CUSTOM 1 CODE_LIMITSET 2" + "CODE_CUSTOM 3 CODE_LIMITSET 4";
            string line;
            string actual = "";
            var    myfile = File.Create(_readerCCCL.File);

            myfile.Close();

            //Act
            _readerCCCL.UpisiUBazu(l);

            //Post act arange
            using (StreamReader sr = new StreamReader(_readerCCCL.File))
            {
                // Read the stream to a string, and write the string to the console.
                for (int i = 0; i < 2; i++)
                {
                    line   = sr.ReadLine();
                    actual = actual + line;
                }
            }

            //Assert
            Assert.AreEqual(expected, actual);

            //Post assert cleanup
            File.Delete(_readerCCCL.File);
        }
Beispiel #5
0
        public void ReplicatorReceiver_Prosledi()
        {
            //Arange
            ReaderCACD         rCACD = new ReaderCACD();
            ReaderCCCL         rCCCL = new ReaderCCCL();
            ReaderCSCM         rCSCM = new ReaderCSCM();
            ReaderCCCS         rCCCS = new ReaderCCCS();
            Logger             l     = new Logger();
            ReplicatorReceiver _replicatorReceiver = new ReplicatorReceiver();

            Podatak[]             p        = new Podatak[1];
            Podatak               podatak1 = new Podatak(Code.CodeSpisak.CODE_ANALOG, 1);
            Podatak               podatak2 = new Podatak(Code.CodeSpisak.CODE_DIGITAL, 1);
            Podatak               podatak3 = new Podatak(Code.CodeSpisak.CODE_CUSTOM, 1);
            Podatak               podatak4 = new Podatak(Code.CodeSpisak.CODE_LIMITSET, 1);
            Podatak               podatak5 = new Podatak(Code.CodeSpisak.CODE_SOURCE, 1);
            Podatak               podatak6 = new Podatak(Code.CodeSpisak.CODE_CONSUMER, 1);
            Podatak               podatak7 = new Podatak(Code.CodeSpisak.CODE_SINGLENOE, 1);
            Podatak               podatak8 = new Podatak(Code.CodeSpisak.CODE_MULTIPLENODE, 1);
            CollectionDescription cd1      = new CollectionDescription();
            HistoricalCollection  hc1      = new HistoricalCollection();

            hc1.ReceiverProperty = new Podatak[1] {
                podatak1
            };
            cd1.Dataset = DataSet.DataSetSpisak.CACD;
            cd1.Hc      = hc1;
            cd1.Id      = 0;
            CollectionDescription cd2 = new CollectionDescription();
            HistoricalCollection  hc2 = new HistoricalCollection();

            hc2.ReceiverProperty = new Podatak[1] {
                podatak2
            };
            cd2.Dataset = DataSet.DataSetSpisak.CACD;
            cd2.Hc      = hc2;
            cd2.Id      = 1;
            CollectionDescription cd3 = new CollectionDescription();
            HistoricalCollection  hc3 = new HistoricalCollection();

            hc3.ReceiverProperty = new Podatak[1] {
                podatak3
            };
            cd3.Dataset = DataSet.DataSetSpisak.CCCL;
            cd3.Hc      = hc3;
            cd3.Id      = 2;
            CollectionDescription cd4 = new CollectionDescription();
            HistoricalCollection  hc4 = new HistoricalCollection();

            hc4.ReceiverProperty = new Podatak[1] {
                podatak4
            };
            cd4.Dataset = DataSet.DataSetSpisak.CCCL;
            cd4.Hc      = hc4;
            cd4.Id      = 3;
            CollectionDescription cd5 = new CollectionDescription();
            HistoricalCollection  hc5 = new HistoricalCollection();

            hc5.ReceiverProperty = new Podatak[1] {
                podatak5
            };
            cd5.Dataset = DataSet.DataSetSpisak.CCCS;
            cd5.Hc      = hc5;
            cd5.Id      = 4;
            CollectionDescription cd6 = new CollectionDescription();
            HistoricalCollection  hc6 = new HistoricalCollection();

            hc6.ReceiverProperty = new Podatak[1] {
                podatak6
            };
            cd6.Dataset = DataSet.DataSetSpisak.CCCS;
            cd6.Hc      = hc6;
            cd6.Id      = 5;
            CollectionDescription cd7 = new CollectionDescription();
            HistoricalCollection  hc7 = new HistoricalCollection();

            hc7.ReceiverProperty = new Podatak[1] {
                podatak7
            };
            cd7.Dataset = DataSet.DataSetSpisak.CSCM;
            cd7.Hc      = hc7;
            cd7.Id      = 6;
            CollectionDescription cd8 = new CollectionDescription();
            HistoricalCollection  hc8 = new HistoricalCollection();

            hc8.ReceiverProperty = new Podatak[1] {
                podatak8
            };
            cd8.Dataset = DataSet.DataSetSpisak.CSCM;
            cd8.Hc      = hc8;
            cd8.Id      = 7;
            List <CollectionDescription> collectionDescription = new List <CollectionDescription>()
            {
                cd1, cd2, cd3, cd4, cd5, cd6, cd7, cd8
            };
            List <CollectionDescription> expectedCd = new List <CollectionDescription>()
            {
                cd1, cd2, cd3, cd4, cd5, cd6, cd7, cd8
            };

            _replicatorReceiver.Cd = collectionDescription;

            //Act
            _replicatorReceiver.Prosledi(rCACD, rCCCL, rCSCM, rCCCS, l);

            //Assert
            Assert.AreEqual(expectedCd[0].Hc.ReceiverProperty[0], rCACD.Buffer[0].Item1);
            Assert.AreEqual(expectedCd[1].Hc.ReceiverProperty[0], rCACD.Buffer[0].Item2);
            Assert.AreEqual(expectedCd[2].Hc.ReceiverProperty[0], rCCCL.Buffer[0].Item1);
            Assert.AreEqual(expectedCd[3].Hc.ReceiverProperty[0], rCCCL.Buffer[0].Item2);
            Assert.AreEqual(expectedCd[4].Hc.ReceiverProperty[0], rCCCS.Buffer[0].Item1);
            Assert.AreEqual(expectedCd[5].Hc.ReceiverProperty[0], rCCCS.Buffer[0].Item2);
            Assert.AreEqual(expectedCd[6].Hc.ReceiverProperty[0], rCSCM.Buffer[0].Item1);
            Assert.AreEqual(expectedCd[7].Hc.ReceiverProperty[0], rCSCM.Buffer[0].Item2);
        }