public void GetXml_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.GetXmlForRegion(iso) as FileResult;

            Assert.IsInstanceOf <FileContentResult>(result);
            Assert.AreEqual("application/xml", result.ContentType);
            Assert.AreEqual("CasesByCountryProvidence.xml", result.FileDownloadName);
        }
        public void GetXml_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.GetXmlForRegion(null) as FileResult;

            Assert.IsInstanceOf <FileContentResult>(result);
            Assert.AreEqual("application/xml", result.ContentType);
            Assert.AreEqual("CasesByCountry.xml", result.FileDownloadName);
        }
        public void GetXml_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.GetXmlForRegion(null);

            Assert.IsInstanceOf <EmptyResult>(result);
        }