Пример #1
0
        public async Task GetTimelineTest()
        {
            // Create DetailService instance
            ReviewService service = new ReviewService();

            var range = new TimestampRange()
            {
                End = Timestamp.FromDateTimeOffset(offsetEnd), Start = Timestamp.FromDateTimeOffset(offsetStart)
            };

            FakeServerStreamWriter <TimelineResponse> fakeServerStreamWriter = new FakeServerStreamWriter <TimelineResponse>();
            var timelinesForTest = new Dictionary <int, List <TimestampRange> >(timelines);

            fakeServerStreamWriter.Received += applicationResponse =>
            {
                Assert.Contains(applicationResponse.Range, timelinesForTest[applicationResponse.Application.Id]);

                timelinesForTest[applicationResponse.Application.Id].Remove(applicationResponse.Range);

                if (timelinesForTest[applicationResponse.Application.Id].Count == 0)
                {
                    timelinesForTest.Remove(applicationResponse.Application.Id);
                }
            };

            await service.GetTimeline(new TimelineRequest()
            {
                Range = range
            }, fakeServerStreamWriter, null);

            Assert.IsEmpty(timelinesForTest);
        }
Пример #2
0
        public async Task GetApplicationsTest()
        {
            // Create DetailService instance
            DashboardService service = new DashboardService();

            var range = new TimestampRange()
            {
                End = Timestamp.FromDateTimeOffset(offsetEnd), Start = Timestamp.FromDateTimeOffset(offsetStart)
            };

            FakeServerStreamWriter <ApplicationResponse> fakeServerStreamWriter = new FakeServerStreamWriter <ApplicationResponse>();
            var totalTimesForTest = new Dictionary <int, int>(totalTimes);

            fakeServerStreamWriter.Received += applicationResponse =>
            {
                Assert.AreEqual(totalTimesForTest[applicationResponse.Application.Id], applicationResponse.TotalTime.Seconds);
                totalTimesForTest.Remove(applicationResponse.Application.Id);
            };

            await service.GetApplications(new ApplicationRequest()
            {
                Range = range
            }, fakeServerStreamWriter, null);

            Assert.IsEmpty(totalTimesForTest);
        }