public void GetCvs_IsoNull_ApiClientReturnsData_ShouldReturnFile()
        {
            var dictionary = new Dictionary <IsoRegionModel, CasesDeathModel>();

            dictionary.Add(
                new IsoRegionModel()
            {
                RegionName = "United State", Iso = "US"
            },
                new CasesDeathModel()
            {
                Cases = 1, Deaths = 1
            });

            var reportService = new Mock <IReportService>();

            reportService.Setup(x => x.GetTop10CovidCasesByCountry())
            .Returns(() => dictionary);

            var controller = new DownloadController(reportService.Object);
            var result     = controller.GetCvsForRegion(null) as FileResult;

            Assert.IsInstanceOf <FileContentResult>(result);
            Assert.AreEqual("text/csv", result.ContentType);
            Assert.AreEqual("CasesByCountry.csv", result.FileDownloadName);
        }
        public void GetCvs_IsoHasValue_ApiClientReturnsData_ShouldReturnFile()
        {
            var dictionary = new Dictionary <ProvinceIsoModel, CasesDeathModel>();
            var iso        = "US";

            dictionary.Add(
                new ProvinceIsoModel()
            {
                Province = "Alabama", Iso = iso
            },
                new CasesDeathModel()
            {
                Cases = 1, Deaths = 1
            });

            var reportService = new Mock <IReportService>();

            reportService.Setup(x => x.GetTop10CovidCasesByCountryRegions(It.IsAny <string>()))
            .Returns(() => dictionary);

            var controller = new DownloadController(reportService.Object);
            var result     = controller.GetCvsForRegion(iso) as FileResult;

            Assert.IsInstanceOf <FileContentResult>(result);
            Assert.AreEqual("text/csv", result.ContentType);
            Assert.AreEqual("CasesByCountryProvidence.csv", result.FileDownloadName);
        }
        public void GetCsv_ApiClientThrowsException_ShouldReturnEmptyResult()
        {
            var reportService = new Mock <IReportService>();

            reportService.Setup(x => x.GetTop10CovidCasesByCountry())
            .Throws(new ApiClientException("test message"));

            var controller = new DownloadController(reportService.Object);
            var result     = controller.GetCvsForRegion(null);

            Assert.IsInstanceOf <EmptyResult>(result);
        }