private void Deserialize() { string path = ConfigurationManager.AppSettings["connectionstring"]; if (ConfigurationManager.AppSettings["repository"] != "Database") { path = browse.GetFilePath(); } BaseTreeViewItem rootItem = new AssemblyTreeViewItem(RepositoryOperations.Read(path)); HierarchicalAreas.Clear(); HierarchicalAreas.Add(rootItem); }
public void VerifyStatusCodeForAlreadyCreatedRepos() { //Arrange string alreadyCreateRepoName = "Dummy1"; string userName = GitConfigurations.Default.username; var bodyForRepositoryCreation = DataHelper.PopulateJsonDataForNewPublicRepository(alreadyCreateRepoName, "This is for testing purpose"); var repositoryOptions = new RepositoryOperations(); //Act var responseFromServer = repositoryOptions.CreateNewRepository(userName, GitConfigurations.Default.password, bodyForRepositoryCreation); //Assert Assert.AreEqual(HttpStatusCode.UnprocessableEntity, responseFromServer.StatusCode); }
public void StarringRepoWhichIsNotPresent() { //Arrange string repoToBeStarredButNotInRepo = "Dummy10"; string userName = GitConfigurations.Default.username; var repositoryOptions = new RepositoryOperations(); //Act var responseFromServer = repositoryOptions.StarringRepository(userName, GitConfigurations.Default.password, repoToBeStarredButNotInRepo); //Assert Assert.AreEqual(HttpStatusCode.NotFound, responseFromServer.StatusCode); //Getting all the starred repos var allStarredRepos = repositoryOptions.GetStarredRepository(userName, GitConfigurations.Default.password); //Asserting the repo which is not starred is not in the list of all starred repos Assert.IsFalse(allStarredRepos.Result.Exists(e => e.name == repoToBeStarredButNotInRepo)); }
public void StarringAndVerifyingRepository() { //Arrange string repoToBeStarred = "Dummy1"; string userName = GitConfigurations.Default.username; var repositoryOptions = new RepositoryOperations(); //Act var responseFromServer = repositoryOptions.StarringRepository(userName, GitConfigurations.Default.password, repoToBeStarred); //Assert Assert.AreEqual(HttpStatusCode.NoContent, responseFromServer.StatusCode); //Getting all the starred repos var allStarredRepos = repositoryOptions.GetStarredRepository(userName, GitConfigurations.Default.password); //Verify the starred repos is in the list of all starred repos Assert.IsTrue(allStarredRepos.Result.Exists(e => e.name == repoToBeStarred)); //Asserting the repo which is not starred is not in the list of all starred repos Assert.IsFalse(allStarredRepos.Result.Exists(e => e.name == "Hello1")); }
private void GenericCreate(Func <TestRepository, IDbCommand, int> custom, RepositoryOperations options) { TestRepository proxy; IDbConnection connection; IDbCommand command; InitializeProxy(out proxy, out connection, out command); proxy.Operations = options; int called = custom(proxy, command); DefaultAsserts(connection, command, called); if (options.HasFlag(RepositoryOperations.CacheExtendedDatabaseInformation)) { Assert.IsTrue(proxy.ExtendedInformationCacheSize > 0); } else { Assert.AreEqual(0, proxy.ExtendedInformationCacheSize); } proxy.Dispose(); if (options.HasFlag(RepositoryOperations.CacheExtendedDatabaseInformation)) { Assert.AreEqual(0, proxy.ExtendedInformationCacheSize); } if (proxy.Operations.HasFlag(RepositoryOperations.LogQueryExecutionTime)) { Console.WriteLine($"Query Execution Time: {proxy.QueryExecutionTime}"); } if (proxy.Operations.HasFlag(RepositoryOperations.LogTotalExecutionTime)) { Console.WriteLine($"Total Execution Time: {proxy.TotalExecutionTime}"); } }
/// <summary> /// Constructor. Note that you should dispose the instance when you're finished with it. /// </summary> /// <param name="addressOrFQDN">The target XenServer IP address or FQDN.</param> /// <param name="username">The user name.</param> /// <param name="password">The password.</param> /// <param name="name">Optionally specifies the XenServer name.</param> /// <param name="logFolder"> /// The folder where log files are to be written, otherwise or <c>null</c> or /// empty if logging is disabled. /// </param> public XenClient(string addressOrFQDN, string username, string password, string name = null, string logFolder = null) { Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(username)); if (!IPAddress.TryParse(addressOrFQDN, out var address)) { var hostEntry = Dns.GetHostEntry(addressOrFQDN); if (hostEntry.AddressList.Length == 0) { throw new XenException($"[{addressOrFQDN}] is not a valid IP address or fully qualified domain name of a XenServer host."); } address = hostEntry.AddressList.First(); } var logWriter = (TextWriter)null; if (!string.IsNullOrEmpty(logFolder)) { Directory.CreateDirectory(logFolder); logWriter = new StreamWriter(Path.Combine(logFolder, $"XENSERVER-{addressOrFQDN}.log")); } Address = addressOrFQDN; Name = name; SshProxy = new SshProxy <XenClient>(addressOrFQDN, null, address, SshCredentials.FromUserPassword(username, password), logWriter); SshProxy.Metadata = this; runOptions = RunOptions.IgnoreRemotePath; // Initialize the operation classes. Repository = new RepositoryOperations(this); Template = new TemplateOperations(this); Machine = new MachineOperations(this); }
public void CreateAndVerifyRepository() { //Arrange string expectedRepoName = "Dummy3"; string userName = GitConfigurations.Default.username; var bodyDataForCreatingNewRepo = DataHelper.PopulateJsonDataForNewPublicRepository(expectedRepoName, "This is for dummy operation"); var repositoryOperations = new RepositoryOperations(); //Act var responseFromServer = repositoryOperations.CreateNewRepository(userName, GitConfigurations.Default.password, bodyDataForCreatingNewRepo); //Assert int idFromCreatedRemo = responseFromServer.Result.id; string nameFromCreatedRepo = responseFromServer.Result.name; Assert.AreEqual(responseFromServer.StatusCode, HttpStatusCode.Created); Assert.AreEqual(nameFromCreatedRepo, expectedRepoName); //GetAllReposFromServer var allReposFromServer = repositoryOperations.GetRepositoryForUser(userName, GitConfigurations.Default.PersonalToken); //Verifing the id of the created repostiory in GetAllRepos Collection Assert.Equals(allReposFromServer.Result.Single(e => e.id == idFromCreatedRemo).id, idFromCreatedRemo); }
/// <summary>Processes an invocation on a target.</summary> /// <param name="target">The target object.</param> /// <param name="methodInfo">The method information.</param> /// <param name="parameters">The parameter values.</param> /// <returns>The return value.</returns> public object Invoke(object target, MethodInfo methodInfo, object[] parameters) { Object result = null; if (methodInfo.Name == nameof(IRepository.Dispose)) { _cache.Clear(); _connection?.Dispose(); _connection = null; } else if (methodInfo.Name == $"set_{nameof(IRepository.ConnectionStringSettings)}") { string newSetting = parameters[0].ToString(); if (newSetting != _connectionStringSettings) { _connection?.Dispose(); _connection = null; _settings = null; _connectionStringSettings = newSetting; } } else if (methodInfo.Name == $"get_{nameof(IRepository.ConnectionStringSettings)}") { result = _connectionStringSettings; } else if (methodInfo.Name == $"set_{nameof(IRepository.Connection)}") { _connection = parameters[0] as IDbConnection; } else if (methodInfo.Name == $"get_{nameof(IRepository.Connection)}") { result = Connection; } else if (methodInfo.Name == $"set_{nameof(IRepository.TvpNameConvension)}") { _tvpNameConvention = parameters[0].ToString(); } else if (methodInfo.Name == $"get_{nameof(IRepository.TvpNameConvension)}") { result = _tvpNameConvention; } else if (methodInfo.Name == $"get_{nameof(IRepository.QueryExecutionTime)}") { result = _queryTime?.Elapsed; } else if (methodInfo.Name == $"get_{nameof(IRepository.TotalExecutionTime)}") { result = _totalTime?.Elapsed; } else if (methodInfo.Name == $"set_{nameof(IRepository.Operations)}") { _operations = (RepositoryOperations)parameters[0]; InitWatches(); } else if (methodInfo.Name == $"get_{nameof(IRepository.Operations)}") { result = _operations; } else if (methodInfo.Name == $"get_{nameof(IRepository.ExtendedInformationCacheSize)}") { result = _cache.Count; } else { InitWatches(); _totalTime?.Reset(); _queryTime?.Reset(); _totalTime?.Start(); try { var transit = new TransitObject { ExtendedInformations = GetExtendedInformation(methodInfo) }; PrepareInitialization(transit, methodInfo, parameters); var connection = Connection; using (var command = connection.CreateCommand()) { command.Connection = connection; Execute(transit, command); } // write output parameters foreach (var item in transit.Outputs) { parameters[item.Key.Position] = item.Value.Value; } foreach (var item in transit.Refernces) { item.WriteBack(parameters); } result = transit.ReturnObject; } catch when(ExceptionFilter()) { } _totalTime?.Stop(); } return(result); }