示例#1
0
        public void CreateCollection()
        {
            IWebHostBuilder webhostbuilder = new WebHostBuilder()
                                             .UseEnvironment("Test")
                                             .UseStartup <TestStartup>();

            using (TestServer server = new TestServer(webhostbuilder)) {
                PostmanCollectionCreator collectioncreator = new PostmanCollectionCreator("http://localhost:5000");
                Collection collection = collectioncreator.Create(Guid.Empty, "Test", server.GetService <IApiDescriptionGroupCollectionProvider>());
                Assert.AreNotEqual(0, collection.Item.Length);
            }
        }
示例#2
0
        public void QueryParametersAreAdded()
        {
            IWebHostBuilder webhostbuilder = new WebHostBuilder()
                                             .UseEnvironment("Test")
                                             .UseStartup <TestStartup>();

            using (TestServer server = new TestServer(webhostbuilder))
            {
                PostmanCollectionCreator collectioncreator = new PostmanCollectionCreator("http://localhost:5000");
                Collection collection = collectioncreator.Create(Guid.Empty, "Test", server.GetService <IApiDescriptionGroupCollectionProvider>());
                Assert.AreNotEqual(0, collection.Item.Length);

                RequestItem item = collection["Common.Simple.GetSomethingWithQuery"] as RequestItem;
                Assert.IsNotNull(item);
                Assert.AreEqual(1, item.Request.Url.Query.Length);
                Assert.AreEqual("parameter", item.Request.Url.Query[0].Key);
            }
        }
示例#3
0
        public void UserPasswordAuthentication()
        {
            IWebHostBuilder webhostbuilder = new WebHostBuilder()
                                             .UseEnvironment("Test")
                                             .UseStartup <TestStartup>();

            using (TestServer server = new TestServer(webhostbuilder)) {
                PostmanCollectionCreator collectioncreator = new PostmanCollectionCreator("http://localhost:5000",
                                                                                          new PasswordAuthenticationData {
                    Server   = "http://auth.localhost:5000/",
                    Audience = "audience",
                    ClientId = "clientid",
                    Username = "******",
                    Password = "******",
                    Scope    = "read:resource"
                });
                Collection collection = collectioncreator.Create(Guid.Empty, "Test", server.GetService <IApiDescriptionGroupCollectionProvider>());
                Assert.AreNotEqual(0, collection.Item.Length);

                Assert.IsTrue(collection.Item.Any(i => i.Name.StartsWith("Authenticate")));
            }
        }