/// <summary> /// Writes the value of the expected object. /// </summary> public string WriteExpected() { MessageWriter writer = new TextMessageWriter(); if (Actual is IUnexpectedElement) { writer.Write("nothing"); } else { writer.WriteValue(Expected); } return(writer.ToString()); }
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"); }
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(); }
/// <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); } } }