Beispiel #1
0
        public void ReaderCACD_UpisiUBazu_Jedan()
        {
            //Arange
            ReaderCACD _readerCACD = new ReaderCACD();
            Logger     l           = new Logger();

            _readerCACD.Buffer.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_ANALOG, 1), new Podatak(Data.Code.CodeSpisak.CODE_DIGITAL, 2)));
            string expected = "CODE_ANALOG 1 CODE_DIGITAL 2";
            string actual;

            File.Delete(_readerCACD.File);

            //Act
            _readerCACD.UpisiUBazu(l);

            //Post act arange
            using (StreamReader sr = new StreamReader(_readerCACD.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(_readerCACD.File);
        }
        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 #3
0
        public void ReaderCACD_UpisiUBazu_Vise()
        {
            //Arange
            ReaderCACD _readerCACD = new ReaderCACD();
            List <Tuple <Podatak, Podatak> > buffer = new List <Tuple <Podatak, Podatak> >();
            Logger l = new Logger();

            buffer.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_ANALOG, 1), new Podatak(Data.Code.CodeSpisak.CODE_DIGITAL, 2)));
            buffer.Add(Tuple.Create(new Podatak(Data.Code.CodeSpisak.CODE_ANALOG, 3), new Podatak(Data.Code.CodeSpisak.CODE_DIGITAL, 4)));
            _readerCACD.Buffer = buffer;
            string expected = "CODE_ANALOG 1 CODE_DIGITAL 2" + "CODE_ANALOG 3 CODE_DIGITAL 4";
            string line;
            string actual = "";

            File.Delete(_readerCACD.File);

            //Act
            _readerCACD.UpisiUBazu(l);

            //Post act arange
            using (StreamReader sr = new StreamReader(_readerCACD.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(_readerCACD.File);
        }
Beispiel #4
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);
        }