예제 #1
0
 private static void displayDifference(TextMessageWriter writer, KeyValuePair <string, Pair> difference)
 {
     writer.Write("\t");
     writer.Write(difference.Key);
     writer.Write(" --> ");
     writer.Write("globalization: ");
     writer.WriteExpectedValue(difference.Value.First);
     writer.Write("\t");
     writer.Write("configuration: ");
     writer.WriteActualValue(difference.Value.Second);
     writer.WriteLine();
 }
예제 #2
0
        private void displayCultureInformation(TextMessageWriter writer, CultureCurrencyInfo fromGlobalization, CurrencyInfo fromConfiguration)
        {
            CanonicalCultureAttribute attr;
            CultureInfo configurationCulture = null;

            if (Enumeration.TryGetAttribute(fromConfiguration.Code, out attr))
            {
                configurationCulture = attr.Culture();
            }
            writer.Write("Globalizaton Currency {0} for culture {1} [{2}] ", fromGlobalization.Info.Code, fromGlobalization.Culture.Name, fromGlobalization.Culture.EnglishName);
            writer.WriteLine("differs from Configuration Currency {0}", fromConfiguration.Code);
            writer.WriteMessageLine(1, "Canonical Culture {0}, {1}",
                                    configurationCulture != null ? configurationCulture.Name : "NONE",
                                    configurationCulture != null ? attr.Overwritten.ToString() : "NA");
        }
예제 #3
0
        /// <summary>
        /// Handles an Ensurance failure for the given constraint. Implementors
        /// should always call
        /// <code>
        /// IEnsuranceResponsibilityChainLink handler = successor;
        /// if( handler != null ) {
        ///     handler.Handle( constraint, message, args );
        /// }
        /// </code>
        /// So that the downstream handler can have a chance to process the
        /// failure.
        /// </summary>
        /// <param name="constraint">The constraint.</param>
        /// <param name="message">The message.</param>
        /// <param name="args">The args.</param>
        public void Handle(Constraint constraint, string message, params object[] args)
        {
            try
            {
                MessageWriter messagewriter = new TextMessageWriter();
                messagewriter.WriteLine();
                constraint.WriteMessageTo(messagewriter);
                messagewriter.Write(new StackTraceWriter().ToString());

                string tmpMessage = String.Format(CultureInfo.CurrentCulture, "{0}{1}", message, messagewriter);

                switch (_logger.DefaultLogSeverity)
                {
                case LogSeverity.Debug:
                    _logger.Debug(tmpMessage, args);
                    break;

                case LogSeverity.Info:
                    _logger.Info(tmpMessage, args);
                    break;

                case LogSeverity.Warn:
                    _logger.Warn(tmpMessage, args);
                    break;

                case LogSeverity.Error:
                    _logger.Error(tmpMessage, args);
                    break;

                case LogSeverity.Fatal:
                    _logger.Fatal(tmpMessage, args);
                    break;
                }
            }
            finally
            {
                IEnsuranceResponsibilityChainLink handler = _successor;
                if (handler != null)
                {
                    handler.Handle(constraint, message, args);
                }
            }
        }
예제 #4
0
파일: Assert.cs 프로젝트: textmetal/main
        /// <summary>
        /// Wraps code containing a series of assertions, which should all
        /// be executed, even if they fail. Failed results are saved and
        /// reported at the end of the code block.
        /// </summary>
        /// <param name="testDelegate">A TestDelegate to be executed in Multiple Assertion mode.</param>
        public static void Multiple(TestDelegate testDelegate)
        {
            TestExecutionContext context = TestExecutionContext.CurrentContext;
            Guard.OperationValid(context != null, "Assert.Multiple called outside of a valid TestExecutionContext");

            context.MultipleAssertLevel++;

            try
            {
                testDelegate();
            }
            finally
            {
                context.MultipleAssertLevel--;
            }

            if (context.MultipleAssertLevel == 0)
            {
                int count = context.CurrentResult.AssertionResults.Count;

                if (count > 0)
                {
                    var writer = new TextMessageWriter("Multiple Assert block had {0} failure(s).", count);

                    int counter = 0;
                    foreach (var assertion in context.CurrentResult.AssertionResults)
                        writer.WriteLine(string.Format("  {0}) {1}", ++counter, assertion.Message));

                    throw new AssertionException(writer.ToString());
                }
            }
        }