Exemple #1
0
            public async Task WhenGivenJsonObjectDownloadPdf()
            {
                var httpClientOptions = ConfigurationHelpers.CreateOptions(HttpClientOptions);
                var httpClientFactory = new HttpClientFactory(httpClientOptions);

                var trustedTicketGetter = new TrustedTicketGetter(Options, TableauAdminCredentials, TableauTenantFinder, httpClientFactory);
                var testService         = new TableauVisualServices(trustedTicketGetter, Options, Logger, httpClientFactory) as ITableauVisualServices;

                var testGetPdfOptions = new CreatePdfOptions("AverageRiskMap", "AverageRiskDashboard",
                                                             "Average Risk Dashboard");

                var downloadPdfOptions = await testService.CreatePdfAsync(testGetPdfOptions);

                Assert.IsNotNull(downloadPdfOptions);

                var downloadPdfJsonObject = JsonConvert.SerializeObject(downloadPdfOptions);

                var deserializedPdfOptions = JsonConvert.DeserializeObject <DownloadPdfOptions>(downloadPdfJsonObject);

                var pdfBytes = await testService.DownloadPdfAsync(deserializedPdfOptions);

                Assert.IsNotNull(pdfBytes);

                var tempPath = Path.GetTempPath() + @"TableauPDFTestDownload";

                Directory.CreateDirectory(tempPath); //Doesn't create if it already exists

                var dateTime = DateTime.UtcNow.ToString().RemoveSpecialCharacters();

                var tempFilePath = tempPath + $@"\test-{dateTime}.pdf";

                File.WriteAllBytes(tempFilePath, pdfBytes);
            }
Exemple #2
0
            public async Task WhenSignedInCreatePdf()
            {
                var httpClientOptions = ConfigurationHelpers.CreateOptions(HttpClientOptions);
                var httpClientFactory = new HttpClientFactory(httpClientOptions);

                var trustedTicketGetter = new TrustedTicketGetter(Options, TableauAdminCredentials, TableauTenantFinder, httpClientFactory);
                var testService         = new TableauVisualServices(trustedTicketGetter, Options, Logger, httpClientFactory) as ITableauVisualServices;

                var testGetPdfOptions = new CreatePdfOptions("AverageRiskMap", "AverageRiskDashboard",
                                                             "Average Risk Dashboard");

                var downloadPdfOptions = await testService.CreatePdfAsync(testGetPdfOptions);

                Assert.IsNotNull(downloadPdfOptions);
            }