Exemple #1
0
        public async Task TestImportANewFileThenUpdateTheDesignSurfaceFile_SameFileDates(string uriRoot)
        {
            const string testText = "File Import ds test 4";

            Msg.Title(testText, "Create standard project then upload a new design surface file. Then update design surface file however leave same FileDates");
            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 fullPath       = TestFileResolver.GetFullPath(importFilename);

            var importFileArray = new[] {
                "| EventType              | ProjectUid       | CustomerUid   | Name        | ImportedFileType | FileCreatedUtc  | FileUpdatedUtc              | ImportedBy                        | IsActivated | MinZoomLevel | MaxZoomLevel |",
                $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {fullPath} | 1                | {startDateTime} | {startDateTime.AddDays(5)}  | [email protected]        | true        | 15           | 19           |",
                $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {fullPath} | 1                | {startDateTime} | {startDateTime.AddDays(5)}  | [email protected]        | true        | 15           | 19           |",
                $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {fullPath} | 1                | {startDateTime} | {startDateTime.AddDays(5)}  | [email protected] | true        | 15           | 19           |"
            };

            await importFile.SendRequestToFileImportV6(ts, importFileArray, 1, new ImportOptions(HttpMethod.Post, new[] { $"filename={importFilename}" }));

            await importFile.SendRequestToFileImportV6(ts, importFileArray, 2, new ImportOptions(HttpMethod.Put, new[] { $"filename={importFilename}" }));

            var filesResult3 = await importFile.SendRequestToFileImportV6(ts, importFileArray, 2, new ImportOptions(HttpMethod.Put, new[] { $"filename={importFilename}" }));

            Assert.Single(filesResult3.ImportedFileDescriptor.ImportedFileHistory);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public async Task TestImportReferenceSurfaceFileWithoutParentShouldFail(string uriRoot)
        {
            const string testText = "File Import ref test 4";

            Msg.Title(testText, "Create standard project and customer then upload reference surface file without parent design uploaded");
            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);
            //Reference Surface
            var importFilename = TestFileResolver.File(TestFile.TestDesignSurface1);
            var parentName     = TestFileResolver.GetFullPath(importFilename);

            var parentUid       = Guid.NewGuid();
            var offset          = 1.5;
            var name            = $"{Path.GetFileNameWithoutExtension(parentName)} +{offset}m";
            var importFileArray = 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 errorResultObj = await importFile.SendRequestToFileImportV6(ts, importFileArray, 1, new ImportOptions(HttpMethod.Post, new[] { $"filename={HttpUtility.UrlEncode(name)}" }), HttpStatusCode.BadRequest);

            Assert.Equal("Missing parent design for reference surface", errorResultObj.Message);
        }
Exemple #4
0
        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");
        }
