예제 #1
0
        public void AfterProcessing_ExtremumObjectHasProperlyAssignedLaterChange10()
        {
            //Arrange
            Mock <IProcessManager>    mockedManager   = new Mock <IProcessManager>();
            Mock <IExtremumProcessor> mockedProcessor = new Mock <IExtremumProcessor>();
            DataSet dataSet4 = utf.getDataSetWithQuotation(4, 1.0915, 1.0916, 1.09111, 1.09112, 1392);

            mockedManager.Setup(m => m.GetDataSet(4)).Returns(dataSet4);
            mockedProcessor.Setup(p => p.IsExtremum(dataSet4, ExtremumType.TroughByLow)).Returns(true);
            mockedProcessor.Setup(p => p.CalculateLaterChange(It.IsAny <Extremum>(), 10)).Returns(1.23);

            //Act
            PriceProcessor processor = new PriceProcessor(mockedManager.Object);

            processor.InjectExtremumProcessor(mockedProcessor.Object);
            processor.Process(dataSet4);

            //Assert
            double   expectedValue = 1.23;
            Price    price         = dataSet4.GetPrice();
            Extremum extremum      = price.GetExtremum(ExtremumType.TroughByLow);
            var      difference    = (extremum.LaterChange10 - expectedValue);

            Assert.IsTrue(Math.Abs(difference) < MAX_DOUBLE_COMPARISON_DIFFERENCE);
        }
예제 #2
0
        public void AfterProcessing_PriceHasTroughByLow_IfExtremaProcessorReturnsTrueForIsExtrema()
        {
            //Arrange
            Mock <IProcessManager>    mockedManager   = new Mock <IProcessManager>();
            Mock <IExtremumProcessor> mockedProcessor = new Mock <IExtremumProcessor>();
            DataSet dataSet4 = utf.getDataSetWithQuotation(4, 1.0915, 1.0916, 1.09111, 1.09112, 1392);

            mockedManager.Setup(m => m.GetDataSet(4)).Returns(dataSet4);
            mockedProcessor.Setup(p => p.IsExtremum(dataSet4, ExtremumType.TroughByLow)).Returns(true);

            //Act
            PriceProcessor processor = new PriceProcessor(mockedManager.Object);

            processor.InjectExtremumProcessor(mockedProcessor.Object);
            processor.Process(dataSet4);

            //Assert
            Price price = dataSet4.GetPrice();

            Assert.IsNotNull(price.GetExtremum(ExtremumType.TroughByLow));
        }
예제 #3
0
        public void AfterProcessing_IfThereIsNewPeakByCloseExtremum_ItHasIsUpdatedFlagSetToTrue()
        {
            //Arrange
            Mock <IProcessManager>    mockedManager   = new Mock <IProcessManager>();
            Mock <IExtremumProcessor> mockedProcessor = new Mock <IExtremumProcessor>();
            DataSet dataSet4 = utf.getDataSetWithQuotation(4, 1.0915, 1.0916, 1.09111, 1.09112, 1392);

            mockedManager.Setup(m => m.GetDataSet(4)).Returns(dataSet4);
            mockedProcessor.Setup(p => p.IsExtremum(dataSet4, ExtremumType.PeakByClose)).Returns(true);

            //Act
            PriceProcessor processor = new PriceProcessor(mockedManager.Object);

            processor.InjectExtremumProcessor(mockedProcessor.Object);
            processor.Process(dataSet4);

            //Assert
            Price    price    = dataSet4.GetPrice();
            Extremum extremum = price.GetExtremum(ExtremumType.PeakByClose);

            Assert.IsTrue(extremum.Updated);
        }
예제 #4
0
        public void AfterProcessing_ExtremumObjectHasProperlyAssignedLaterCounter()
        {
            //Arrange
            Mock <IProcessManager>    mockedManager   = new Mock <IProcessManager>();
            Mock <IExtremumProcessor> mockedProcessor = new Mock <IExtremumProcessor>();
            DataSet dataSet4 = utf.getDataSetWithQuotation(4, 1.0915, 1.0916, 1.09111, 1.09112, 1392);

            mockedManager.Setup(m => m.GetDataSet(4)).Returns(dataSet4);
            mockedProcessor.Setup(p => p.IsExtremum(dataSet4, ExtremumType.TroughByLow)).Returns(true);
            mockedProcessor.Setup(p => p.CalculateLaterCounter(It.IsAny <Extremum>())).Returns(4);

            //Act
            PriceProcessor processor = new PriceProcessor(mockedManager.Object);

            processor.InjectExtremumProcessor(mockedProcessor.Object);
            processor.Process(dataSet4);

            //Assert
            int      expectedValue = 4;
            Price    price         = dataSet4.GetPrice();
            Extremum extremum      = price.GetExtremum(ExtremumType.TroughByLow);

            Assert.AreEqual(expectedValue, extremum.LaterCounter);
        }