コード例 #1
0
        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);
            }
        }
コード例 #2
0
        public Credentials(string token)
        {
            Ensure.ArgumentIsNotNullOrEmptyString(token, "token");

            Login              = null;
            Password           = token;
            AuthenticationType = AuthenticationType.Oauth;
        }
コード例 #3
0
        /// <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));
        }
コード例 #4
0
        public Credentials(string login, string password)
        {
            Ensure.ArgumentIsNotNullOrEmptyString(login, "login");
            Ensure.ArgumentIsNotNullOrEmptyString(password, "password");

            Login              = login;
            Password           = password;
            AuthenticationType = AuthenticationType.Basic;
        }
コード例 #5
0
ファイル: ApiConnection.cs プロジェクト: artfuldev/Tookan.NET
        /// <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);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        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));
        }
コード例 #8
0
 // Or Snake Case
 public static string ToRubyCase(this string propertyName)
 {
     Ensure.ArgumentIsNotNullOrEmptyString(propertyName, "s");
     return(string.Join("_", propertyName.SplitUpperCase()).ToLowerInvariant());
 }
コード例 #9
0
        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));
        }