Example #1
0
        protected override async Task FormatArrangeAsync(StreamWriter writer)
        {
            var options = _optionsResolver.ResolveOptions(Method, _parameters);

            // QueryAdapter
            await writer.WriteLineAsync().ConfigureAwait(false);

            await writer.WriteLineAsync("            // Arrange 'queryAdapter' parameter").ConfigureAwait(false);

            await writer.WriteLineAsync($"            var queryAdapter = await GetQueryAdapterAsync({options});").ConfigureAwait(false);

            await _parameters.SetupParametersAsync(writer).ConfigureAwait(false);
        }
        protected override async Task FormatArrangeAsync(StreamWriter writer)
        {
            var options = _optionsResolver.ResolveOptions(_methods.AsyncMethod, _parameters.AsyncParameters);

            // QueryAdapter
            await writer.WriteLineAsync().ConfigureAwait(false);

            await writer.WriteLineAsync("            // Arrange 'queryAdapter' parameter").ConfigureAwait(false);

            await writer.WriteLineAsync($"            var queryAdapter = await GetQueryAdapterAsync({options});").ConfigureAwait(false);

            await _parameters.SyncParameters.SetupParametersAsync(writer).ConfigureAwait(false);

            await _parameters.AsyncParameters.SetupParametersAsync(writer).ConfigureAwait(false);

            // ExpectedResult
            await writer.WriteLineAsync().ConfigureAwait(false);

            await writer.WriteLineAsync("            // Arrange 'expectedResult' parameter").ConfigureAwait(false);

            if (_methods.SyncMethod.Name.Equals("Append", StringComparison.Ordinal) ||
                _methods.SyncMethod.Name.Equals("Prepend", StringComparison.Ordinal))
            {
                await writer.WriteLineAsync($"            var expectedResult =").ConfigureAwait(false);

                await writer.WriteLineAsync($"            Enumerable").ConfigureAwait(false);

                await writer.WriteAsync($"            .{_methods.SyncMethod.Name}").ConfigureAwait(false);
            }
            else if (_methods.SyncMethod.Name.Equals("SkipLast", StringComparison.Ordinal) ||
                     _methods.SyncMethod.Name.Equals("TakeLast", StringComparison.Ordinal))
            {
                await writer.WriteLineAsync($"            var expectedResult =").ConfigureAwait(false);

                await writer.WriteLineAsync($"            EnumerableExtension").ConfigureAwait(false);

                await writer.WriteAsync($"            .{_methods.SyncMethod.Name}").ConfigureAwait(false);
            }
            else
            {
                await writer.WriteAsync($"            var expectedResult = {TypeHelper.FormatCSharpTypeName(_methods.SyncMethod.DeclaringType!, _knownNamespaces.Namespaces)}.{_methods.SyncMethod.Name}").ConfigureAwait(false);
            }

            if (_methods.SyncMethod.IsGenericMethod)
            {
                await writer.WriteAsync("<").ConfigureAwait(false);

                var genericArguments = _methods.SyncMethod.GetGenericArguments();
                for (var i = 0; i < genericArguments.Length; i++)
                {
                    await writer.WriteAsync(
                        TypeHelper.FormatCSharpTypeName(genericArguments[i], _knownNamespaces.Namespaces)).ConfigureAwait(false);

                    if (i < genericArguments.Length - 1)
                    {
                        await writer.WriteAsync(',').ConfigureAwait(false);

                        await writer.WriteAsync(' ').ConfigureAwait(false);
                    }
                }

                await writer.WriteAsync('>').ConfigureAwait(false);
            }

            await writer.WriteAsync('(').ConfigureAwait(false);

            await _parameters.SyncParameters.WriteParameterListAsync(writer).ConfigureAwait(false);

            await writer.WriteLineAsync(");").ConfigureAwait(false);
        }