コード例 #1
0
        public void Map_ReturnsNewKStream()
        {
            var observable = Observable.Return(DEFAULT_KEY_VALUE_PAIR);
            var testObject = new KStream <Unit, Unit>(observable);
            var actual     = testObject.Map((k, v) => KeyValuePair.Create(k, v));

            Assert.NotSame(testObject, actual);
        }
コード例 #2
0
        public async void Map_AppliesMapperToStream_WithTypesDifferentFromInput()
        {
            var observable = new[] {
                KeyValuePair.Create("hello", "WORLD"),
                KeyValuePair.Create("it's", "ME")
            }.ToObservable();
            var testObject = new KStream <string, string>(observable);

            var expected = new[] {
                KeyValuePair.Create(5, 5),
                KeyValuePair.Create(4, 2)
            };

            var actual = await testObject
                         .Map((k, v) =>
                              KeyValuePair.Create <int, int>(k.Length, v.Length)
                              )
                         .ToObservable()
                         .ToList()
                         .SingleAsync();

            Assert.Equal(expected, actual);
        }
コード例 #3
0
        public async void Map_AppliesMapperToStream()
        {
            var observable = new[] {
                KeyValuePair.Create("hello", "WORLD"),
                KeyValuePair.Create("it's", "ME")
            }.ToObservable();
            var testObject = new KStream <string, string>(observable);

            var expected = new[] {
                KeyValuePair.Create("HELLO", "world"),
                KeyValuePair.Create("IT'S", "me")
            };

            var actual = await testObject
                         .Map((k, v) =>
                              KeyValuePair.Create(k.ToUpper(), v.ToLower())
                              )
                         .ToObservable()
                         .ToList()
                         .SingleAsync();

            Assert.Equal(expected, actual);
        }