Beispiel #1
0
        public void Constructor_fromDto_hasCorrectProperties()
        {
            //Act.
            var trendHitDto = new TrendHitDto()
            {
                Id                = DEFAULT_ID,
                TrendlineId       = DEFAULT_TRENDLINE_ID,
                IndexNumber       = DEFAULT_INDEX_NUMBER,
                ExtremumType      = DEFAULT_EXTREMUM_TYPE,
                Value             = DEFAULT_VALUE,
                DistanceToLine    = DEFAULT_DISTANCE_TO_LINE,
                Guid              = DEFAULT_GUID,
                PreviousRangeGuid = DEFAULT_PREVIOUS_RANGE_GUID,
                NextRangeGuid     = DEFAULT_NEXT_RANGE_GUID
            };

            var trendHit = TrendHit.FromDto(trendHitDto);

            //Assert.
            Assert.AreEqual(DEFAULT_ID, trendHit.Id);
            Assert.AreEqual(DEFAULT_GUID, trendHit.Guid);
            Assert.AreEqual(DEFAULT_TRENDLINE_ID, trendHit.TrendlineId);
            Assert.AreEqual(DEFAULT_INDEX_NUMBER, trendHit.IndexNumber);
            Assert.AreEqual(DEFAULT_EXTREMUM_TYPE, (int)trendHit.ExtremumType);
            Assert.AreEqual(DEFAULT_VALUE, trendHit.Value);
            Assert.AreEqual(DEFAULT_DISTANCE_TO_LINE, trendHit.DistanceToLine);
            Assert.AreEqual(DEFAULT_PREVIOUS_RANGE_GUID, trendHit.PreviousRangeGuid);
            Assert.AreEqual(DEFAULT_NEXT_RANGE_GUID, trendHit.NextRangeGuid);
        }
Beispiel #2
0
        private Dictionary <int, TrendHit> GetTrendHitsMap(int assetId, int timeframeId)
        {
            _repository = new EFTrendlineRepository();
            IEnumerable <TrendHitDto>  dtos         = _repository.GetTrendHits();
            IEnumerable <TrendHit>     trendHits    = dtos.Select(th => TrendHit.FromDto(th));
            Dictionary <int, TrendHit> trendHitsMap = new Dictionary <int, TrendHit>();

            Dictionary <int, ExtremumGroup> extremumGroupsMap = GetExtremumGroupsMap(assetId, timeframeId);

            foreach (var trendHit in trendHits)
            {
                ExtremumGroup eg = null;
                extremumGroupsMap.TryGetValue(trendHit.ExtremumGroupId, out eg);
                if (eg != null)
                {
                    trendHit.ExtremumGroup = eg;
                }
                trendHitsMap.Add(trendHit.TrendHitId, trendHit);
            }

            return(trendHitsMap);
        }