當前位置: 首頁>>代碼示例>>C#>>正文


C# Testing.Browser類代碼示例

本文整理匯總了C#中Nancy.Testing.Browser的典型用法代碼示例。如果您正苦於以下問題:C# Browser類的具體用法?C# Browser怎麽用?C# Browser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Browser類屬於Nancy.Testing命名空間,在下文中一共展示了Browser類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: when_binding_to_a_collection_with_blacklisted_property

        public void when_binding_to_a_collection_with_blacklisted_property()
        {
            // Given
            var guid = Guid.NewGuid();
            string source = string.Format("{{\"SomeString\":\"some string value\",\"SomeGuid\":\"{0}\"}}", guid);

            var context = new BindingContext
            {
                DestinationType = typeof(Stuff),
                ValidModelBindingMembers = typeof(Stuff).GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(propertyInfo => propertyInfo.Name != "SomeString").Select(p => new BindingMemberInfo(p)),
            };

            // Given
            var module = new ConfigurableNancyModule(c => c.Post("/stuff", (_, m) =>
            {
                var stuff = m.Bind<List<Stuff>>("SomeString");
                return stuff.ToJSON();
            }));
            var bootstrapper = new TestBootstrapper(config => config.Module(module));

            // When
            var browser = new Browser(bootstrapper);
            var result = browser.Post("/stuff", with =>
            {
                with.HttpRequest();
                with.JsonBody(new List<Stuff> { new Stuff(1, "one"), new Stuff(2, "two") }, new JilSerializer());
            });

            // Then
            Assert.AreEqual("[{\"Id\":1,\"SomeString\":null},{\"Id\":2,\"SomeString\":null}]", result.Body.AsString());
        }
開發者ID:chenzuo,項目名稱:Nancy.Serialization.Jil,代碼行數:31,代碼來源:ModelBindingFixture.cs

示例2: Should_apply_default_accept_when_no_accept_header_sent

        public void Should_apply_default_accept_when_no_accept_header_sent()
        {
            // Given
            var browser = new Browser(with =>
            {
                with.ResponseProcessor<TestProcessor>();

                with.Module(new ConfigurableNancyModule(x =>
                {
                    x.Get("/", parameters =>
                    {
                        var context =
                            new NancyContext { NegotiationContext = new NegotiationContext() };

                        var negotiator =
                            new Negotiator(context);

                        return negotiator;
                    });
                }));
            });

            // When
            var response = browser.Get("/");

            // Then
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
開發者ID:uxTomas,項目名稱:Nancy,代碼行數:28,代碼來源:ContentNegotiationFixture.cs

示例3: TracingSmokeTests

        public TracingSmokeTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                    configuration => configuration.Modules(new Type[] { typeof(RazorWithTracingTestModule) }));

            this.browser = new Browser(bootstrapper);
        }
開發者ID:afwilliams,項目名稱:Nancy,代碼行數:7,代碼來源:TracingSmokeTests.cs

示例4: TestGetReturnsJsonArray

        public void TestGetReturnsJsonArray()
        {
            // Setup
            var mockBrightstar = new Mock<IBrightstarService>();
            mockBrightstar.Setup(s => s.ListStores()).Returns(new[] {"store1", "store2", "store3"});
            var app =
                new Browser(new FakeNancyBootstrapper(mockBrightstar.Object,
                                                      new FallbackStorePermissionsProvider(StorePermissions.All, StorePermissions.All),
                                                      new FallbackSystemPermissionsProvider(SystemPermissions.All, SystemPermissions.ListStores)));

            // Execute
            var response = app.Get("/", c => c.Accept(MediaRange.FromString("application/json")));

            // Assert
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
            Assert.That(response.ContentType, Contains.Substring("application/json"));
            Assert.That(response.Body, Is.Not.Null);
            var responseContent = response.Body.DeserializeJson <StoresResponseModel>();
            Assert.That(responseContent, Is.Not.Null);
            Assert.That(responseContent.Stores, Is.Not.Null);
            Assert.That(responseContent.Stores.Count, Is.EqualTo(3));
            Assert.That(responseContent.Stores.Any(s => s.Equals("store1") ));
            Assert.That(responseContent.Stores.Any(s => s.Equals("store2") ));
            Assert.That(responseContent.Stores.Any(s => s.Equals("store3") ));
        }
開發者ID:GTuritto,項目名稱:BrightstarDB,代碼行數:25,代碼來源:StoresUrlSpec.cs

