Вот источник Enumerable.Any
(Assert.False()
только подтверждает, что возвращается false
.):
public static bool Any<TSource>(this IEnumerable<TSource> source) {
if (source == null) throw Error.ArgumentNull("source");
using (IEnumerator<TSource> e = source.GetEnumerator()) {
if (e.MoveNext()) return true;
}
return false;
}
Вот источник Assert.Empty
от xUnit:
public static void Empty(IEnumerable collection)
{
Assert.GuardArgumentNotNull("collection", collection);
var enumerator = collection.GetEnumerator();
try
{
if (enumerator.MoveNext())
throw new EmptyException(collection);
}
finally
{
(enumerator as IDisposable)?.Dispose();
}
}
Кажется, они используют очень похожий способ проверки наличия предметов в коллекции.Я ожидаю того же результата от каждого метода.
Без подробностей о том, как вы используете каждый из них, трудно сказать, почему вы получаете разные результаты.