コード例 #1
0
ファイル: MapperTest.cs プロジェクト: avjolsakaj/Framework
        public async Task MapAsyncEnumerable_ToNewObject_MappedAsync()
        {
            var mapper = new Mapper();
            var source = new TestAsyncEnumerable <MapFrom>(
                new MapFrom[]
            {
                new MapFrom()
                {
                    Property = 1
                },
                new MapFrom()
                {
                    Property = 2
                },
            });

            var to = mapper.MapAsyncEnumerable(source);

            var list = await to.ToListAsync().ConfigureAwait(false);

            Assert.IsType <List <MapTo> >(list);
            Assert.Equal(2, list.Count);
            Assert.Equal(1, list[0].Property);
            Assert.Equal(2, list[1].Property);
        }
コード例 #2
0
        public async Task MapEnumerableAsync_ToNewObject_MappedAsync()
        {
            var mapper = new AsyncMapper();
            var source = new TestAsyncEnumerable <MapFrom>(
                new MapFrom[]
            {
                new MapFrom()
                {
                    Property = 1
                },
                new MapFrom()
                {
                    Property = 2
                },
            });

            var to = mapper.MapEnumerableAsync(source, this.cancellationTokenSource.Token);

            var list = await to.ToListAsync().ConfigureAwait(false);

            Assert.Equal(this.cancellationTokenSource.Token, mapper.CancellationToken);
            Assert.IsType <List <MapTo> >(list);
            Assert.Equal(2, list.Count);
            Assert.Equal(1, list[0].Property);
            Assert.Equal(2, list[1].Property);
        }