Exemple #5
0
        public async Task ManualTRexTest_CreateImportedFile(string uriRoot)
        {
            const string testText = "File Import Misc 2";

            Msg.Title(testText, "Create standard project then upload a new design surface 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.TestDesignSurface3_GoodContent);
            var fullFilePath   = TestFileResolver.GetFullPath(importFilename);

            var importFileArray = new[] {
                "| EventType              | ProjectUid   | CustomerUid   | Name           | ImportedFileType | FileCreatedUtc  | FileUpdatedUtc              | ImportedBy                 | IsActivated | MinZoomLevel | MaxZoomLevel |",
                $"| ImportedFileDescriptor | {ts.ProjectUid} | {customerUid} | {fullFilePath} | 1                | {startDateTime} | {startDateTime.AddDays(5)}  | [email protected] | true        | 15           | 19           |"
            };
            var filesResult = await importFile.SendRequestToFileImportV6(ts, importFileArray, 1,
                                                                         new ImportOptions(HttpMethod.Post, new[] { "filename=TestDesignSurfaceTestDesignSurface3_GoodContent.TTM" }));

            Assert.NotNull(filesResult);
            Assert.Equal(0, filesResult.Code);
            Assert.Equal(ts.ProjectUid.ToString(), filesResult.ImportedFileDescriptor.ProjectUid);

            var trexService   = new TRex();
            var designsResult = await trexService.GetDesignsFromTrex(customerUid.ToString(), ts.ProjectUid.ToString());

            Assert.Equal(0, designsResult.Code);
            Assert.Single(designsResult.DesignFileDescriptors);
            Assert.Equal(filesResult.ImportedFileDescriptor.ImportedFileUid, designsResult.DesignFileDescriptors[0].DesignUid);
            Assert.Equal("TestDesignSurface3_GoodContent.TTM", designsResult.DesignFileDescriptors[0].Name);
        }
Exemple #6
0
        public async Task TestImportSvlFile(string uriRoot)
        {
            const string testText = "File Import align test 1";

            Msg.Title(testText, "Create standard project then upload svl 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           |"
            };

            var filesResult = await importFile.SendRequestToFileImportV6(ts, importFileArray, 1, new ImportOptions(HttpMethod.Post, new[] { $"filename={importFilename}" }));

            ts.CompareTheActualImportFileWithExpected(filesResult.ImportedFileDescriptor, importFile.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor, true);
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        public async Task Set_activation_should_handle_project_with_no_files()
        {
            const string testText = "File Activation test 3";

            Msg.Title(testText, "Set ImportFile::IsActivated with no loaded project files");
            var ts                    = new TestSupport();
            var customerUid           = Guid.NewGuid();
            var createProjectResponse = ExecutorTestFixture.CreateCustomerProject(customerUid.ToString(), testText, Boundaries.Boundary1);

            ts.ProjectUid = new Guid(createProjectResponse.Result.Id);

            await DoActivationRequest(customerUid, ts.ProjectUid.ToString(), "id", false, HttpStatusCode.OK, 400, "Project contains no imported files.");
        }
Exemple #9
0
        public async Task AddProjectSettingsThenUpdateThem()
        {
            const string testText = "Project settings test 4";

            Msg.Title(testText, "Add project settings for a project monitoring project");
            var ts                    = new TestSupport();
            var customerUid           = Guid.NewGuid();
            var createProjectResponse = ExecutorTestFixture.CreateCustomerProject(customerUid.ToString(), testText, Boundaries.Boundary1);

            ts.ProjectUid = new Guid(createProjectResponse.Result.Id);

            // Now create the settings
            var projectSettings = "{useMachineTargetPassCount: false,customTargetPassCountMinimum: 5}";

            projectSettings = projectSettings.Replace(" ", string.Empty);

            var projSettings = ProjectSettingsRequest.CreateProjectSettingsRequest(ts.ProjectUid.ToString(), projectSettings, ProjectSettingsType.Targets);
            var configJson   = JsonConvert.SerializeObject(projSettings, new JsonSerializerSettings {
                DateTimeZoneHandling = DateTimeZoneHandling.Unspecified
            });
            await ts.CallProjectWebApi("api/v4/projectsettings", HttpMethod.Put, configJson, customerUid.ToString());

            var projectSettings1 = "{customTargetPassCountMaximum: 7,useMachineTargetTemperature: false,customTargetTemperatureMinimum: 75}";

            projectSettings1 = projectSettings1.Replace(" ", string.Empty);

            var projSettings1 = ProjectSettingsRequest.CreateProjectSettingsRequest(ts.ProjectUid.ToString(), projectSettings1, ProjectSettingsType.Targets);
            var configJson2   = JsonConvert.SerializeObject(projSettings1, new JsonSerializerSettings {
                DateTimeZoneHandling = DateTimeZoneHandling.Unspecified
            });
            var response1 = await ts.CallProjectWebApi("api/v4/projectsettings", HttpMethod.Put, configJson2, customerUid.ToString());

            var objresp = JsonConvert.DeserializeObject <ProjectSettingsResult>(response1);

            var tempSettings = JsonConvert.SerializeObject(objresp.Settings).Replace("\"", string.Empty);

            Assert.Equal(projectSettings1, tempSettings);
            Assert.Equal(ts.ProjectUid.ToString(), objresp.ProjectUid);

            // get call
            var response2 = await ts.CallProjectWebApi($"api/v4/projectsettings/{ts.ProjectUid}", HttpMethod.Get, null, customerUid.ToString());

            var objresp1 = JsonConvert.DeserializeObject <ProjectSettingsResult>(response2);

            tempSettings = JsonConvert.SerializeObject(objresp1.Settings).Replace("\"", string.Empty);

            Assert.Equal(projectSettings1, tempSettings);
            Assert.Equal(ts.ProjectUid.ToString(), objresp1.ProjectUid);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        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");
        }
Exemple #12
0
        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);
        }
