Esempio n. 1
0
 public void NominalTest()
 {
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Repeat(5, 10),
         FastLinq.Repeat(5, 10),
         4);
 }
Esempio n. 2
0
 public void RepeatNull()
 {
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Repeat <object>(null, 3),
         FastLinq.Repeat <object>(null, 3),
         1);
 }
Esempio n. 3
0
 public void Empty()
 {
     EnsureResultOrExceptionSame(
         new int[] { },
         arr => Enumerable.Reverse(arr),
         arr => FastLinq.Reverse(arr));
 }
Esempio n. 4
0
 public void Nominal()
 {
     EnsureResultOrExceptionSame(
         new int[] { 1, 2, 3 },
         arr => Enumerable.Reverse(arr),
         arr => FastLinq.Reverse(arr));
 }
Esempio n. 5
0
 public void Null()
 {
     EnsureResultOrExceptionSame(
         (int[])null,
         arr => Enumerable.Reverse(arr),
         arr => FastLinq.Reverse(arr));
 }
Esempio n. 6
0
 public void IntMin()
 {
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Range(int.MinValue, 10),
         FastLinq.Range(int.MinValue, 10),
         4);
 }
Esempio n. 7
0
 public void IntMaxCountTwo()
 {
     new Action(
         () => FastLinq.Range(int.MaxValue, 2))
     .Should()
     .Throw <ArgumentOutOfRangeException>();
 }
Esempio n. 8
0
 public void RepeatNone()
 {
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Repeat(5, 0),
         FastLinq.Repeat(5, 0),
         1);
 }
Esempio n. 9
0
 public void Objects()
 {
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Empty <object>(),
         FastLinq.Empty <object>(),
         1);
 }
Esempio n. 10
0
 public void IntMaxCountOne()
 {
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Range(int.MaxValue, 1),
         FastLinq.Range(int.MaxValue, 1),
         1);
 }
Esempio n. 11
0
 public void FastLinq_SecondToLastItemCollection()
 {
     char _ = Enumerable.FirstOrDefault(
         FastLinq.Skip(
             FastLinq.Reverse(this.allLetters),
             1));
 }
Esempio n. 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);
                }
Esempio n. 13
0
 public void TwoCountIntMax()
 {
     new Action(
         () => FastLinq.Range(2, int.MaxValue))
     .Should()
     .Throw <ArgumentOutOfRangeException>();
 }
Esempio n. 14
0
 public void FastLinq_SecondToLastItemArray()
 {
     int _ = FastLinq.FirstOrDefault(
         FastLinq.Skip(
             FastLinq.Reverse(this.intArray),
             1));
 }
Esempio n. 15
0
 public void FastLinq_Paginate_ToList()
 {
     List <string> _ = FastLinq.ToList(
         FastLinq.Take(
             FastLinq.Skip(this.stringList, 30),
             10));
 }
Esempio n. 16
0
 public void FastLinq_LastTen_Lazy()
 {
     IReadOnlyList <int> _ = FastLinq.Reverse(
         FastLinq.Take(
             FastLinq.Reverse(this.intArray),
             10));
 }
Esempio n. 17
0
 public void NominalTest()
 {
     ListCompareTestUtil.ValidateEqual(
         Enumerable.Empty <int>(),
         FastLinq.Empty <int>(),
         1);
 }
Esempio n. 18
0
 public void CountNegative()
 {
     new Action(
         () => FastLinq.Repeat(0, -100))
     .Should()
     .Throw <ArgumentOutOfRangeException>();
 }
Esempio n. 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.");
                }
Esempio n. 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();
 }
Esempio n. 21
0
        public void NullInput()
        {
            IList list = null;

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

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

            new Action(
                () => FastLinq.SingleOrDefault(list))
            .Should()
            .Throw <InvalidOperationException>();
        }
Esempio n. 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);
 }
Esempio n. 25
0
        public void InputNull()
        {
            IReadOnlyList <int> list = null;

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

            new Action(
                () => FastLinq.ToList(input))
            .Should()
            .Throw <ArgumentNullException>();
        }
Esempio n. 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);
                }
Esempio n. 28
0
        public void InputEmpty()
        {
            IReadOnlyList <int> list = new int[] { };

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

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

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