Пример #1
0
        public async Task MapArrayAsync_ToNewObject_MappedAsync()
        {
            var mapper = new AsyncMapper();

            var to = await mapper
                     .MapArrayAsync(
                new MapFrom[]
            {
                new MapFrom()
                {
                    Property = 1
                },
                new MapFrom()
                {
                    Property = 2
                },
            },
                this.cancellationTokenSource.Token)
                     .ConfigureAwait(false);

            Assert.Equal(this.cancellationTokenSource.Token, mapper.CancellationToken);
            Assert.IsType <MapTo[]>(to);
            Assert.Equal(2, to.Length);
            Assert.Equal(1, to[0].Property);
            Assert.Equal(2, to[1].Property);
        }
Пример #2
0
        public async Task MapTypedCollectionAsync_ToNewObject_MappedAsync()
        {
            var mapper = new AsyncMapper();

            var to = await mapper
                     .MapCollectionAsync(
                new MapFrom[]
            {
                new MapFrom()
                {
                    Property = 1
                },
                new MapFrom()
                {
                    Property = 2
                },
            },
                new List <MapTo>())
                     .ConfigureAwait(false);

            Assert.IsType <List <MapTo> >(to);
            Assert.Equal(2, to.Count);
            Assert.Equal(1, to[0].Property);
            Assert.Equal(2, to[1].Property);
        }
Пример #3
0
        public async Task MapAsyncEnumerable_ToNewObject_MappedAsync()
        {
            var mapper = new AsyncMapper();
            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);
        }
Пример #4
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);
        }
Пример #5
0
        public Task MapAsync_Null_ThrowsArgumentNullExceptionAsync()
        {
            var mapper = new AsyncMapper();

            return(Assert.ThrowsAsync <ArgumentNullException>(
                       "source",
                       () => mapper.MapAsync(null, this.cancellationTokenSource.Token)));
        }
Пример #6
0
        public async Task MapArrayAsync_Empty_MappedAsync()
        {
            var mapper = new AsyncMapper();

            var to = await mapper.MapArrayAsync(Array.Empty <MapFrom>()).ConfigureAwait(false);

            Assert.IsType <MapTo[]>(to);
            Assert.Empty(to);
        }
Пример #7
0
        public async Task MapTypedCollectionAsync_Empty_MappedAsync()
        {
            var mapper = new AsyncMapper();

            var to = await mapper.MapCollectionAsync(Array.Empty <MapFrom>(), new List <MapTo>()).ConfigureAwait(false);

            Assert.IsType <List <MapTo> >(to);
            Assert.Empty(to);
        }
Пример #8
0
        public async Task MapList_Empty_Mapped()
        {
            var mapper = new AsyncMapper();

            var to = await mapper.MapList(
                new MapFrom[0]);

            Assert.IsType <List <MapTo> >(to);
            Assert.Empty(to);
        }
Пример #9
0
        public async Task MapArrayAsync_Empty_Mapped()
        {
            var mapper = new AsyncMapper();

            var to = await mapper.MapArrayAsync(
                new MapFrom[0]);

            Assert.IsType <MapTo[]>(to);
            Assert.Empty(to);
        }
Пример #10
0
        public async Task MapObservableCollectionAsync_Empty_Mapped()
        {
            var mapper = new AsyncMapper();

            var to = await mapper.MapObservableCollectionAsync(
                new MapFrom[0]);

            Assert.IsType <ObservableCollection <MapTo> >(to);
            Assert.Empty(to);
        }
Пример #11
0
        public async Task MapArrayAsync_Empty_MappedAsync()
        {
            var mapper = new AsyncMapper();

            var to = await mapper
                     .MapArrayAsync(Array.Empty <MapFrom>(), this.cancellationTokenSource.Token)
                     .ConfigureAwait(false);

            Assert.IsType <MapTo[]>(to);
            Assert.Empty(to);
        }
Пример #12
0
        public async Task MapTypedCollectionAsync_Empty_Mapped()
        {
            var mapper = new AsyncMapper();

            var to = await mapper.MapCollectionAsync(
                new MapFrom[0],
                new List <MapTo>());

            Assert.IsType <List <MapTo> >(to);
            Assert.Empty(to);
        }
Пример #13
0
        public async Task MapAsync_ToNewObject_Mapped()
        {
            var mapper = new AsyncMapper();

            var to = await mapper.MapAsync(new MapFrom()
            {
                Property = 1
            });

            Assert.Equal(1, to.Property);
        }
Пример #14
0
        public async Task MapAsync_ToNewObject_MappedAsync()
        {
            var mapper = new AsyncMapper();

            var to = await mapper
                     .MapAsync(new MapFrom()
            {
                Property = 1
            }, this.cancellationTokenSource.Token)
                     .ConfigureAwait(false);

            Assert.Equal(this.cancellationTokenSource.Token, mapper.CancellationToken);
            Assert.Equal(1, to.Property);
        }
Пример #15
0
        public async Task MapArrayAsync_ToNewObject_Mapped()
        {
            var mapper = new AsyncMapper();

            var to = await mapper.MapArrayAsync(
                new MapFrom[]
            {
                new MapFrom()
                {
                    Property = 1
                },
                new MapFrom()
                {
                    Property = 2
                }
            });

            Assert.IsType <MapTo[]>(to);
            Assert.Equal(2, to.Length);
            Assert.Equal(1, to[0].Property);
            Assert.Equal(2, to[1].Property);
        }
Пример #16
0
        public async Task MapList_ToNewObject_Mapped()
        {
            var mapper = new AsyncMapper();

            var to = await mapper.MapList(
                new MapFrom[]
            {
                new MapFrom()
                {
                    Property = 1
                },
                new MapFrom()
                {
                    Property = 2
                }
            });

            Assert.IsType <List <MapTo> >(to);
            Assert.Equal(2, to.Count);
            Assert.Equal(1, to[0].Property);
            Assert.Equal(2, to[1].Property);
        }
Пример #17
0
        public async Task MapObservableCollectionAsync_ToNewObject_Mapped()
        {
            var mapper = new AsyncMapper();

            var to = await mapper.MapObservableCollectionAsync(
                new MapFrom[]
            {
                new MapFrom()
                {
                    Property = 1
                },
                new MapFrom()
                {
                    Property = 2
                }
            });

            Assert.IsType <ObservableCollection <MapTo> >(to);
            Assert.Equal(2, to.Count);
            Assert.Equal(1, to[0].Property);
            Assert.Equal(2, to[1].Property);
        }
Пример #18
0
        public void Map_Null_ThrowsArgumentNullException()
        {
            var mapper = new AsyncMapper();

            Assert.ThrowsAsync <ArgumentNullException>("source", () => mapper.Map(null));
        }
Пример #19
0
        public Task MapAsync_Null_ThrowsArgumentNullException()
        {
            var mapper = new AsyncMapper();

            return(Assert.ThrowsAsync <ArgumentNullException>("source", () => mapper.MapAsync(null)));
        }