当前位置: 首页>>代码示例>>C#>>正文


C# Browser.Post方法代码示例

本文整理汇总了C#中Nancy.Testing.Browser.Post方法的典型用法代码示例。如果您正苦于以下问题:C# Browser.Post方法的具体用法?C# Browser.Post怎么用?C# Browser.Post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nancy.Testing.Browser的用法示例。


在下文中一共展示了Browser.Post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetUp

        public void SetUp()
        {
            _server = new Browser(new ServerBootstrapper());

            sampleConfig = TestHelper.GetSampleConfig();
            environmentConfig = TestHelper.GetEnvironmentOverrideConfig();

            setConfigResponse = _server.Post("application/new", context =>
            {
                context.HttpRequest();
                context.JsonBody(sampleConfig as object);
            });

            setEnvironmentConfigResponse = _server.Post("application/new", context =>
            {
                context.HttpRequest();
                context.JsonBody(environmentConfig as object);
                context.Query(TestHelper.Environment, "test");
            });

            getCreatedEnvironmentConfigResponse = _server.Get("application/new", context =>
            {
                context.Query(TestHelper.Environment, "test");
            });

            getEnvironmentConfigResult = getCreatedEnvironmentConfigResponse.Body.AsJson();
        }
开发者ID:cimdalli,项目名称:DynamicConfigurator,代码行数:27,代码来源:with_environment_data.cs

示例2: Should_find_usages_of_class

        public void Should_find_usages_of_class()
        {
            const string editorText = 
@"public class myclass
{
    public void method() { }

    public void method_calling_method()
    {
        method();        
    }
}
";
            var solution = new FakeSolution();
            var project = new FakeProject();
            project.AddFile(editorText);
            solution.Projects.Add(project);

            var bootstrapper = new ConfigurableBootstrapper(c => c.Dependency<ISolution>(solution));
            var browser = new Browser(bootstrapper);

            var result = browser.Post("/findusages", with =>
            {
                with.HttpRequest();
                with.FormValue("FileName", "myfile");
                with.FormValue("Line", "3");
                with.FormValue("Column", "21");
                with.FormValue("Buffer", editorText);
            });

            var usages = result.Body.DeserializeJson<FindUsagesResponse>().Usages.ToArray();
            usages.Count().ShouldEqual(2);
            usages[0].Text.Trim().ShouldEqual("public void method() { }");
            usages[1].Text.Trim().ShouldEqual("method();");
        }
开发者ID:dykim07,项目名称:vim-ide,代码行数:35,代码来源:IntegrationTest.cs

