コード例 #1
0
ファイル: TrendHitUnitTests.cs プロジェクト: mielk/shares
        public void ToDto_returnProperDto()
        {
            //Act
            var trendHit = new TrendHit(DEFAULT_TRENDLINE_ID, DEFAULT_INDEX_NUMBER, DEFAULT_EXTREMUM_TYPE)
            {
                Id                = DEFAULT_ID,
                Value             = DEFAULT_VALUE,
                DistanceToLine    = DEFAULT_DISTANCE_TO_LINE,
                PreviousRangeGuid = DEFAULT_PREVIOUS_RANGE_GUID,
                NextRangeGuid     = null
            };
            var guid        = trendHit.Guid;
            var trendHitDto = trendHit.ToDto();

            //Assert.
            Assert.AreEqual(DEFAULT_ID, trendHitDto.Id);
            Assert.AreEqual(guid, trendHitDto.Guid);
            Assert.AreEqual(DEFAULT_TRENDLINE_ID, trendHitDto.TrendlineId);
            Assert.AreEqual(DEFAULT_INDEX_NUMBER, trendHitDto.IndexNumber);
            Assert.AreEqual(DEFAULT_EXTREMUM_TYPE, trendHitDto.ExtremumType);
            Assert.AreEqual(DEFAULT_VALUE, trendHitDto.Value);
            Assert.AreEqual(DEFAULT_DISTANCE_TO_LINE, trendHitDto.DistanceToLine);
            Assert.AreEqual(DEFAULT_PREVIOUS_RANGE_GUID, trendHitDto.PreviousRangeGuid);
            Assert.IsNull(trendHitDto.NextRangeGuid);
        }
コード例 #2
0
        public void UpdateTrendhits_AllItemsPassedToMethodArePassedToRepository()
        {
            //Arrange
            IEnumerable <TrendHitDto> trendhitDtos = null;
            TrendHit trendhit = new TrendHit(1, 2, ExtremumType.PeakByClose)
            {
                Id = 1, Guid = "AC180C9B-E6D2-4138-8E0A-BE31FCE8626D", Value = 1.234, DistanceToLine = 0.0004, PreviousRangeGuid = null, NextRangeGuid = "89BFF378-F310-4A28-B753-00A0FF9A852C"
            };
            Mock <ITrendlineRepository> mockedRepository = new Mock <ITrendlineRepository>();

            mockedRepository.
            Setup(r => r.UpdateTrendHits(It.IsAny <IEnumerable <TrendHitDto> >())).
            Callback <IEnumerable <TrendHitDto> >((col) => trendhitDtos = col).Verifiable();

            //Act
            TrendlineService service = new TrendlineService(mockedRepository.Object);

            service.UpdateTrendHit(trendhit);

            //Assert
            IEnumerable <TrendHitDto> expectedTrendhitDtos = new TrendHitDto[] { trendhit.ToDto() };

            mockedRepository.Verify(r => r.UpdateTrendHits(It.IsAny <IEnumerable <TrendHitDto> >()), Times.Exactly(1));
            Assert.IsTrue(trendhitDtos.HasEqualItems(expectedTrendhitDtos));
        }