예제 #1
0
        public bool Deadband(CollectionDescription collection)
        {
            List <CollectionDescription> dataFromBase = new List <CollectionDescription>();

            if (collection == null)
            {
                throw new ArgumentNullException("Empty collection sent to chech deadband");
            }
            if (collection.m_HistoricalCollection.m_WorkerProperty[0].Code.Equals(Code.CODE_DIGITAL))
            {
                return(true);
            }
            //uzmi podatke iz baza
            //dataFromBase = Deserialization(collection.Dataset); proxy
            dataFromBase = proxy.Deserialization(collection.Dataset);

            if (dataFromBase.Count == 0)
            {
                return(true);
            }

            bool secoundExist = true;
            bool answer       = false;

            foreach (CollectionDescription item in dataFromBase)
            {
                if (item.m_HistoricalCollection.m_WorkerProperty[0].Code == collection.m_HistoricalCollection.m_WorkerProperty[0].Code)
                {
                    if (collection.m_HistoricalCollection.m_WorkerProperty[0].WorkerValue <= (item.m_HistoricalCollection.m_WorkerProperty[0].WorkerValue * 1.02) &&
                        collection.m_HistoricalCollection.m_WorkerProperty[0].WorkerValue >= item.m_HistoricalCollection.m_WorkerProperty[0].WorkerValue * 0.98)
                    {
                        //return false;
                        secoundExist = false;
                        continue;
                    }
                    else
                    {
                        answer       = true;
                        secoundExist = false;
                        break;
                    }
                }
            }
            if (secoundExist)
            {
                answer = true;
            }

            return(answer);
        }
예제 #2
0
        public void ReceiveFromLoadBalancerTest()
        {
            //Laziranje podataka koriscenjem NSubstitute biblioteke
            proxyMock.Deserialization(100).ReturnsForAnyArgs(new List <CollectionDescription>());
            Worker.Worker.proxy = proxyMock;
            bool resultAnalog    = worker.ReceiveFromLoadBalancer(Code.CODE_ANALOG, 100);
            bool resultDigital   = worker.ReceiveFromLoadBalancer(Code.CODE_DIGITAL, 100);
            bool resultCustom    = worker.ReceiveFromLoadBalancer(Code.CODE_CUSTOM, 100);
            bool resultConsumer  = worker.ReceiveFromLoadBalancer(Code.CODE_CONSUMER, 100);
            bool resultLimiset   = worker.ReceiveFromLoadBalancer(Code.CODE_LIMITSET, 100);
            bool resultSingleNoe = worker.ReceiveFromLoadBalancer(Code.CODE_SINGLENOE, 100);
            bool resultSource    = worker.ReceiveFromLoadBalancer(Code.CODE_SOURCE, 100);
            bool resultMulty     = worker.ReceiveFromLoadBalancer(Code.CODE_MULTIPLENODE, 100);

            Assert.IsTrue(resultAnalog);
            Assert.IsTrue(resultDigital);
            Assert.IsTrue(resultCustom);
            Assert.IsTrue(resultConsumer);
            Assert.IsTrue(resultLimiset);
            Assert.IsTrue(resultSingleNoe);
            Assert.IsTrue(resultSource);
            Assert.IsTrue(resultMulty);
        }