示例3: Observe

        public override void Observe()
        {
            base.RefreshDb();

            Container.Install(new BusInstaller(), new RepositoryInstaller(), new CommandInstaller());

            var state = StateMother.Draft;
            SaveAndFlush(state, StateMother.Published);



            var id = GetFromDb(state).Id;
            _browser = new Browser(with =>
            {
                with.Module(new StateModule(Container.Resolve<IPublishStorableCommands>(), Container.Resolve<IRepository<State>>()));
            });

            Session.FlushMode = FlushMode.Never;

            //Transaction(x =>
            //{
            _response = _browser.Post("/State/Edit", with =>
            {
                with.HttpRequest();
                with.Body("{ 'id': '" + id + "', 'name': 'Draft', 'alias': 'Test Draft'}");
                with.Header("content-type", "application/json");
                //with.Header("Authorization", "ApiKey 4E7106BA-16B6-44F2-AF4C-D1C411440F8E");
            });
            //});

            Session.Flush();
            // Session.Close();
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:33,代码来源:when_invoking_state_edit_route.cs

示例4: EnderecoInvalido

        public void EnderecoInvalido()
        {
            var bootstrapper = new FakeBoostrapper();

            bootstrapper.AddressQuery = () =>
                                            {
                                                var fake = new Mock<IAddressQuery>();
                                                fake.Setup(c => c.Execute())
                                                    .Returns(() =>
                                                                 {
                                                                     throw new AddressNotFoundException(
                                                                         "Endereço inválido");
                                                                 });
                                                return fake.Object;
                                            };

            var browser = new Browser(bootstrapper);

            var query = new Query { Addresses = new List<Address>{new Address{Name = "Ebdereco invalido"}}, Type = RouteType.LessTraffic };

            var result = browser.Post("/", with =>
            {
                with.HttpRequest();
                with.JsonBody(query);
            });

            Assert.Equal(HttpStatusCode.InternalServerError, result.StatusCode);
        }
开发者ID:kibiluzbad,项目名称:exu,代码行数:28,代码来源:RoutesTests.cs

示例5: Should_Return_Created_If_Created

        public void Should_Return_Created_If_Created()
        {
            var fakePostRepository = new Mock<IPostRepository>();
            var fakePost = new Post();
            fakePostRepository.Setup(x => x.Create(It.IsAny<Post>())).Returns(fakePost);

            var browser = new Browser(
                cfg =>
                {
                    cfg.Module<BlogModule>();
                    cfg.Dependencies<IPostRepository>(fakePostRepository.Object);
                    cfg.RequestStartup((container, pipelines, context) =>
                    {
                        context.CurrentUser = new UserIdentity {UserName = "Test"};
                    });
                });

            var result = browser.Post("/", with =>
            {
                with.HttpRequest();
                with.FormValue("Content", "Test Content");
            });

            Assert.Equal(HttpStatusCode.Created, result.StatusCode);
        }
开发者ID:chenzuo,项目名称:MicroBlog,代码行数:25,代码来源:BlogModuleTest.cs

示例6: PostInvalidMemeTypeRequestTest

        public void PostInvalidMemeTypeRequestTest(string text)
        {
            const string unknownResponseText = "Sorry! I don't know what that means! \n\nTo generate a meme for the current channel, type '/meme <memetype>:<meme text>' and I'll generate and insert the meme for you.\nI know about the following memes:\n   - Success Kid (sk)\n   - All The Things (att)\n   - Dwight Schrute (dwight)\n   - I Don't Always (ida)\n   - Doge (doge)\n   - Yoda (yoda1)\n   - Thinkin' Yoda (yoda2)\n";
            const string responseType = "ephemeral";

            var browser = new Browser(cfg =>
            {
                cfg.Module<ImageModule>();
                cfg.Dependency<IRootPathProvider>(new DefaultRootPathProvider());
                cfg.Dependency<ICommandParser>(new CommandParser());
                cfg.Dependency<IBlobStore>(new MockedImageStore("not_invalid"));
                cfg.Dependency<IImageGenerator>(new ImageGenerator(new MockedImageProvider()));
            });

            var result = browser.Post("/image/", context =>
            {
                if (text != null)
                    context.FormValue("text", text);
            });

            var model = result.Body.DeserializeJson<Models.UnknownResponse>();

            Assert.NotNull(model);
            Assert.Equal(responseType, model.response_type);
            Assert.Equal(unknownResponseText, model.text);
            Assert.Null(model.attachments);
        }
开发者ID:brporter,项目名称:slackmeme,代码行数:27,代码来源:ImageModuleTests.cs

示例7: Creates_user_when_valid_data_is_posted

        public void Creates_user_when_valid_data_is_posted()
        {
            const string login = "[email protected]";
            const string password = "password";

            var adapter = new InMemoryAdapter();
            Database.UseMockAdapter(adapter);

            var browser = new Browser(BootstrapperFactory.Create());

            var response = browser.Post("/admin/setup", with =>
            {
                with.HttpRequest();
                with.FormValue("Login", login);
                with.FormValue("Password", password);
            });

            var db = Database.Open();

            var allUsers = db.Users.All().ToList();

            Assert.AreEqual(1, allUsers.Count);
            Assert.AreEqual(login, allUsers[0].Login);
            Assert.AreEqual(password + "salt", allUsers[0].HashedPassword);
            Assert.AreEqual("salt", allUsers[0].Salt);

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
        }
开发者ID:kristofclaes,项目名称:Markie,代码行数:28,代码来源:SetupModuleTests.cs

示例8: When_deploying_an_app_that_doesnt_exist

 public When_deploying_an_app_that_doesnt_exist()
 {
     _Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
     {
         with.LoggedInUser();
     });
     _Response = _Browser.Post("/Deploy/foofoo");
 }
