private bool IsMatch( string expectedResourceKey, string actualMessage, bool isExactMatch, object[] stringParameters, out string messageFromResources) { ExceptionHelpers.CheckStringArgumentIsNotNullOrEmpty(expectedResourceKey, "expectedResourceKey"); ExceptionHelpers.CheckArgumentNotNull(actualMessage, "actualMessage"); messageFromResources = _lookup.LookupString(expectedResourceKey); if (stringParameters.Length == 0) { return(IsMatchWithAnyPlaceholderValues(messageFromResources, actualMessage, isExactMatch)); } else { Assert.True(stringParameters.Count(p => p is AnyValueParameter) <= 1, "Only one 'AnyValueParameter' allowed."); messageFromResources = string.Format(CultureInfo.CurrentCulture, messageFromResources, stringParameters); var anyValueParameter = stringParameters.OfType <AnyValueParameter>().SingleOrDefault(); if (anyValueParameter != null) { var parts = messageFromResources.Split(new[] { anyValueParameter.ToString() }, StringSplitOptions.None); Assert.Equal(2, parts.Length); return(parts.Length == 2 && actualMessage.StartsWith(parts[0]) && actualMessage.EndsWith(parts[1])); } return(isExactMatch ? actualMessage == messageFromResources : actualMessage.Contains(messageFromResources)); } }
private bool IsMatch( string expectedResourceKey, string actualMessage, bool isExactMatch, object[] stringParameters, out string messageFromResources) { ExceptionHelpers.CheckStringArgumentIsNotNullOrEmpty(expectedResourceKey, "expectedResourceKey"); ExceptionHelpers.CheckArgumentNotNull(actualMessage, "actualMessage"); messageFromResources = _lookup.LookupString(expectedResourceKey); if (stringParameters.Length == 0) { return(IsMatchWithAnyPlaceholderValues(messageFromResources, actualMessage, isExactMatch)); } else { messageFromResources = string.Format(CultureInfo.InvariantCulture, messageFromResources, stringParameters); return(isExactMatch ? actualMessage == messageFromResources : actualMessage.Contains(messageFromResources)); } }