Exemplo n.º 1
0
 public void PipeWithSequence()
 {
     var results = new List<int>();
     var returned = new[] { 1, 2, 3 }.Pipe(results.Add);
     // Lazy - nothing has executed yet
     Assert.That(results, Is.Empty);
     returned.AssertSequenceEqual(1, 2, 3);
     // Now it has...
     results.AssertSequenceEqual(1, 2, 3);
 }
Exemplo n.º 2
0
 public void IndexSequenceStartIndex()
 {
     const string one = "one";
     const string two = "two";
     const string three = "three";
     var result = new[] { one, two, three }.Index(10);
     result.AssertSequenceEqual(
         KeyValuePair.Create(10, one),
         KeyValuePair.Create(11, two),
         KeyValuePair.Create(12, three));
 }
Exemplo n.º 3
0
        public void CountBySimpleTest()
        {
            var result = new[] { 1, 2, 3, 4, 5, 6, 1, 2, 3, 1, 1, 2 }.CountBy(c => c);

            var expectations = new List<KeyValuePair<int, int>>()
            {
                { 1, 4 },
                { 2, 3 },
                { 3, 2 },
                { 4, 1 },
                { 5, 1 },
                { 6, 1 },
            };

            result.AssertSequenceEqual(expectations);
        }
Exemplo n.º 4
0
 public void BatchSequenceTransformingResult()
 {
     var result = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }.Batch(4, batch => batch.Sum());
     result.AssertSequenceEqual(10, 26, 9);
 }
Exemplo n.º 5
0
 public void PadNarrowSourceSequenceWithNonDefaultPadding()
 {
     var result = new[] { 123, 456, 789 }.Pad(5, -1);
     result.AssertSequenceEqual(new[] { 123, 456, 789, -1, -1 });
 }
Exemplo n.º 6
0
 public void PadEqualSourceSequence()
 {
     var result = new[] { 123, 456, 789 }.Pad(3);
     result.AssertSequenceEqual(new[] { 123, 456, 789 });
 }
Exemplo n.º 7
0
 public void TakeLastOnSequenceShortOfCount()
 {
     var result = new[] { 12, 34, 56 }.TakeLast(5);
     result.AssertSequenceEqual(12, 34, 56);
 }
Exemplo n.º 8
0
 public void TakeLast()
 {
     var result = new[]{ 12, 34, 56, 78, 910, 1112 }.TakeLast(3);
     result.AssertSequenceEqual(78, 910, 1112);
 }
Exemplo n.º 9
0
 public void TakeEveryThirdOnNonEmptySequence()
 {
     var result = new[] { 1, 2, 3, 4, 5 }.TakeEvery(3);
     result.AssertSequenceEqual(1, 4);
 }
Exemplo n.º 10
0
 public void TakeEveryOtherOnNonEmptySequence()
 {
     var result = new[] { 1, 2, 3, 4, 5 }.TakeEvery(2);
     result.AssertSequenceEqual(1, 3, 5);
 }
Exemplo n.º 11
0
 public void PairwiseWideSourceSequence()
 {
     var result = new[] { 123, 456, 789 }.Pairwise((a, b) => new { A = a, B = b, });
     result.AssertSequenceEqual(new { A = 123, B = 456, },
                                new { A = 456, B = 789, });
 }
Exemplo n.º 12
0
        public void CountByWithEqualityComparer()
        {
            var result = new[] { "a", "B", "c", "A", "b", "A" }.CountBy(c => c, StringComparer.OrdinalIgnoreCase);

            var expectations = new List<KeyValuePair<string, int>>()
            {
                { "a", 3 },
                { "B", 2 },
                { "c", 1 },
            };

            result.AssertSequenceEqual(expectations);
        }