//[Fact] public void SearchComponentOnExchangeWithFilter() { ISIS.Web.IComponentLibrarySearchResult <VFComponent> searchResult; using (VFWebClient vfWebClient = new VFWebClient(this.fixture.credentials.Url, this.fixture.credentials)) { VFExchange exchange = new VFExchange(vfWebClient); Dictionary <string, ISIS.Web.ComponentLibraryFilterParameter> filterParams = new Dictionary <string, ISIS.Web.ComponentLibraryFilterParameter>(); string categoryToSearch = "Engine"; string filterName = "Power"; string minimumValue = "400"; // Create a new filter object var newParam = new ISIS.Web.ContinuousFilterParameter(filterName) { MinValue = minimumValue, }; filterParams[filterName] = newParam; var filter = new VFExchangeFilter() { Category = categoryToSearch, ParameterList = filterParams }; searchResult = exchange.Search(filter); Assert.Equal(1, searchResult.hits); } }
public void GetProfile() { using (VFWebClient webClient = new VFWebClient(this.fixture.credentials.Url, this.fixture.credentials)) { Assert.DoesNotThrow(() => { webClient.GetProfile(); }); } }
//[Fact] public void DownloadNonExistentComponentFromExchange() { string metaDirectory = META.VersionInfo.MetaPath; var componentToDownload = new ISIS.VehicleForge.VFComponent(); // Might make sense to randomly generate a component id and try it - 24 hex characters componentToDownload.zip_url = "/rest/exchange/components/aaaabbbbccccddddeeeeffff/zip"; using (VFWebClient vfWebClient = new VFWebClient(this.fixture.credentials.Url, this.fixture.credentials)) { VFExchange exchange = new VFExchange(vfWebClient); string newZipPath = exchange.DownloadComponent(componentToDownload, metaDirectory); Assert.Null(newZipPath); } }
public void SearchEmptyCategoryOnExchange() { ISIS.Web.IComponentLibrarySearchResult <VFComponent> searchResult; string categoryToSearch = ""; using (VFWebClient vfWebClient = new VFWebClient(this.fixture.credentials.Url, this.fixture.credentials)) { VFExchange exchange = new VFExchange(vfWebClient); var filter = new VFExchangeFilter() { Category = categoryToSearch, }; searchResult = exchange.Search(filter); Assert.Null(searchResult); } }
//[Fact] public void SearchComponentOnExchange() { ISIS.Web.IComponentLibrarySearchResult <VFComponent> searchResult; string categoryToSearch = "Engine"; using (VFWebClient vfWebClient = new VFWebClient(this.fixture.credentials.Url, this.fixture.credentials)) { VFExchange exchange = new VFExchange(vfWebClient); var filter = new VFExchangeFilter() { Category = categoryToSearch, StartPosition = 0, NumberOfResults = 10 }; searchResult = exchange.Search(filter); Assert.Equal(5, searchResult.hits); } }
//[Fact] public void DownloadComponentFromExchange() { string metaDirectory = META.VersionInfo.MetaPath; var componentToDownload = new ISIS.VehicleForge.VFComponent(); // https://testbench.vf.isis.vanderbilt.edu/rest/exchange/components/5282583bc51df0577fa0fd23 // Engine_Caterpillar_C9_280kW componentToDownload.zip_url = "/rest/exchange/components/5282583bc51df0577fa0fd23/zip"; using (VFWebClient vfWebClient = new VFWebClient(this.fixture.credentials.Url, this.fixture.credentials)) { VFExchange exchange = new VFExchange(vfWebClient); string newZipPath = exchange.DownloadComponent(componentToDownload, metaDirectory); Assert.NotNull(newZipPath); if (File.Exists(newZipPath)) { File.Delete(newZipPath); } } }
public List<MgaFCO> ShowAndSelectVFComponents(Dictionary<string, ComponentLibraryFilterParameter> filterParameters) { // VF List<MgaFCO> importedComponents = new List<MgaFCO>(); using (VFExchangeConfig config = new VFExchangeConfig()) { var dialogResult = config.ShowDialog(); if (dialogResult == DialogResult.OK) { Credentials credentials = config.Credentials; // FOR DEBUGGING. Should remove these two lines... // For testing only //if (System.IO.File.Exists("pass.txt")) //{ // string loginInfo = System.IO.File.ReadAllText("pass.txt"); // credentials.Url = loginInfo.Split(',').ElementAt(0); // credentials.Username = loginInfo.Split(',').ElementAt(1); // credentials.Password = loginInfo.Split(',').ElementAt(2); //} try { using (VFWebClient vfWebClient = new VFWebClient(credentials.Url, credentials)) { VFExchange exchange = new VFExchange(vfWebClient); // in the future, may also allow the user to define parameter ranges in a form? var filter = new VFExchangeFilter() { Category = Clm.GetComponentCategory(this.CyPhyComponent), NumberOfResults = 10, StartPosition = 0, ParameterList = filterParameters }; using (VFComponentExchangeForm vfComponentSelection = new VFComponentExchangeForm(exchange, filter, this.ZipDownloadDir)) { var dr = vfComponentSelection.ShowDialog(); if (dr == DialogResult.OK) { // import the component zip files from VFComponentDownloads importedComponents.AddRange(Clm.ImportComponentZips(this.CyPhyComponent.Project, vfComponentSelection.DownloadedComponentZips)); } } } } catch (VFException ex) { string message = string.Format("{0}{1}{2}", ex.Message, Environment.NewLine, ex.GetType()); MessageBox.Show(message); } } } return importedComponents; }
public List <MgaFCO> ShowAndSelectVFComponents(Dictionary <string, ComponentLibraryFilterParameter> filterParameters) { // VF List <MgaFCO> importedComponents = new List <MgaFCO>(); using (VFExchangeConfig config = new VFExchangeConfig()) { var dialogResult = config.ShowDialog(); if (dialogResult == DialogResult.OK) { Credentials credentials = config.Credentials; // FOR DEBUGGING. Should remove these two lines... // For testing only //if (System.IO.File.Exists("pass.txt")) //{ // string loginInfo = System.IO.File.ReadAllText("pass.txt"); // credentials.Url = loginInfo.Split(',').ElementAt(0); // credentials.Username = loginInfo.Split(',').ElementAt(1); // credentials.Password = loginInfo.Split(',').ElementAt(2); //} try { using (VFWebClient vfWebClient = new VFWebClient(credentials.Url, credentials)) { VFExchange exchange = new VFExchange(vfWebClient); // in the future, may also allow the user to define parameter ranges in a form? var filter = new VFExchangeFilter() { Category = Clm.GetComponentCategory(this.CyPhyComponent), NumberOfResults = 10, StartPosition = 0, ParameterList = filterParameters }; using (VFComponentExchangeForm vfComponentSelection = new VFComponentExchangeForm(exchange, filter, this.ZipDownloadDir)) { var dr = vfComponentSelection.ShowDialog(); if (dr == DialogResult.OK) { // import the component zip files from VFComponentDownloads importedComponents.AddRange(Clm.ImportComponentZips(this.CyPhyComponent.Project, vfComponentSelection.DownloadedComponentZips)); } } } } catch (VFException ex) { string message = string.Format("{0}{1}{2}", ex.Message, Environment.NewLine, ex.GetType()); MessageBox.Show(message); } } } return(importedComponents); }