public void UploadFileToS3_GetS3SignedUrl_Delete_IntegrationTest() { // https://console.aws.amazon.com/s3/home?region=us-west-2# AppFileService target = (AppFileService)AppFileEN.GetService(""); string key = "systemtest/testintegrationfile2.jpg"; // test deleting existing file try { target.DeleteFromS3(key); } catch (Exception) { } byte[] testbytes = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; target.UploadFileToS3(key, testbytes, "image/jpg", Guid.NewGuid()); var url = target.GetS3SignedUrlAccess(key, 5); using (System.Net.WebClient w = new System.Net.WebClient()) { byte[] data = w.DownloadData(url); Assert.IsTrue(data.Length > 0); } target.DeleteFromS3(key); }
public Form1(WebClientService webClientService, AppFileService appFileService) { InitializeComponent(); _webClientService = webClientService; _appFileService = appFileService; _appCurrentDirectory = Application.StartupPath; }
public void UploadToS3Completed_Test() { // this test inserts a new file into the database and updates its status // by completing it string fileName = "testfile.jpg"; AppFileService target = (AppFileService)AppFileEN.GetService(""); var appFile = target.InsertNewFile(fileName, (int)EntityEnums.AppEntityFileTypeEnum.Test_Picture_Upload, TestEnums.User.constPatientUserID); Assert.AreEqual(appFile.AppFileUploadStatusID, (short)EntityEnums.AppEntityFileUploadStatus.Incomplete); string fileKey = "systemtest/testfile.jpg"; target.DeleteFromS3(fileKey); // clearning test byte[] bytes = { 0, 1, 2, 3, 4 }; target.UploadFileToS3(fileKey, bytes, "image/jpg", Guid.NewGuid()); target.UploadToS3Completed(new AppFileUploadToS3CompletedSP() { AppFileID = appFile.AppFileID }); var actualfile = target.GetByIDT(appFile.AppFileID); short newStatus = actualfile.AppFileUploadStatusID; try // Cleaning test data { target.DeleteFromS3(fileKey); target.Delete(actualfile); } catch (Exception) { } Assert.AreEqual(newStatus, (short)EntityEnums.AppEntityFileUploadStatus.Completed); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; this.Resuming += App_Resuming; this.EnteredBackground += App_EnteredBackground; var DS = new DialogService(); Repository.StoreFactory <IDialogService>(() => DS); var KEH = new KnownExceptionHandler(); Repository.StoreFactory <IKnownExceptionHandler>(() => KEH); var NS = new NavigationService(); Repository.StoreFactory <INavigationService>(() => NS); var TPS = new TilePinService(); Repository.StoreFactory <ITilePinService>(() => TPS); var TS = new ToastService(); Repository.StoreFactory <IToastService>(() => TS); var AFS = new AppFileService(); Repository.StoreFactory <IAppFileService>(() => AFS); var AMS = new AppMetadataService(); Repository.StoreFactory <IAppMetadata>(() => AMS); }
public void FileExistsS3_Test2() { AppFileService target = (AppFileService)AppFileEN.GetService(""); string key = "systemtest/randomfilename123123123.jpg"; bool expected = false; bool actual = target.FileExistsS3(key); Assert.AreEqual(expected, actual, "file " + key + "should not exists on Amazon S3 bucket."); }
public void FileExistsS3_Test() { AppFileService target = (AppFileService)AppFileEN.GetService(""); string key = "systemtest/testwebprivatedownload.jpg"; bool expected = true; bool actual = target.FileExistsS3(key); Assert.AreEqual(expected, actual, "file " + key + "should exist on Amazon S3 bucket."); }
public void GetFileKey2Test() { AppFileService target = (AppFileService)AppFileEN.GetService(""); string recordId = "123123"; string virtualPathTemplate = "userfiles/u{userid}/visitattach/{recordid}/image.jpg"; string selectedfileName = "filename.jpg"; long userId = 100000001; string expected = "userfiles/u100000001/visitattach/123123/image.jpg"; string actual = target.GetFileKeyByPathTemplate(virtualPathTemplate, selectedfileName, userId, recordId); Assert.AreEqual(expected, actual); }
public void GetFileKeyTest() { var AppFile = AppFileServiceTest.CreateNewAppFile(); AppFileService target = (AppFileService)AppFileEN.GetService(""); string recordId = "123123"; string virtualPathTemplate = "userfiles/u{userid}/visitattach/{recordid}/{filename}"; string selectedfileName = "myfile.zip"; long userId = 100000001; string expected = "userfiles/u100000001/visitattach/123123/myfile.zip"; string actual = target.GetFileKeyByPathTemplate(virtualPathTemplate, selectedfileName, userId, recordId); Assert.AreEqual(expected, actual); }
public void GetS3SignedUrlAccessTest() { // https://console.aws.amazon.com/s3/home?region=us-west-2# // test generates a url for downloading a file from S3 // it downloads the file and checks the length to be more than 0 AppFileService target = (AppFileService)AppFileEN.GetService(""); string key = "systemtest/testwebprivatedownload.jpg"; var url = target.GetS3SignedUrlAccess(key, 5); using (System.Net.WebClient w = new System.Net.WebClient()) { byte[] data = w.DownloadData(url); Assert.IsTrue(data.Length > 0); } }