예제 #1
0
        public async Task DefaultIfEmptyWithInt64SourceWithDefaultValueIsEquivalentToDefaultIfEmptyTest()
        {
            // Arrange

            // Arrange 'queryAdapter' parameter
            var queryAdapter = await GetQueryAdapterAsync(DisallowAll);

            // Arrange 'source' parameter
            var source = GetQueryable <long>();

            // Arrange 'asyncSource' parameter
            var asyncSource = queryAdapter.GetAsyncQueryable <long>();

            // Arrange 'defaultValue' parameter
            var defaultValue = 5;

            // Arrange 'expectedResult' parameter
            var expectedResult = Enumerable.DefaultIfEmpty <long>(source, defaultValue);

            // Act
            var result = await AsyncQueryable.DefaultIfEmpty <long>(asyncSource, defaultValue).ToListAsync().ConfigureAwait(false);

            // Assert
            Assert.Equal(expectedResult, result);
        }
예제 #2
0
        public async Task DefaultIfEmptyWithDoubleSourceNullSourceThrowsArgumentNullExceptionTest()
        {
            // Arrange

            // Arrange 'queryAdapter' parameter
            var queryAdapter = await GetQueryAdapterAsync(DisallowAll);

            // Arrange 'asyncSource' parameter
            IAsyncQueryable <double> asyncSource = null !;

            // Act
            // -

            // Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await AsyncQueryable.DefaultIfEmpty <double>(asyncSource).ToListAsync().ConfigureAwait(false);
            });
        }