void RunSpecificationAssembly(string fileName, ISpecificationRunner runner) { Ensure.ArgumentIsNotNullOrEmptyString(fileName, "fileName"); try { string originalWorkingDirectory = Environment.CurrentDirectory; try { Environment.CurrentDirectory = WorkingDirectory.FullName; Log(Level.Info, "Loading assembly {0}", fileName); Assembly assembly = Assembly.LoadFrom(fileName); runner.RunAssembly(assembly); } finally { Environment.CurrentDirectory = originalWorkingDirectory; } } catch (Exception ex) { throw new BuildException("Unexpected error while running specs", ex); } }
public Credentials(string token) { Ensure.ArgumentIsNotNullOrEmptyString(token, "token"); Login = null; Password = token; AuthenticationType = AuthenticationType.Oauth; }
/// <summary> /// Performs an asynchronous HTTP POST request. /// Attempts to map the response body to an object of type <typeparamref name="T"/> /// </summary> /// <typeparam name="T">The type to map the response to</typeparam> /// <param name="uri">URI endpoint to send request to</param> /// <param name="body">The object to serialize as the body of the request</param> /// <param name="accepts">Specifies accepted response media types.</param> /// <param name="contentType">Specifies the media type of the request body</param> /// <param name="twoFactorAuthenticationCode">Two Factor Authentication Code</param> /// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns> public Task <IApiResponse <T> > Post <T>(Uri uri, object body, string accepts, string contentType, string twoFactorAuthenticationCode) { Ensure.ArgumentIsNotNull(uri, "uri"); Ensure.ArgumentIsNotNull(body, "body"); Ensure.ArgumentIsNotNullOrEmptyString(twoFactorAuthenticationCode, "twoFactorAuthenticationCode"); return(SendData <T>(uri, HttpMethod.Post, body, accepts, contentType, CancellationToken.None, twoFactorAuthenticationCode)); }
public Credentials(string login, string password) { Ensure.ArgumentIsNotNullOrEmptyString(login, "login"); Ensure.ArgumentIsNotNullOrEmptyString(password, "password"); Login = login; Password = password; AuthenticationType = AuthenticationType.Basic; }
/// <summary> /// Creates or replaces the API resource at the specified URI. /// </summary> /// <typeparam name="T">The API resource's type.</typeparam> /// <param name="uri">URI of the API resource to create or replace</param> /// <param name="data">Object that describes the API resource; this will be serialized and used as the request's body</param> /// <param name="twoFactorAuthenticationCode">The two-factor authentication code in response to the current user's previous challenge</param> /// <returns>The created API resource.</returns> /// <exception cref="ApiException">Thrown when an API error occurs.</exception> public async Task <T> Put <T>(Uri uri, object data, string twoFactorAuthenticationCode) { Ensure.ArgumentIsNotNull(uri, "uri"); Ensure.ArgumentIsNotNull(data, "data"); Ensure.ArgumentIsNotNullOrEmptyString(twoFactorAuthenticationCode, "twoFactorAuthenticationCode"); var response = await Connection.Put <T>(uri, data, twoFactorAuthenticationCode).ConfigureAwait(false); return(response.Body); }
bool RunTestAssembly(string fileName, ReportResult reportResult) { Ensure.ArgumentIsNotNullOrEmptyString(fileName, "fileName"); string[] assemblyNames = new[] { fileName }; string[] dirNames = null; if (AssemblyPaths != null) { dirNames = new string[AssemblyPaths.DirectoryNames.Count]; AssemblyPaths.DirectoryNames.CopyTo(dirNames, 0); } try { Log(Level.Info, "Loading assembly {0}", fileName); using ( TestDomainDependencyGraph graph = TestDomainDependencyGraph.BuildGraph(assemblyNames, dirNames, CreateFilter(), Verbose)) { graph.Log += TestRunInfo_Log; string originalWorkingDirectory = Environment.CurrentDirectory; try { Environment.CurrentDirectory = WorkingDirectory.FullName; ReportResult runResult = graph.RunTests(); Log(Level.Info, "Finished running tests"); Log(Level.Info, "Merging results"); reportResult.Merge(runResult); UpdateNAntProperties(Properties, runResult); return(runResult.Counter.FailureCount == 0); } finally { Environment.CurrentDirectory = originalWorkingDirectory; graph.Log -= TestRunInfo_Log; } } } catch (Exception ex) { throw new BuildException("Unexpected error while running tests", ex); } }
static IEnumerable <string> SplitUpperCase(this string source) { Ensure.ArgumentIsNotNullOrEmptyString(source, "source"); int wordStartIndex = 0; var letters = source.ToCharArray(); var previousChar = char.MinValue; // Skip the first letter. we don't care what case it is. for (int i = 1; i < letters.Length; i++) { if (char.IsUpper(letters[i]) && !char.IsWhiteSpace(previousChar)) { //Grab everything before the current character. yield return(new string(letters, wordStartIndex, i - wordStartIndex)); wordStartIndex = i; } previousChar = letters[i]; } //We need to have the last word. yield return(new string(letters, wordStartIndex, letters.Length - wordStartIndex)); }
// Or Snake Case public static string ToRubyCase(this string propertyName) { Ensure.ArgumentIsNotNullOrEmptyString(propertyName, "s"); return(string.Join("_", propertyName.SplitUpperCase()).ToLowerInvariant()); }
public static Uri FormatUri(this string pattern, params object[] args) { Ensure.ArgumentIsNotNullOrEmptyString(pattern, "pattern"); return(new Uri(string.Format(CultureInfo.InvariantCulture, pattern, args), UriKind.Relative)); }