예제 #1
0
        public async Task HasExpectedType(string method, string url, OperationType?type)
        {
            var request = new StartRequest(method, url);
            var sources = new List <string> {
                NuGetSourceUrl
            };
            var context = await OperationParserContext.CreateAsync(sources);

            var operationInfo = OperationParser.Parse(context, request);

            Assert.Equal(type, operationInfo.Operation?.Type);
        }
        private static async Task UpdateSources(Context ctx, IEnumerable <string> sources)
        {
            var newSources = sources.Except(ctx.Sources).ToList();

            if (newSources.Any())
            {
                ctx.Sources.AddRange(newSources);
                ctx.Sources.Sort(StringComparer.Ordinal);

                Console.WriteLine("Loading sources for operation parsing...");
                foreach (var source in sources)
                {
                    Console.WriteLine($"- {source}");
                }

                ctx.OperationParserContext = await OperationParserContext.CreateAsync(ctx.Sources);
            }
        }
예제 #3
0
        public async Task CanParsePackageBaseAddressIndex()
        {
            var request = new StartRequest("GET", NuGetPackageBaseAddress + "newtonsoft.json/index.json");
            var sources = new List <string> {
                NuGetSourceUrl
            };
            var context = await OperationParserContext.CreateAsync(sources);

            var operationInfo = OperationParser.Parse(context, request);

            var pair = Assert.Single(operationInfo.SourceResourceUris);

            Assert.Equal(NuGetSourceUrl, pair.Key);
            Assert.Equal(new Uri(NuGetPackageBaseAddress, UriKind.Absolute), pair.Value);

            Assert.Equal(OperationType.PackageBaseAddressIndex, operationInfo.Operation.Type);
            Assert.Same(request, operationInfo.Request);
            var operationWithId = Assert.IsType <OperationWithId>(operationInfo.Operation);

            Assert.Equal("newtonsoft.json", operationWithId.Id);
        }