public async Task Set_activation_should_set_state_on_eligible_files() { const string testText = "File Activation test 6"; Msg.Title(testText, "Set ImportFile::IsActivated"); var ts = new TestSupport(); var customerUid = Guid.NewGuid(); var startDateTime = ts.FirstEventDate; var createProjectResponse = ExecutorTestFixture.CreateCustomerProject(customerUid.ToString(), testText, Boundaries.Boundary1); ts.ProjectUid = new Guid(createProjectResponse.Result.Id); var importFilename = TestFileResolver.File(TestFile.TestAlignment2); var fullFilePath = TestFileResolver.GetFullPath(importFilename); var fileResult = await ImportFiles(ts, ts.ProjectUid, customerUid, startDateTime, fullFilePath); await DoActivationRequest(customerUid, ts.ProjectUid.ToString(), fileResult.ImportedFileDescriptor.ImportedFileUid, false, HttpStatusCode.OK, 200, "Success"); //Confirm it's deactivated for this user var importFile = new ImportFile(); var importFileList = await importFile.GetImportedFilesFromWebApi <ImportedFileDescriptorListResult>($"api/v6/importedfiles?projectUid={ts.ProjectUid}", customerUid); Assert.Single(importFileList.ImportedFileDescriptors); Assert.False(importFileList.ImportedFileDescriptors[0].IsActivated, "Should be deactivated for user 1"); //and activated for another user importFileList = await importFile.GetImportedFilesFromWebApi <ImportedFileDescriptorListResult>($"api/v6/importedfiles?projectUid={ts.ProjectUid}", customerUid, RestClient.ANOTHER_JWT); Assert.Single(importFileList.ImportedFileDescriptors); Assert.True(importFileList.ImportedFileDescriptors[0].IsActivated, "Should be activated for user 2"); }
public async Task TestImportV5ForTbcSvlFile_AlignmentType_OK() { var testText = "File Import V5TBC test 1"; Msg.Title(testText, "Create project then upload Alignment file via TBC V5 API"); var ts = new TestSupport(); var startDateTime = ts.FirstEventDate; var projectName = $"project {testText}"; var createResponse = await ts.CreateProjectViaWebApiV5TBC(projectName); var returnLongV5Result = JsonConvert.DeserializeObject <ReturnLongV5Result>(createResponse); var importFile = new ImportFile(); var importFilename = TestFileResolver.File(TestFile.TestAlignment1); var importFileArray = new[] { "| EventType | ProjectUid | CustomerUid | Name | ImportedFileType | FileCreatedUtc | FileUpdatedUtc | ImportedBy | IsActivated | MinZoomLevel | MaxZoomLevel |", $"| ImportedFileDescriptor | {ts.ProjectUid} | {ts.CustomerUid} | {importFilename} | 3 | {startDateTime} | {startDateTime.AddDays(5)} | [email protected] | true | 15 | 19 |" }; var response = await importFile.SendImportedFilesToWebApiV5TBC(ts, returnLongV5Result.Id, importFileArray, 1); var importFileV5Result = JsonConvert.DeserializeObject <ReturnLongV5Result>(response); Assert.Equal(HttpStatusCode.OK, importFileV5Result.Code); Assert.NotEqual(-1, importFileV5Result.Id); var importFileList = await importFile.GetImportedFilesFromWebApi <ImmutableList <DesignDetailV5Result> >($"api/v5/projects/{returnLongV5Result.Id}/importedfiles", ts.CustomerUid); Assert.True(importFileList.Count == 1, "Expected 1 imported files but got " + importFileList.Count); Assert.Equal(importFileV5Result.Id, importFileList[0].id); Assert.Equal(Path.GetFileName(importFilename), importFileList[0].name); Assert.Equal((int)ImportedFileType.Alignment, importFileList[0].fileType); }
public async Task TestImportANewFileThenUpdateTheAlignmentFile(string uriRoot) { const string testText = "File Import align test 3"; Msg.Title(testText, "Create standard project then upload a new alignment file. Then update alignment file"); var ts = new TestSupport(); var customerUid = Guid.NewGuid(); var startDateTime = ts.FirstEventDate; var createProjectResponse = ExecutorTestFixture.CreateCustomerProject(customerUid.ToString(), testText, Boundaries.Boundary1); ts.ProjectUid = new Guid(createProjectResponse.Result.Id); var importFile = new ImportFile(uriRoot); var importFilename = TestFileResolver.File(TestFile.TestAlignment1); var fullFilePath = TestFileResolver.GetFullPath(importFilename); var importFileArray = new[] { "| EventType | ProjectUid | CustomerUid | Name | ImportedFileType | FileCreatedUtc | FileUpdatedUtc | ImportedBy | IsActivated | MinZoomLevel | MaxZoomLevel |", $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {fullFilePath} | 3 | {startDateTime} | {startDateTime.AddDays(5)} | [email protected] | true | 15 | 19 |", $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {fullFilePath} | 3 | {startDateTime} | {startDateTime.AddDays(5)} | [email protected] | true | 15 | 19 |" }; var filesResult = await importFile.SendRequestToFileImportV6(ts, importFileArray, 1, new ImportOptions(HttpMethod.Post, new[] { $"filename={importFilename}" })); var expectedResult1 = importFile.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor; ts.CompareTheActualImportFileWithExpected(filesResult.ImportedFileDescriptor, expectedResult1, true); await importFile.SendRequestToFileImportV6(ts, importFileArray, 2, new ImportOptions(HttpMethod.Post, new[] { $"filename={importFilename}" }), HttpStatusCode.BadRequest); var expectedResult2 = importFile.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor; var importFileList = await importFile.GetImportedFilesFromWebApi <ImportedFileDescriptorListResult>($"api/v6/importedfiles?projectUid={ts.ProjectUid}", customerUid); Assert.True(importFileList.ImportedFileDescriptors.Count == 1, "Expected 1 imported files but got " + importFileList.ImportedFileDescriptors.Count); ts.CompareTheActualImportFileWithExpectedV6(importFileList.ImportedFileDescriptors[0], expectedResult2, true); }
public async Task GetImportedFiles_should_return_activation_state() { const string testText = "File Activation test 1"; Msg.Title(testText, "Get all activated import files"); var ts = new TestSupport(); var customerUid = Guid.NewGuid(); var startDateTime = ts.FirstEventDate; var createProjectResponse = ExecutorTestFixture.CreateCustomerProject(customerUid.ToString(), testText, Boundaries.Boundary1); ts.ProjectUid = new Guid(createProjectResponse.Result.Id); var importFile = new ImportFile(); var importFilename1 = TestFileResolver.File(TestFile.TestAlignment1); var fullFilePath1 = TestFileResolver.GetFullPath(importFilename1); var importFilename2 = TestFileResolver.File(TestFile.TestAlignment2); var fullFilePath2 = TestFileResolver.GetFullPath(importFilename2); var importFileArray = new[] { "| EventType | ProjectUid | CustomerUid | Name | ImportedFileType | FileCreatedUtc | FileUpdatedUtc | ImportedBy | IsActivated |", $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {fullFilePath1} | 3 | {startDateTime} | {startDateTime.AddDays(5)} | [email protected] | true |", $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {fullFilePath2} | 3 | {startDateTime} | {startDateTime.AddDays(5)} | [email protected] | true |" }; var filesResult = await importFile.SendRequestToFileImportV6(ts, importFileArray, 1, new ImportOptions(HttpMethod.Post)); var expectedResult = importFile.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor; expectedResult.IsActivated = true; ts.CompareTheActualImportFileWithExpected(filesResult.ImportedFileDescriptor, expectedResult, true); filesResult = await importFile.SendRequestToFileImportV6(ts, importFileArray, 2, new ImportOptions(HttpMethod.Post)); expectedResult = importFile.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor; expectedResult.IsActivated = true; ts.CompareTheActualImportFileWithExpectedV6(filesResult.ImportedFileDescriptor, expectedResult, true); var importFileList = await importFile.GetImportedFilesFromWebApi <ImportedFileDescriptorListResult>($"api/v6/importedfiles?projectUid={ts.ProjectUid}", customerUid); Assert.True(importFileList.ImportedFileDescriptors.Count == 2, "Expected 2 imported files but got " + importFileList.ImportedFileDescriptors.Count); ts.CompareTheActualImportFileWithExpectedV6(importFileList.ImportedFileDescriptors[1], expectedResult, true); var activatedFileList = await importFile.GetImportedFilesFromWebApi <ImportedFileDescriptorListResult>($"api/v6/importedfiles?projectUid={ts.ProjectUid}", customerUid); Assert.Equal(2, activatedFileList.ImportedFileDescriptors.Count); }
public async Task TestImport2ReferenceSurfaceFiles(string uriRoot1, string uriRoot2) { const string testText = "File Import ref test 3"; Msg.Title(testText, "Create standard project and customer then upload two Reference surface files"); var ts = new TestSupport(); var customerUid = Guid.NewGuid(); var startDateTime = ts.FirstEventDate; var createProjectResponse = ExecutorTestFixture.CreateCustomerProject(customerUid.ToString(), testText, Boundaries.Boundary1); ts.ProjectUid = new Guid(createProjectResponse.Result.Id); var importFileParent = new ImportFile(uriRoot1); var importFileChild = new ImportFile(uriRoot2); //Parent Design var importFilename = TestFileResolver.File(TestFile.TestDesignSurface1); var parentName = TestFileResolver.GetFullPath(importFilename); var importFileArray = new[] { "| EventType | ProjectUid | CustomerUid | Name | ImportedFileType | FileCreatedUtc | FileUpdatedUtc | ImportedBy | IsActivated | MinZoomLevel | MaxZoomLevel |", $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {parentName} | 1 | {startDateTime} | {startDateTime.AddDays(5)} | [email protected] | true | 15 | 19 |" }; var filesResult1 = await importFileParent.SendRequestToFileImportV6(ts, importFileArray, 1, new ImportOptions(HttpMethod.Post, new[] { $"filename={importFilename}" })); var expectedResult1 = importFileParent.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor; ts.CompareTheActualImportFileWithExpected(filesResult1.ImportedFileDescriptor, importFileParent.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor, true); //Reference Surfaces var parentUid = filesResult1.ImportedFileDescriptor.ImportedFileUid; var offset1 = 1.5; var offset2 = -2.5; parentName = Path.GetFileNameWithoutExtension(parentName); var name1 = $"{parentName} +{offset1}m"; var name2 = $"{parentName} {offset2}m"; var importFileArray2 = new[] { "| EventType | ProjectUid | CustomerUid | Name | ImportedFileType | FileCreatedUtc | FileUpdatedUtc | ImportedBy | IsActivated | MinZoomLevel | MaxZoomLevel | ParentUid | Offset |", $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {name1} | 6 | {startDateTime} | {startDateTime.AddDays(5)} | [email protected] | true | 15 | 19 | {parentUid} | {offset1} |", $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {name2} | 6 | {startDateTime} | {startDateTime.AddDays(5)} | [email protected] | true | 15 | 19 | {parentUid} | {offset2} |" }; var filesResult2 = await importFileChild.SendRequestToFileImportV6(ts, importFileArray2, 1, new ImportOptions(HttpMethod.Post, new[] { $"filename={HttpUtility.UrlEncode(name1)}" })); var expectedResult2 = importFileChild.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor; ts.CompareTheActualImportFileWithExpected(filesResult2.ImportedFileDescriptor, expectedResult2, true); var filesResult3 = await importFileChild.SendRequestToFileImportV6(ts, importFileArray2, 2, new ImportOptions(HttpMethod.Post, new[] { $"filename={HttpUtility.UrlEncode(name2)}" })); var expectedResult3 = importFileChild.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor; ts.CompareTheActualImportFileWithExpected(filesResult3.ImportedFileDescriptor, expectedResult3, true); var importFileList = await importFileParent.GetImportedFilesFromWebApi <ImportedFileDescriptorListResult>($"api/v6/importedfiles?projectUid={ts.ProjectUid}", customerUid); Assert.True(importFileList.ImportedFileDescriptors.Count == 3, "Expected 3 imported files but got " + importFileList.ImportedFileDescriptors.Count); ts.CompareTheActualImportFileWithExpectedV6(importFileList.ImportedFileDescriptors[0], expectedResult1, true); ts.CompareTheActualImportFileWithExpectedV6(importFileList.ImportedFileDescriptors[1], expectedResult2, true); ts.CompareTheActualImportFileWithExpectedV6(importFileList.ImportedFileDescriptors[2], expectedResult3, true); }
public async Task Set_activation_should_ignore_reference_surface(string uriRoot1, string uriRoot2) { const string testText = "File Activation test 8"; Msg.Title(testText, "ignore reference surface"); var ts = new TestSupport(); var customerUid = Guid.NewGuid(); var startDateTime = ts.FirstEventDate; var createProjectResponse = ExecutorTestFixture.CreateCustomerProject(customerUid.ToString(), testText, Boundaries.Boundary1); ts.ProjectUid = new Guid(createProjectResponse.Result.Id); var importFileParent = new ImportFile(uriRoot1); var importFileChild = new ImportFile(uriRoot2); //Import parent design and reference surface var importFilename = TestFileResolver.File(TestFile.TestDesignSurface1); var parentName = TestFileResolver.GetFullPath(importFilename); var importFileArray = new[] { "| EventType | ProjectUid | CustomerUid | Name | ImportedFileType | FileCreatedUtc | FileUpdatedUtc | ImportedBy | IsActivated | MinZoomLevel | MaxZoomLevel |", $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {parentName} | 1 | {startDateTime} | {startDateTime.AddDays(5)} | [email protected] | true | 15 | 19 |" }; var filesResult = await importFileParent.SendRequestToFileImportV6(ts, importFileArray, 1, new ImportOptions(HttpMethod.Post, new[] { $"filename={importFilename}" })); var parentUid = filesResult.ImportedFileDescriptor.ImportedFileUid; var offset = 1.5; var name = $"{Path.GetFileNameWithoutExtension(parentName)} +{offset}m"; var importFileArray2 = new[] { "| EventType | ProjectUid | CustomerUid | Name | ImportedFileType | FileCreatedUtc | FileUpdatedUtc | ImportedBy | IsActivated | MinZoomLevel | MaxZoomLevel | ParentUid | Offset |", $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {name} | 6 | {startDateTime} | {startDateTime.AddDays(5)} | [email protected] | true | 15 | 19 | {parentUid} | {offset} |" }; var filesResult2 = await importFileChild.SendRequestToFileImportV6(ts, importFileArray2, 1, new ImportOptions(HttpMethod.Post, new[] { $"filename={HttpUtility.UrlEncode(name)}" })); //Try and deactivate the reference surface await DoActivationRequest(customerUid, ts.ProjectUid.ToString(), filesResult2.ImportedFileDescriptor.ImportedFileUid, false, HttpStatusCode.OK, 200, "Success"); //Confirm it has not changed state var importFileList = await importFileParent.GetImportedFilesFromWebApi <ImportedFileDescriptorListResult>($"api/v6/importedfiles?projectUid={ts.ProjectUid}", customerUid); Assert.True(importFileList.ImportedFileDescriptors.Count == 2, "Expected 2 imported files but got " + importFileList.ImportedFileDescriptors.Count); var refSurf = importFileList.ImportedFileDescriptors.SingleOrDefault(i => i.ImportedFileUid == filesResult2.ImportedFileDescriptor.ImportedFileUid); Assert.NotNull(refSurf); Assert.True(refSurf.IsActivated, "Reference surface should be activated"); }
public async Task TestNoFileUploads(string uriRoot) { const string testText = "File Import Misc 1"; Msg.Title(testText, "Create standard project and customer then get imported files - There should be none."); var ts = new TestSupport(); var customerUid = Guid.NewGuid(); var createProjectResponse = ExecutorTestFixture.CreateCustomerProject(customerUid.ToString(), testText, Boundaries.Boundary1); ts.ProjectUid = new Guid(createProjectResponse.Result.Id); var importFile = new ImportFile(uriRoot); var expectedResults = importFile.ExpectedImportFileDescriptorsListResult; var filesResult = await importFile.GetImportedFilesFromWebApi <ImportedFileDescriptorListResult>($"api/v6/importedfiles?projectUid={ts.ProjectUid}", customerUid); Assert.True(filesResult.ImportedFileDescriptors.Count == expectedResults.ImportedFileDescriptors.Count, " Expected number of fields does not match actual"); Assert.Equal(expectedResults.ImportedFileDescriptors, filesResult.ImportedFileDescriptors); }
public async Task TestImportANewFileThenUpdateTheFileThenDeleteTheFile(string uriRoot) { const string testText = "File Import Misc 3"; Msg.Title(testText, "Inset a new file, upsert a new version and then delete the file"); var ts = new TestSupport(); var customerUid = Guid.NewGuid(); var startDateTime = ts.FirstEventDate; var createProjectResponse = ExecutorTestFixture.CreateCustomerProject(customerUid.ToString(), testText, Boundaries.Boundary1); ts.ProjectUid = new Guid(createProjectResponse.Result.Id); var importFile = new ImportFile(uriRoot); var importFilename = TestFileResolver.File(TestFile.TestDesignSurface1); var fullFilePath = TestFileResolver.GetFullPath(importFilename); var importFileArray = new[] { "| EventType | ProjectUid | CustomerUid | Name | ImportedFileType | FileCreatedUtc | FileUpdatedUtc | ImportedBy | SurveyedUtc | IsActivated | MinZoomLevel | MaxZoomLevel |", $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {fullFilePath} | 2 | {startDateTime} | {startDateTime.AddDays(5)} | [email protected] | {startDateTime} | true | 0 | 0 |", $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {fullFilePath} | 2 | {startDateTime.AddDays(10)} | {startDateTime.AddDays(10)} | [email protected] | {startDateTime} | true | 0 | 0 |" }; var filesResult = await importFile.SendRequestToFileImportV6(ts, importFileArray, 1, new ImportOptions(HttpMethod.Post, new[] { $"filename={importFilename}" })); var expectedResult1 = importFile.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor; ts.CompareTheActualImportFileWithExpected(filesResult.ImportedFileDescriptor, expectedResult1, true); _ = await importFile.SendRequestToFileImportV6(ts, importFileArray, 2, new ImportOptions(HttpMethod.Put, new[] { $"filename={importFilename}" })); var expectedResult2 = importFile.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor; var importFileList = await importFile.GetImportedFilesFromWebApi <ImportedFileDescriptorListResult>($"api/v6/importedfiles?projectUid={ts.ProjectUid}", customerUid); Assert.True(importFileList.ImportedFileDescriptors.Count == 1, "Expected 1 imported files but got " + importFileList.ImportedFileDescriptors.Count); ts.CompareTheActualImportFileWithExpectedV6(importFileList.ImportedFileDescriptors[0], expectedResult2, true); importFile.ImportedFileUid = filesResult.ImportedFileDescriptor.ImportedFileUid; var deleteResult = await importFile.SendRequestToFileImportV6(ts, importFileArray, 1, new ImportOptions(HttpMethod.Delete)); Assert.Equal(0, deleteResult.Code); Assert.Equal("success", deleteResult.Message); }
public async Task TestImport2SurveyedSurfaceFiles(string uriRoot) { const string testText = "File Import v2"; Msg.Title(testText, "Create standard project and customer then upload two Surveryed surface files"); var ts = new TestSupport(); var customerUid = Guid.NewGuid(); var startDateTime = ts.FirstEventDate; var createProjectResponse = ExecutorTestFixture.CreateCustomerProject(customerUid.ToString(), testText, Boundaries.Boundary1); ts.ProjectUid = new Guid(createProjectResponse.Result.Id); var importFile = new ImportFile(uriRoot); var importFilename1 = TestFileResolver.File(TestFile.TestDesignSurface1); var importFilename2 = TestFileResolver.File(TestFile.TestDesignSurface2); var importFileArray = new[] { "| EventType | ProjectUid | CustomerUid | Name | ImportedFileType | FileCreatedUtc | FileUpdatedUtc | ImportedBy | SurveyedUtc | IsActivated | MinZoomLevel | MaxZoomLevel |", $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {TestFileResolver.GetFullPath(importFilename1)} | 2 | {startDateTime} | {startDateTime.AddDays(5)} | [email protected] | {startDateTime} | true | 0 | 0 |", $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {TestFileResolver.GetFullPath(importFilename2)} | 2 | {startDateTime} | {startDateTime.AddDays(5)} | [email protected] | {startDateTime} | true | 0 | 0 |" }; var filesResult = await importFile.SendRequestToFileImportV6(ts, importFileArray, 1, new ImportOptions(HttpMethod.Post, new[] { $"filename={importFilename1}" })); var expectedResult1 = importFile.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor; ts.CompareTheActualImportFileWithExpected(filesResult.ImportedFileDescriptor, expectedResult1, true); var filesResult2 = await importFile.SendRequestToFileImportV6(ts, importFileArray, 2, new ImportOptions(HttpMethod.Post, new[] { $"filename={importFilename2}" })); var expectedResult2 = importFile.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor; ts.CompareTheActualImportFileWithExpected(filesResult2.ImportedFileDescriptor, expectedResult2, true); var importFileList = await importFile.GetImportedFilesFromWebApi <ImportedFileDescriptorListResult>($"api/v6/importedfiles?projectUid={ts.ProjectUid}", customerUid); Assert.True(importFileList.ImportedFileDescriptors.Count == 2, "Expected 2 imported files but got " + importFileList.ImportedFileDescriptors.Count); ts.CompareTheActualImportFileWithExpectedV6(importFileList.ImportedFileDescriptors[0], expectedResult1, true); ts.CompareTheActualImportFileWithExpectedV6(importFileList.ImportedFileDescriptors[1], expectedResult2, true); }