Пример #1
0
    public void ExAllTest()
    {
        var sss = "aaskjfhkaehff".Select(c => Tuple.Create(c)).ToList();

        foreach (var c in sss)
        {
            if (char.IsWhiteSpace(c.Item1))
            {
                throw new Exception();
            }
        }

        Assert.True("".All());
        Assert.True("".All(c => true, true));
        Assert.True("".All(c => true, false));

        var e = new EnumerableThrowsInvalidOperationException();

        Assert.False(e.All(true));
        Assert.False(e.All(c => true, true));
        Assert.Throws <InvalidOperationException>(() => e.All());
        Assert.Throws <InvalidOperationException>(() => e.All());
        Assert.Throws <InvalidOperationException>(() => e.All(false));
        Assert.Throws <InvalidOperationException>(() => e.All(c => true));
        Assert.Throws <InvalidOperationException>(() => e.All(c => true, false));
    }
Пример #2
0
    public void ExAnyTest()
    {
        Assert.False("".Any());
        Assert.False("".Any(c => true, true));
        Assert.False("".Any(c => true, false));

        IEnumerable <char> e = new EnumerableThrowsInvalidOperationException();

        Assert.True(e.Any(true));
        Assert.True(e.Any(c => true, true));

        e = new EnumerableThrowsInvalidOperationException0();

        Assert.False(e.Any(true));
        Assert.False(e.Any(c => true, true));
        Assert.Throws <InvalidOperationException>(() => e.Any());
        Assert.Throws <InvalidOperationException>(() => e.Any(false));
        Assert.Throws <InvalidOperationException>(() => e.Any(c => true));
        Assert.Throws <InvalidOperationException>(() => e.Any(c => true, false));
    }