Пример #1
0
        public void MergeCharts_EmptyCharts_GetsMerged()
        {
            // Arrange
            var target = new Result();

            var source = new Result
            {
                Charts = new Dictionary <string, ChartDefinition>
                {
                    {
                        "chart", new ChartDefinition
                        {
                            Series = new Dictionary <string, SeriesDefinition>
                            {
                                {
                                    "series", new SeriesDefinition
                                    {
                                        Values = new List <InstantChartPoint>
                                        {
                                            new InstantChartPoint
                                            {
                                                X = Instant.FromUnixTimeSeconds(60 * 60 * 24 * 100), // 100 days
                                                Y = 100
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            // Act
            ResultUpdater.Merge(target, source);

            // Assert
            Assert.AreEqual(1, target.Charts["chart"].Series["series"].Values.Count);
        }
Пример #2
0
        public void MergeCharts_SameSeriesUpdatedData_GetsMerged()
        {
            // Arrange
            var target = new Result
            {
                Charts = new Dictionary <string, ChartDefinition>
                {
                    {
                        "chart", new ChartDefinition
                        {
                            Series = new Dictionary <string, SeriesDefinition>
                            {
                                {
                                    "series", new SeriesDefinition
                                    {
                                        Values = new List <InstantChartPoint>
                                        {
                                            new InstantChartPoint
                                            {
                                                X = Instant.Add(Instant.FromUnixTimeTicks(0), Duration.FromDays(100)),
                                                Y = 100
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var source = new Result
            {
                Charts = new Dictionary <string, ChartDefinition>
                {
                    {
                        "chart", new ChartDefinition
                        {
                            Series = new Dictionary <string, SeriesDefinition>
                            {
                                {
                                    "series", new SeriesDefinition
                                    {
                                        Values = new List <InstantChartPoint>
                                        {
                                            new InstantChartPoint
                                            {
                                                X = Instant.Add(Instant.FromUnixTimeTicks(0), Duration.FromDays(100)),
                                                Y = 100
                                            },
                                            new InstantChartPoint
                                            {
                                                X = Instant.Add(Instant.FromUnixTimeTicks(0), Duration.FromDays(101)),
                                                Y = 100
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            // Act
            ResultUpdater.Merge(target, source);

            // Assert
            Assert.AreEqual(2, target.Charts["chart"].Series["series"].Values.Count);
        }