示例5: HomeModuleTests

        public HomeModuleTests()
        {
            StaticConfiguration.DisableErrorTraces = false;

            var bootstrapper = GetConfigurableBootstrapper();
            _browser = new Browser(bootstrapper);
        }
開發者ID:nchabelengmc,項目名稱:silverpop-dotnet-api,代碼行數:7,代碼來源:HomeModuleTests.cs

示例6: shows_how_to_add_stuff_to_the_application_startup

        public void shows_how_to_add_stuff_to_the_application_startup()
        {
            // Arrange
            // Ripped from the Nancy-testing tests
            // Let's play with the date of the application
            // and kick ourself off 100 years in the future
            var date = new DateTime(2113, 01, 31);
            var bootstrapper = new Nancy.Testing.ConfigurableBootstrapper(with =>
                {
                    with.Module<DateModule>();
                    with.ApplicationStartup((container, pipelines) =>
                    {
                        // Other options are:
                            // pipelines.AfterRequest
                            // pipelines.OnError

                        // But for now - let's hook in before each request
                        pipelines.BeforeRequest += ctx =>
                        {
                            ctx.Items.Add("date", date);
                            return null;
                        };
                    });
                });

            var browser = new Browser(bootstrapper);

            // Act
            var response = browser.Get("/dateInTheFuture");

            // Assert
            Assert.Equal("The date is: 2113-01-31", response.Body.AsString());
        }
開發者ID:marcusoftnet,項目名稱:DiscoveringNancyThroughTests,代碼行數:33,代碼來源:ApplicationStartup_Tests.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: Init

        public void Init()
        {
            _storageEngine = new Mock<IStorageEngine>();

            var bootstrapper = new OverlookBootStrapper(_storageEngine.Object);
            _browser = new Browser(bootstrapper);
        }
開發者ID:KallDrexx,項目名稱:Overlook,代碼行數:7,代碼來源:MetricsModuleTests.cs

示例9: ViewBagTests

        public ViewBagTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                    configuration => configuration.Modules(typeof(RazorTestModule)));

            this.browser = new Browser(bootstrapper);
        }
開發者ID:RadifMasud,項目名稱:Nancy,代碼行數:7,代碼來源:ViewBagTests.cs

示例10: 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

示例11: Should_return_info_page_if_password_empty

        public async Task Should_return_info_page_if_password_empty()
        {
            // Given
            var bootstrapper = new ConfigurableBootstrapper(with =>
            {
                with.Configure(env =>
                {
                    env.Diagnostics(
                        enabled: true,
                        password: string.Empty,
                        cryptographyConfiguration: this.cryptoConfig);
                });

                with.EnableAutoRegistration();
                with.Diagnostics<DefaultDiagnostics>();
            });

            var browser = new Browser(bootstrapper);

            // When
            var result = await browser.Get(DiagnosticsConfiguration.Default.Path);

            // Then
            Assert.True(result.Body.AsString().Contains("Diagnostics Disabled"));
        }
開發者ID:VPashkov,項目名稱:Nancy,代碼行數:25,代碼來源:DiagnosticsHookFixture.cs

示例12: SetUp

 public void SetUp()
 {
     Runner.SqlCompact(ConnectionString).Down();
     Runner.SqlCompact(ConnectionString).Up();
     _server = new Server(64978);
     _browser = new Browser(new LemonadeBootstrapper(), context => context.UserHostAddress("localhost"));
 }
開發者ID:thesheps,項目名稱:lemonade,代碼行數:7,代碼來源:GivenLocalesModule.cs

示例13: TestFixtureSetup

 public void TestFixtureSetup()
 {
     _browser = new Browser(cfg =>
     {
         cfg.Module<SiteModule>();
     });
 }
開發者ID:amazuretestnz,項目名稱:NancyDemo1,代碼行數:7,代碼來源:SiteModuleFixture.cs

示例14: SetUp

		public void SetUp()
		{
			_fakeShortener = new FakeShortener();

			_bootstrapper = new ConfigurableBootstrapper(with => with.Dependency(_fakeShortener));
			_browser = new Browser(_bootstrapper);
		}
開發者ID:Dotnetwill,項目名稱:vfy.be,代碼行數:7,代碼來源:SiteTests.cs

示例15: PartialViewTests

        public PartialViewTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                    configuration => configuration.Modules(new [] { typeof(RazorTestModule) }));

            this.browser = new Browser(bootstrapper);
        }
開發者ID:dwonisch,項目名稱:Nancy,代碼行數:7,代碼來源:PartialViewTests.cs


注:本文中的Nancy.Testing.Browser類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。