示例#1
0
 public void TestPullables()
 {
     Prop.ForAll <string[]>(strings =>
     {
         var sent     = new List <string>(strings);
         var received = new List <string>();
         PullableSource <string>
         .Sends(sent)
         .ForEach(output => received.Add(output));
         return(sent.SequenceEqual(received));
     }).QuickCheckThrowOnFailure();
 }
示例#2
0
 public void TestPullables()
 {
     Prop.ForAll <int[]>(numbers =>
     {
         var sent     = new List <int>(numbers);
         var received = new List <int>();
         var expected = new List <int>(numbers).Select(number => number * 2);
         PullableSource <int>
         .Sends(sent)
         .Map(number => number * 2)
         .AssertSink(output =>
         {
             received.Add(output);
             return(true);
         }, () => { }, () => Assert.Fail("Should not error out!"));
         return(expected.SequenceEqual(received));
     }).QuickCheckThrowOnFailure();
 }
示例#3
0
 public void TestPullables()
 {
     Prop.ForAll <int[]>(numbers =>
     {
         var sent     = new List <int>(numbers);
         var received = new List <int>();
         var expected = new List <int>(numbers).Sum();
         PullableSource <int>
         .Sends(sent)
         .Scan((acc, number) => acc + number, 0)
         .AssertSink(output =>
         {
             received.Add(output);
             return(true);
         }, () => { }, () => Assert.Fail("Should not error out!"));
         return(sent.Count == 0 || expected == received.Last());
     }).QuickCheckThrowOnFailure();
 }
示例#4
0
        public void TestPullables()
        {
            var random = new Random();

            Prop.ForAll <int[]>(numbers =>
            {
                var skip     = random.Next(numbers.Length);
                var sent     = new List <int>(numbers);
                var received = new List <int>();
                var expected = new List <int>(numbers).Skip(skip);
                PullableSource <int>
                .Sends(sent)
                .Skip(skip)
                .AssertSink(output =>
                {
                    received.Add(output);
                    return(true);
                }, () => { }, () => Assert.Fail("Should not error out!"));
                return(expected.SequenceEqual(received));
            }).QuickCheckThrowOnFailure();
        }