Exemple #13
0
        public async Task Set_activation_should_handle_no_eligible_files()
        {
            const string testText = "File Activation test 5";

            Msg.Title(testText, "Set ImportFile::IsActivated with no valid 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 importFilename = TestFileResolver.File(TestFile.TestAlignment2);

            await ImportFiles(ts, ts.ProjectUid, customerUid, startDateTime, TestFileResolver.GetFullPath(importFilename));

            await DoActivationRequest(customerUid, ts.ProjectUid.ToString(), "BAD_ID", false, HttpStatusCode.OK, 200, "Success");
        }
Exemple #14
0
        public async Task TestImportReferenceSurfaceFileFromDeactivatedDesign(string uriRoot1, string uriRoot2)
        {
            const string testText = "File Import ref test 2";

            Msg.Title(testText, "Create standard project and customer then upload reference surface 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 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 filesResult = await importFileParent.SendRequestToFileImportV6(ts, importFileArray, 1, new ImportOptions(HttpMethod.Post, new[] { $"filename={importFilename}" }));

            ts.CompareTheActualImportFileWithExpected(filesResult.ImportedFileDescriptor, importFileParent.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor, true);
            //Deactivate the parent design
            await FileActivationTests.DoActivationRequest(customerUid, ts.ProjectUid.ToString(), filesResult.ImportedFileDescriptor.ImportedFileUid, false, HttpStatusCode.OK, 200, "Success");

            //Reference Surface
            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)}" }));

            //Expect the reference surface to be deactivated
            importFileChild.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor.IsActivated = false;
            ts.CompareTheActualImportFileWithExpected(filesResult2.ImportedFileDescriptor, importFileChild.ExpectedImportFileDescriptorSingleResult.ImportedFileDescriptor, true);
        }
Exemple #15
0
        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);
        }
Exemple #16
0
        public async Task Set_activation_should_handle_empty_file_list()
        {
            const string testText = "File Activation test 4";

            Msg.Title(testText, "Set ImportFile::IsActivated with empty file list");
            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.TestAlignment1);
            var fullFilePath   = TestFileResolver.GetFullPath(importFilename);

            await ImportFiles(ts, ts.ProjectUid, customerUid, startDateTime, fullFilePath);

            await DoActivationRequest(customerUid, ts.ProjectUid.ToString(), null,
                                      false, HttpStatusCode.OK, 400, "Request contains no imported file IDs.");
        }
Exemple #17
0
        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);
        }
Exemple #18
0
        public async Task AddEmptyProjectSettings()
        {
            const string testText = "Project settings test 3";

            Msg.Title(testText, "Add project settings for a project monitoring project");
            var ts                    = new TestSupport();
            var customerUid           = Guid.NewGuid();
            var createProjectResponse = ExecutorTestFixture.CreateCustomerProject(customerUid.ToString(), testText, Boundaries.Boundary1);

            ts.ProjectUid = new Guid(createProjectResponse.Result.Id);

            // Now create the settings
            var projectSettings = string.Empty;
            var projSettings    = ProjectSettingsRequest.CreateProjectSettingsRequest(ts.ProjectUid.ToString(), projectSettings, ProjectSettingsType.Targets);
            var configJson      = JsonConvert.SerializeObject(projSettings, new JsonSerializerSettings {
                DateTimeZoneHandling = DateTimeZoneHandling.Unspecified
            });
            var response = await ts.CallProjectWebApi("api/v4/projectsettings", HttpMethod.Put, configJson, customerUid.ToString());

            var objresp = JsonConvert.DeserializeObject <ProjectSettingsResult>(response);

            var tempSettings = objresp.Settings == null ? string.Empty : JsonConvert.SerializeObject(objresp.Settings).Replace("\"", string.Empty);

            Assert.Equal(projectSettings, tempSettings);
            //Assert.Equal(ts.ProjectUid, objresp.projectUid);

            // get call
            var response1 = await ts.CallProjectWebApi($"api/v4/projectsettings/{ts.ProjectUid}", HttpMethod.Get, null, customerUid.ToString());

            var objresp1 = JsonConvert.DeserializeObject <ProjectSettingsResult>(response1);

            tempSettings = objresp1.Settings == null ? string.Empty : JsonConvert.SerializeObject(objresp1.Settings).Replace("\"", string.Empty);

            Assert.Equal(projectSettings, tempSettings);
            //Assert.Equal(ts.ProjectUid, objresp1.projectUid);
        }
