コード例 #1
0
        public async Task ShouldReturnJsonReport()
        {
            const int    year  = 2018;
            const int    month = 2;
            const string type  = "json";

            var actionResult = await SendReportRequestAsync(year, month, type);

            var report = MvcUtils.GetSuccessResultData <Report>(actionResult);

            Assert.Equal(year.ToString(), report.Year);
            Assert.Equal(new DateTime(year, month, 1).ToString("MMMM"), report.Month);
            Assert.Equal(5, report.WeekPeriods.Length);
        }
コード例 #2
0
        public async Task ShouldReturnTxtReport()
        {
            const int    year  = 2018;
            const int    month = 2;
            const string type  = "txt";

            var actionResult = await SendReportRequestAsync(year, month, type);

            var report = MvcUtils.GetSuccessResultData <string>(actionResult);

            using (var reader = new StringReader(report))
            {
                var firstLine  = reader.ReadLine();
                var secondLine = reader.ReadLine();
                var thirdLine  = reader.ReadLine();

                Assert.Equal(string.Format("Year: {0:yyyy}, month: {0:MMMM}", new DateTime(year, month, 1)), firstLine);
                Assert.Equal("Week periods:", secondLine);
                Assert.Equal("1..2: EUR - max: 25.62, min: 25.62, media: 25.62; USD - max: 22.04, min: 22.04, media: 22.04; ", thirdLine);
            }
        }