开发者ID:nterry,项目名称:Apphbify,代码行数:8,代码来源:When_deploying_an_app_that_doesnt_exist.cs

示例9: When_no_payload_is_sent

 public When_no_payload_is_sent()
 {
     _Browser = Testing.CreateBrowser<HookModule>();
     _Response = _Browser.Post("/Sites/foofoo/NotifyByEmail", with =>
     {
         with.Query("email", "[email protected]");
     });
 }
开发者ID:nterry,项目名称:Apphbify,代码行数:8,代码来源:When_no_payload_is_sent.cs

示例10: SignIn

 protected static void SignIn(Browser browser)
 {
     browser.Post("/signin", with =>
     {
         with.HttpRequest();
         with.FormValue("Email", "[email protected]");
         with.FormValue("Password", "password");
     });
 }
开发者ID:Firebuild,项目名称:Firebuild,代码行数:9,代码来源:BaseWebTests.cs

示例11: can_fetch_as_text_via_header

        public void can_fetch_as_text_via_header()
        {
            var sut = new Browser(new Bootstrapper { DataStore = DataStoreForTest });

            var result = sut.Post("/quips", with => with.JsonBody(testData))
                                            .Then.Get("/quip", with => with.Accept("text/plain"));

            result.ContentType.ShouldBe("text/plain");
            result.Body.AsString().ShouldBe("Fixed some errors in the last commit");
        }
开发者ID:hyrmn,项目名称:NancyIntro,代码行数:10,代码来源:ContentNegotiationTests.cs

示例12: When_no_application_name_is_specified

 public When_no_application_name_is_specified()
 {
     _Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
     {
         with.LoggedInUser();
     });
     _Response = _Browser.Post("/Deploy/jabbr", with =>
     {
         with.FormValue("region_id", "amazon-web-services::us-east-1");
     });
 }
开发者ID:nterry,项目名称:Apphbify,代码行数:11,代码来源:When_no_application_name_is_specified.cs

示例13: When_no_region_id_is_specified

 public When_no_region_id_is_specified()
 {
     _Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
     {
         with.LoggedInUser();
     });
     _Response = _Browser.Post("/Deploy/jabbr", with =>
     {
         with.FormValue("application_name", "foo");
     });
 }
开发者ID:nterry,项目名称:Apphbify,代码行数:11,代码来源:When_no_region_id_is_specified.cs

示例14: can_get_an_awesome_commit_message

        public void can_get_an_awesome_commit_message()
        {
            var sut = new Browser(new Bootstrapper { DataStore = DataStoreForTest });

            var aFunnyMessage = new Quip { Message = "By works, I meant 'doesnt work'. Works now.." };

            var result = sut.Post("/quips", with => with.JsonBody(aFunnyMessage))
                                            .Then.Get("/");

            result.Body["#totally_useful_commit_message"].ShouldExistOnce().And.ShouldContain("works now", StringComparison.InvariantCultureIgnoreCase);
        }
开发者ID:hyrmn,项目名称:NancyIntro,代码行数:11,代码来源:HomeModuleTests.cs

示例15: can_fetch_as_json_via_extension

        public void can_fetch_as_json_via_extension()
        {
            var sut = new Browser(new Bootstrapper { DataStore = DataStoreForTest });

            var result = sut.Post("/quips", with => with.JsonBody(testData))
                                            .Then.Get("/quip.json");

            var returnedQuip = result.Body.DeserializeJson<Quip>();

            returnedQuip.Message.ShouldBe("Fixed some errors in the last commit");
        }
开发者ID:hyrmn,项目名称:NancyIntro,代码行数:11,代码来源:ContentNegotiationTests.cs


注:本文中的Nancy.Testing.Browser.Post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。