Exemple #19
0
        public async Task AddProjectSettingsGoodPath()
        {
            const string testText = "Project settings test 1";

            Msg.Title(testText, "Add project settings for a standard project");
            var ts          = new TestSupport();
            var customerUid = Guid.NewGuid();
            var response    = ExecutorTestFixture.CreateCustomerProject(customerUid.ToString(), testText, Boundaries.Boundary1);

            ts.ProjectUid = new Guid(response.Result.Id);

            // Now create the settings
            var projectSettings1 = "{ useMachineTargetPassCount: false,customTargetPassCountMinimum: 5,customTargetPassCountMaximum: 7,useMachineTargetTemperature: false,customTargetTemperatureMinimum: 75," +
                                   "customTargetTemperatureMaximum: 150,useMachineTargetCmv: false,customTargetCmv: 77,useMachineTargetMdp: false,customTargetMdp: 88,useDefaultTargetRangeCmvPercent: false," +
                                   "customTargetCmvPercentMinimum: 75,customTargetCmvPercentMaximum: 105,useDefaultTargetRangeMdpPercent: false,customTargetMdpPercentMinimum: 85,customTargetMdpPercentMaximum: 115," +
                                   "useDefaultTargetRangeSpeed: false,customTargetSpeedMinimum: 10,customTargetSpeedMaximum: 30,useDefaultCutFillTolerances: false,customCutFillTolerances: [3, 2, 1, 0, -1, -2, -3]," +
                                   "useDefaultVolumeShrinkageBulking: false, customShrinkagePercent: 5, customBulkingPercent: 7.5}";

            projectSettings1 = projectSettings1.Replace(" ", string.Empty);

            var projSettings1 = ProjectSettingsRequest.CreateProjectSettingsRequest(ts.ProjectUid.ToString(), projectSettings1, ProjectSettingsType.Targets);
            var configJson1   = JsonConvert.SerializeObject(projSettings1, new JsonSerializerSettings {
                DateTimeZoneHandling = DateTimeZoneHandling.Unspecified
            });
            var putresponse1 = await ts.CallProjectWebApi("api/v4/projectsettings", HttpMethod.Put, configJson1, customerUid.ToString());

            var putobjresp1 = JsonConvert.DeserializeObject <ProjectSettingsResult>(putresponse1);

            var tempSettings = JsonConvert.SerializeObject(putobjresp1.Settings).Replace("\"", string.Empty);

            //Assert.Equal(projectSettings1, putobjresp1.settings, "Actual project settings 1 do not match expected");
            Assert.Equal(projectSettings1, tempSettings);
            Assert.Equal(ts.ProjectUid.ToString(), putobjresp1.ProjectUid);

            // create settings for a second user for same project
            var projectSettings2 = "{ useMachineTargetPassCount: false,customTargetPassCountMinimum: 6,customTargetPassCountMaximum: 6,useMachineTargetTemperature: false,customTargetTemperatureMinimum: 70," +
                                   "customTargetTemperatureMaximum: 140,useMachineTargetCmv: false,customTargetCmv: 71,useMachineTargetMdp: false,customTargetMdp: 81,useDefaultTargetRangeCmvPercent: false," +
                                   "customTargetCmvPercentMinimum: 80,customTargetCmvPercentMaximum: 100,useDefaultTargetRangeMdpPercent: false,customTargetMdpPercentMinimum: 80,customTargetMdpPercentMaximum: 100," +
                                   "useDefaultTargetRangeSpeed: false,customTargetSpeedMinimum: 12,customTargetSpeedMaximum: 27,useDefaultCutFillTolerances: false,customCutFillTolerances: [3, 2, 1, 0, -1, -2, -3]," +
                                   "useDefaultVolumeShrinkageBulking: false, customShrinkagePercent: 6, customBulkingPercent: 5.2}";

            projectSettings2 = projectSettings2.Replace(" ", string.Empty);

            var projSettings2 = ProjectSettingsRequest.CreateProjectSettingsRequest(ts.ProjectUid.ToString(), projectSettings2, ProjectSettingsType.Targets);
            var configJson2   = JsonConvert.SerializeObject(projSettings2, new JsonSerializerSettings {
                DateTimeZoneHandling = DateTimeZoneHandling.Unspecified
            });
            var putresponse2 = await ts.CallProjectWebApi("api/v4/projectsettings", HttpMethod.Put, configJson2, customerUid.ToString(), RestClient.ANOTHER_JWT);

            var putobjresp2 = JsonConvert.DeserializeObject <ProjectSettingsResult>(putresponse2);

            tempSettings = JsonConvert.SerializeObject(putobjresp2.Settings).Replace("\"", string.Empty);

            //Assert.Equal(projectSettings2, putobjresp2.setting);
            Assert.Equal(projectSettings2, tempSettings);
            Assert.Equal(ts.ProjectUid.ToString(), putobjresp2.ProjectUid);

            // get call
            var getresponse1 = await ts.CallProjectWebApi($"api/v4/projectsettings/{ts.ProjectUid}", HttpMethod.Get, null, customerUid.ToString());

            var getobjresp1 = JsonConvert.DeserializeObject <ProjectSettingsResult>(getresponse1);

            tempSettings = JsonConvert.SerializeObject(getobjresp1.Settings).Replace("\"", string.Empty);

            //Assert.Equal(projectSettings1, getobjresp1.settings);
            Assert.Equal(projectSettings1, tempSettings);
            Assert.Equal(ts.ProjectUid.ToString(), getobjresp1.ProjectUid);
        }