Beispiel #1
0
 public void NominalTest()
 {
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Repeat(5, 10),
         FastLinq.Repeat(5, 10),
         4);
 }
Beispiel #2
0
 public void RepeatNull()
 {
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Repeat <object>(null, 3),
         FastLinq.Repeat <object>(null, 3),
         1);
 }
Beispiel #3
0
 public void Empty()
 {
     EnsureResultOrExceptionSame(
         new int[] { },
         arr => Enumerable.Reverse(arr),
         arr => FastLinq.Reverse(arr));
 }
Beispiel #4
0
 public void Nominal()
 {
     EnsureResultOrExceptionSame(
         new int[] { 1, 2, 3 },
         arr => Enumerable.Reverse(arr),
         arr => FastLinq.Reverse(arr));
 }
Beispiel #5
0
 public void Null()
 {
     EnsureResultOrExceptionSame(
         (int[])null,
         arr => Enumerable.Reverse(arr),
         arr => FastLinq.Reverse(arr));
 }
Beispiel #6
0
 public void IntMin()
 {
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Range(int.MinValue, 10),
         FastLinq.Range(int.MinValue, 10),
         4);
 }
Beispiel #7
0
 public void IntMaxCountTwo()
 {
     new Action(
         () => FastLinq.Range(int.MaxValue, 2))
     .Should()
     .Throw <ArgumentOutOfRangeException>();
 }
Beispiel #8
0
 public void RepeatNone()
 {
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Repeat(5, 0),
         FastLinq.Repeat(5, 0),
         1);
 }
Beispiel #9
0
 public void Objects()
 {
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Empty <object>(),
         FastLinq.Empty <object>(),
         1);
 }
Beispiel #10
0
 public void IntMaxCountOne()
 {
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Range(int.MaxValue, 1),
         FastLinq.Range(int.MaxValue, 1),
         1);
 }
 public void FastLinq_SecondToLastItemCollection()
 {
     char _ = Enumerable.FirstOrDefault(
         FastLinq.Skip(
             FastLinq.Reverse(this.allLetters),
             1));
 }
Beispiel #12
0
                public void NotDuplicateBecauseOfComparer()
                {
                    ICollection <int>  source      = new[] { 1, 2, 3 };
                    Func <int, string> keySelector = i =>
                    {
                        switch (i)
                        {
                        case 1:
                            return("a");

                        case 2:
                            // Not duplicate, because we consider the case
                            return("A");

                        case 3:
                            return("c");

                        default:
                            throw new Exception();
                        }
                    };

                    var result = FastLinq.ToDictionary(source.AsReadOnly(), keySelector, StringComparer.Ordinal);

                    Assert.AreEqual(source.Count, result.Count);
                    CollectionAssert.AreEqual(
                        new[]
                    {
                        new KeyValuePair <string, int>("a", 1),
                        new KeyValuePair <string, int>("A", 2),
                        new KeyValuePair <string, int>("c", 3),
                    },
                        result);
                }
Beispiel #13
0
 public void TwoCountIntMax()
 {
     new Action(
         () => FastLinq.Range(2, int.MaxValue))
     .Should()
     .Throw <ArgumentOutOfRangeException>();
 }
 public void FastLinq_SecondToLastItemArray()
 {
     int _ = FastLinq.FirstOrDefault(
         FastLinq.Skip(
             FastLinq.Reverse(this.intArray),
             1));
 }
 public void FastLinq_Paginate_ToList()
 {
     List <string> _ = FastLinq.ToList(
         FastLinq.Take(
             FastLinq.Skip(this.stringList, 30),
             10));
 }
 public void FastLinq_LastTen_Lazy()
 {
     IReadOnlyList <int> _ = FastLinq.Reverse(
         FastLinq.Take(
             FastLinq.Reverse(this.intArray),
             10));
 }
Beispiel #17
0
 public void NominalTest()
 {
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Empty <int>(),
         FastLinq.Empty <int>(),
         1);
 }
Beispiel #18
0
 public void CountNegative()
 {
     new Action(
         () => FastLinq.Repeat(0, -100))
     .Should()
     .Throw <ArgumentOutOfRangeException>();
 }
Beispiel #19
0
                public void DuplicateKeysIfComparerHonored()
                {
                    ICollection <int>  source      = new[] { 1, 2, 3 };
                    Func <int, string> keySelector = i =>
                    {
                        switch (i)
                        {
                        case 1:
                            return("a");

                        case 2:
                            // Duplicate, if we ignore the case
                            return("A");

                        case 3:
                            return("c");

                        default:
                            throw new Exception();
                        }
                    };
                    Func <int, int> valueSelector = i => i * 2;

                    new Action(
                        () => FastLinq.ToDictionary(source.AsReadOnly(), keySelector, valueSelector, StringComparer.OrdinalIgnoreCase))
                    .Should()
                    .Throw <ArgumentException>()
                    .WithMessage("An item with the same key has already been added.");
                }
Beispiel #20
0
 public void CountIntMax()
 {
     // Cannot use ListCompare due to memory constraints (in x86 at least)
     new Action(
         () => FastLinq.Repeat(2, int.MaxValue))
     .Should()
     .NotThrow();
 }
Beispiel #21
0
        public void NullInput()
        {
            IList list = null;

            new Action(
                () => FastLinq.Cast <string>(list))
            .Should()
            .Throw <ArgumentNullException>();
        }
Beispiel #22
0
        public void Null()
        {
            IReadOnlyList <int> input = null;

            new Action(
                () => FastLinq.Reverse(input))
            .Should()
            .Throw <ArgumentNullException>();
        }
Beispiel #23
0
        public void MoreThanOne()
        {
            IReadOnlyList <int> list = new[] { 1, 2, 3 };

            new Action(
                () => FastLinq.SingleOrDefault(list))
            .Should()
            .Throw <InvalidOperationException>();
        }
Beispiel #24
0
 public void Nominal()
 {
     int[] list = new[] { 1, 2, 3 };
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Cast <object>(list),
         FastLinq.Cast <object>(list),
         itemNotInTheCollection: null,
         enforceWritable: false);
 }
Beispiel #25
0
        public void InputNull()
        {
            IReadOnlyList <int> list = null;

            new Action(
                () => FastLinq.Last(list))
            .Should()
            .Throw <ArgumentNullException>();
        }
Beispiel #26
0
        public void NullInput()
        {
            IReadOnlyCollection <int> input = null;

            new Action(
                () => FastLinq.ToList(input))
            .Should()
            .Throw <ArgumentNullException>();
        }
Beispiel #27
0
                public void EmptySource()
                {
                    ICollection <int>  source      = new int[] { };
                    Func <int, string> keySelector = i => i.ToString();

                    var result = FastLinq.ToDictionary(source.AsReadOnly(), keySelector, StringComparer.Ordinal);

                    Assert.AreEqual(0, result.Count);
                }
        public void InputEmpty()
        {
            IReadOnlyList <int> list = new int[] { };

            new Action(
                () => FastLinq.ElementAt(list, 0))
            .Should()
            .Throw <ArgumentOutOfRangeException>();
        }
Beispiel #29
0
        public void InputEmpty()
        {
            IReadOnlyList <int> list = new int[] { };

            new Action(
                () => FastLinq.Last(list))
            .Should()
            .Throw <InvalidOperationException>();
        }
Beispiel #30
0
        public void NullInput2()
        {
            IReadOnlyList <int> list = null;

            new Action(
                () => FastLinq.Cast <int, object>(list))
            .Should()
            .Throw <ArgumentNullException>();
        }