예제 #1
0
        public async Task <IActionResult> DownloadOpportunitySpreadsheetAsync(int opportunityId)
        {
            var downloadedFileInfo = await _opportunityService.GetOpportunitySpreadsheetDataAsync(opportunityId);

            return(File(downloadedFileInfo.FileContent,
                        downloadedFileInfo.ContentType,
                        downloadedFileInfo.FileName));
        }
예제 #2
0
        public When_Opportunity_Controller_Download_Opportunity_Spreadsheet_Is_Called()
        {
            var config = new MapperConfiguration(c => c.AddMaps(typeof(OpportunityMapper).Assembly));

            var mapper = new Mapper(config);

            _opportunityService = Substitute.For <IOpportunityService>();
            _opportunityService.GetOpportunitySpreadsheetDataAsync(1).Returns(
                new FileDownloadDto
            {
                FileName    = "test_file.xlsx",
                ContentType = "application/file",
                FileContent = new byte[] { 01, 02 }
            });

            var opportunityController = new OpportunityController(_opportunityService, mapper);

            _result = opportunityController.DownloadOpportunitySpreadsheetAsync(1).GetAwaiter().GetResult();
        }