Exemple #1
0
        public void SubscribeOnHomePage_WithDuplicateEmail_AlreadySubscribedMessage()
        {
            // Given
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper, defaults: to => to.Accept("application/json"));

            var result = browser.Post("/", with =>
            {
                with.FormValue("email", "*****@*****.**");
                with.FormValue("real", "");
                with.HttpRequest();
            });

            result = browser.Post("/", with =>
            {
                with.FormValue("email", "*****@*****.**");
                with.FormValue("real", "");
                with.HttpRequest();
            });

            // Then
            var commonResult = result.Body.DeserializeJson <CommonResult>();

            Assert.True(commonResult.Success);
            Assert.Equal("Already subscribed", commonResult.Message);
        }
Exemple #2
0
        public void TestSetup()
        {
            // Arrange
            var bootstrapper = new DefaultNancyBootstrapper();

            _browser = new Browser(bootstrapper);
        }
Exemple #3
0
        public void DebugRoute()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);


            var requestBody  = "{\"token\":\"fWLgDuiSNnxt2RYDhljCTbs0\",\"team_id\":\"T02FQR5EX\",\"channel_id\":\"C036W3BN3\",\"channel_name\":\"debug\",\"user_id\":\"U02NAKD4K\",\"user_name\":\"casperandersen\",\"command\":\" / imdb\",\"text\":\"test\"}";
            var slackCommand = new Model.SlackCommandRequest()
            {
                token        = "fWLgDuiSNnxt2RYDhljCTbs0",
                team_id      = "T02FQR5EX",
                channel_id   = "C036W3BN3",
                channel_name = "debug",
                user_id      = "U02NAKD4K",
                user_name    = "casperandersen",
                command      = "/imdb",
                text         = "test"
            };

            // When
            var result = browser.Post("/imdb/debug", with => {
                with.HttpRequest();
                with.JsonBody <Model.SlackCommandRequest>(slackCommand);
                with.Body(requestBody);
            });

            // Then
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
Exemple #4
0
        public void WebhookSearchResultResponse()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);

            var slackCommand = new Model.SlackCommandRequest()
            {
                token        = "fWLgDuiSNnxt2RYDhljCTbs0",
                team_id      = "T02FQR5EX",
                channel_id   = "C036W3BN3",
                channel_name = "debug",
                user_id      = "U02NAKD4K",
                user_name    = "casperandersen",
                command      = "/imdb",
                text         = "the 100"
            };

            // When
            var result = browser.Post("/imdb", with => {
                with.HttpRequest();
                with.JsonBody <Model.SlackCommandRequest>(slackCommand);
            });

            // Then
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
 public MediatorServer(SystemConfiguration systemConfig, DataSource dataSource)
 {
     config = systemConfig.Servers.First(kvp => kvp.Value.Type == ServerTypes.Mediator).Value;
     controller = new Controller(dataSource);
     //			bootstrapper = new MediatorBootstrapper(controller);
     bootstrapper = new ApiBootstrapper(controller);
 }
        public void Setup()
        {
            boostrapper = new DefaultNancyBootstrapper();
            browser     = new Browser(boostrapper, defaults: to => to.Accept("application/json"));

            TestContext.WriteLine("test setup done");
        }
Exemple #7
0
        public void can_delete_a_book()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);
            var result = browser.Delete("/books/destroy/1", with => with.HttpRequest());

            Assert.AreEqual(HttpStatusCode.OK.ToString(), result.StatusCode.ToString());
        }
Exemple #8
0
        public NancyService()
        {
            var port       = AppSettings.ServerPort;
            var uriBuilder = new UriBuilder("http", "localhost", port);
            INancyBootstrapper bootStrapper = new DefaultNancyBootstrapper();

            _host = new NancyHost(uriBuilder.Uri);
        }
Exemple #9
0
        public void ShouldReturnStatusOkWhenRouteExists1()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);
            var result       = browser.Get("/debug", with => { with.HttpRequest(); });

            Assert.AreEqual(HttpStatusCode.OK, result.Result.StatusCode);
        }
Exemple #10
0
        protected RequestSpec()
        {
            var defaultNancyBootstrapper = new DefaultNancyBootstrapper();

            defaultNancyBootstrapper.Initialise();

            engine = defaultNancyBootstrapper.GetEngine();
        }
Exemple #11
0
        protected RequestSpec()
        {
            var defaultNancyBootstrapper = new DefaultNancyBootstrapper();

            defaultNancyBootstrapper.Initialise();

            engine = defaultNancyBootstrapper.GetEngine();
        }
Exemple #12
0
        public void Status_is_ok_on_root_path() {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

            var result = browser.Get("/", with => with.HttpRequest());

            Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.OK));
            Assert.That(result.Body.AsString(), Does.Not.Contain("[ERR!]"));
        }
Exemple #13
0
        static void Main(string[] args)
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            bootstrapper.Initialise();
            var host = new NancyHost(bootstrapper, new Uri("http://127.0.0.1:8080"));

            host.Start();

            Console.ReadLine();
        }
        public void TestGet()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

            var url = string.Format("/getProtoBuf/{0}/{1}", UserName, UserAge);
            var response = browser.Get(url, with => with.HttpRequest());

            CheckResponse(response, UserName, UserAge);
        }
Exemple #15
0
        public async Task MainEndpoint()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);
            var result       = await browser.Get("/", with => {
                with.HttpRequest();
            });

            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
        }
Exemple #16
0
        public async Task Should_GetAnEmptyListOfStudentsAsync()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);

            var result = await browser.Get("/students", with => with.HttpRequest());

            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
            Assert.Equal("[]", result.Body.AsString());
        }
Exemple #17
0
        public void Configuration(IAppBuilder app)
        {
            var bootstrapper = new DefaultNancyBootstrapper();

            app
                .UseFunc(LogRequests) // defined below
                .UseShowExceptions() // from Gate.Middleware package
                .MapHubs("/signalr") // from SignalR.Server assembly
                .RunNancy(bootstrapper); // from Gate.Adapters.Nancy package
        }
        public void Return_Not_Found_When_Asking_For_Empty_Guid()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);

            var result = browser.Get($"/scrape/1", with => {
                with.HttpRequest();
            });

            Assert.AreEqual(HttpStatusCode.NotFound, result.StatusCode);
        }
        public void DefaultTest()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

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

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
    public void WaitClientNotRegistered()
    {
      var bootstrapper = new DefaultNancyBootstrapper();
      var browser = new Browser(bootstrapper);

      var response = browser.Get(string.Format("http://127.0.0.1/Poll/Wait?clientId={0}&seqCode={1}", Guid.NewGuid().ToString(), 0));
      Assert.IsNotNull(response);
      var responseAsString = response.Body.AsString();
      Assert.IsNotNull(responseAsString);
      Assert.IsTrue(responseAsString.Contains("ClientNotRegistered"));
    }
Exemple #21
0
        public void ReturnOKWhenDefaultRouteHit()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);

            // When
            var result = browser.Get("/", with => { with.HttpRequest(); });

            // Then
            Assert.Equal(HttpStatusCode.OK, result.Result.StatusCode);
        }
Exemple #22
0
        public void TestOK()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);

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

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
Exemple #23
0
        public async Task SendData()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);
            var result       = await browser.Post("/data", with =>
            {
                with.HttpRequest();
            });

            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
        }
Exemple #24
0
        public void ReturnNotFoundWhenRouteDoesntExist()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);

            // When
            var result = browser.Get("/bla", with => { with.HttpRequest(); });

            // Then
            Assert.Equal(HttpStatusCode.NotFound, result.Result.StatusCode);
        }
        public void LoadAllModulesAndTestView()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

            var response = browser.Get("/authors", (with) => {
                with.HttpRequest();
            });

            response.ShouldHaveRedirectedTo("/homeWithStylishMaster");
        }
        public void Bootstrapper_should_use_locator_if_not_specified()
        {
            // Given
            var bootstrapper = new DefaultNancyBootstrapper();
            NancyBootstrapperLocator.Bootstrapper = bootstrapper;

            //When
            //Then
            this.nancyOptions.Bootstrapper.ShouldNotBeNull();
            this.nancyOptions.Bootstrapper.ShouldBeSameAs(bootstrapper);
        }
Exemple #27
0
        public void Should_return_status_ok_for_root()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

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

            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
        }
 public IntergrationTests()
 {
     // Given
     mock = new CallBacksMock();
     var bootstrapper = new DefaultNancyBootstrapper();
     var browser      = new Browser(bootstrapper);
     // When
     var result = browser.Get("/mock/callback", with =>
     {
         with.HttpRequest();
     });
 }
        public void Should_return_status_ok_when_route_exists()
        {
            // Given
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper, defaults: to => to.Accept("application/json"));

            // When
            var result = browser.Get("/", with => with.HttpRequest());

            // Then
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
        public void ShouldReturnStatusOkWhenRouteExists()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

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

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
Exemple #31
0
        public void Main()
        {
            var host = new WebHostBuilder()
                       .UseStartup <Startup>()
                       .Build();

            host.Run();

            var bootstrapper = new DefaultNancyBootstrapper();

            _browser = new Browser(bootstrapper);
        }
Exemple #32
0
        public void Bootstrapper_should_use_locator_if_not_specified()
        {
            // Given
            var bootstrapper = new DefaultNancyBootstrapper();

            NancyBootstrapperLocator.Bootstrapper = bootstrapper;

            //When
            //Then
            this.nancyOptions.Bootstrapper.ShouldNotBeNull();
            this.nancyOptions.Bootstrapper.ShouldBeSameAs(bootstrapper);
        }
        public void WaitClientNotRegistered()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);

            var response = browser.Get(string.Format("http://127.0.0.1/Poll/Wait?clientId={0}&seqCode={1}", Guid.NewGuid().ToString(), 0));

            Assert.IsNotNull(response);
            var responseAsString = response.Body.AsString();

            Assert.IsNotNull(responseAsString);
            Assert.IsTrue(responseAsString.Contains("ClientNotRegistered"));
        }
Exemple #34
0
        public static void Amanda_Exposes_1_Parameter_Action()
        {
            var bootstraper = new DefaultNancyBootstrapper();
            var browser     = new Browser(bootstraper);

            var result = browser.Get("/api/DoNothingFor", ctx =>
            {
                ctx.Query("i", "5");
                ctx.HttpRequest();
            });

            result.StatusCode.Should().Be(HttpStatusCode.OK);
        }
Exemple #35
0
        public void Should_answer_Not_Empty_on_root_path()
        {
            // Given
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);

            // When
            var response = browser.Get("/image/", with => {
                with.HttpRequest();
            });

            Assert.NotEmpty(response.Result.Body);
        }
Exemple #36
0
        public async Task Should_GetListOfStudentsAsync()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);
            var testStudent  = await browser.CreateTestStudentAsync();

            var result = await browser.Get("/students", with => with.HttpRequest());

            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
            var studentList = result.Body.DeserializeJson <Student[]>();

            Assert.Single(studentList, testStudent);
        }
Exemple #37
0
        public void can_create_a_book()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);
            var newTitle = Guid.NewGuid().ToString();
            var result = browser.Post("/books/new", with =>
            {
                with.HttpRequest();
                with.FormValue("Title", newTitle);
            });

            Assert.AreEqual(HttpStatusCode.Created.ToString(), result.StatusCode.ToString());
        }
Exemple #38
0
        public static void Amanda_Exposes_1_Parameter_Action()
        {
            var bootstraper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstraper);

            var result = browser.Get("/api/DoNothingFor", ctx =>
                                                              {
                                                                  ctx.Query("i", "5");
                                                                  ctx.HttpRequest();
                                                              });

            result.StatusCode.Should().Be(HttpStatusCode.OK);
        }
        public async Task Should_GetListOfTeachersAsync()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);
            var testTeacher  = await browser.CreateTestTeacherAsync();

            var result = await browser.Get("/teachers", with => with.HttpRequest());

            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
            var teacherList = result.Body.DeserializeJson <Teacher[]>();

            Assert.Single(teacherList, testTeacher);
        }
Exemple #40
0
        public void TestMethod1()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);
            // When
            var result = browser.Post("/", with => {
                with.HttpRequest();
                with.Body(testdata_resources.customer);
            });

            // Then
            Assert.AreEqual(HttpStatusCode.OK, result.Result.StatusCode);
        }
        public async Task Should_return_status_ok_when_route_exists()
        {
            // Given
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper, defaults: to => to.Accept("application/json"));

            // When
            var result = await browser.Get("/shoppingcart/123", with => {
                with.HttpRequest();
            });

            // Then
            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
        }
        public void TestNotFound()
        {
            //Arrange
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

            //Act
            var result = browser.Delete("/routes", with => {
                with.HttpRequest();
            });

            //Assert
            Assert.AreEqual (HttpStatusCode.MethodNotAllowed, result.StatusCode);
        }
Exemple #43
0
        public void ShouldReturnStatusOkWhenRouteExists3()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);
            var result       = browser.Get("/debugdataJson", with => { with.HttpRequest(); });

            Assert.AreEqual(HttpStatusCode.OK, result.Result.StatusCode);
            var actual = result.Result.Body.AsString().Replace(" ", string.Empty);
            var expect = JsonConvert.SerializeObject(new WorkerModule.DebugData {
                Name = "xxx", Status = true, Crc = 12345
            }).Replace(" ", string.Empty).ToLower();

            Assert.AreEqual(expect, actual);
        }
Exemple #44
0
        public void TestThatEmptyPost_BadRequest()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);

            // When
            var result = browser.Post("/api/login", with =>
            {
                with.HttpRequest();
            });

            // Then
            Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode);
        }
        public void TestThatEmptyPost_BadRequest()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

            // When
            var result = browser.Post("/api/login", with =>
            {
                with.HttpRequest();
            });

            // Then
            Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode);
        }
Exemple #46
0
        public async Task TestGetAsync()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);
            var url          = string.Format("/getmsgpack/{0}/{1}", UserName, UserAge);

            var response = await browser.Get(url, with =>
            {
                with.HttpRequest();
                with.Accept(ConstValue.MessagePackContentType);
            });

            CheckResponse(response, UserName, UserAge);
        }
Exemple #47
0
        public void ShouldReturnStatusOkWhenRouteExists2()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser      = new Browser(bootstrapper);
            var result       = browser.Get("/debugdataText", with => { with.HttpRequest(); });

            Assert.AreEqual(HttpStatusCode.OK, result.Result.StatusCode);
            var actual = result.Result.Body.AsString();
            var expect = new WorkerModule.DebugData {
                Name = "xxx", Status = true, Crc = 12345
            }.ToString();

            Assert.AreEqual(expect, actual);
        }
        public ComputeServer(SystemConfiguration systemConfig, string name, AlgorithmFactory algoFactory)
        {
            uuid = Guid.NewGuid().ToString();
            this.name = name;
            config = systemConfig.Servers[name];

            var mediatorConfig = systemConfig.Servers.First(kvp => kvp.Value.Type == ServerTypes.Mediator).Value;
            mediator = new MediatorConnector(mediatorConfig);

            workerPool = new WorkerPool(config.PoolSize, uuid, mediator);

            //bootstrapper = new ComputeBootstrapper(this, workerPool);
            bootstrapper = new ApiBootstrapper(this, workerPool, algoFactory);
        }
        public void LoadAllModulesAndTestThem()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

            BrowserResponse response = browser.Get("/books", (with) => {
                with.HttpRequest();
                with.Accept("application/json");
            });

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            Assert.AreEqual("application/json; charset=utf-8", response.Body.ContentType);
            Assert.IsTrue(response.Body.AsString().Length > 0);
            Console.WriteLine(response.Body.AsString());
        }
        public void TestMethod1()
        {
            // Given
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

            // When
            var result = browser.Get("/", with =>
            {
                with.HttpRequest();
            });

            // Then
            Assert.IsTrue(HttpStatusCode.OK == result.StatusCode);
        }
Exemple #51
0
        public void smoke_test()
        {
            // Given
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

            // When
            var result = browser.Get("/books", with =>
            {
                with.HttpRequest();
            });

            // Then
            Assert.AreEqual(HttpStatusCode.OK.ToString(), result.StatusCode.ToString());
        }
        public void TestThatNonNetlightPost_BadRequest()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

            // When
            var result = browser.Post("/api/login", with =>
            {
                with.FormValue("Username", "*****@*****.**");
                with.HttpRequest();
            });

            // Then
            Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode);
        }
        public void TestPut()
        {
            //Arrange
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

            //Act
            var result = browser.Put("/routes", with => {
                with.HttpRequest();
            });

            //Assert
            Assert.AreEqual (HttpStatusCode.OK, result.StatusCode);
            Assert.AreEqual ("Response with Put\n", result.Body.AsString());
        }
Exemple #54
0
        public static void Amanda_Exposes_No_Parameter_Action()
        {
            var bootstraper = new DefaultNancyBootstrapper();
            var browser = new Browser(x =>
                                          {
                                              x.RootPathProvider(new DefaultRootPathProvider());
                                          });

            var result = browser.Get("/api/DoNothing", ctx =>
                                                           {
                                                               ctx.HttpRequest();
                                                           });

            result.StatusCode.Should().Be(HttpStatusCode.OK);
        }
        public void TestPost()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

            // get the serialized bytes to the service
            var response = browser.Post(
                "/postProtoBuf",
                with =>
                {
                    with.HttpRequest();
                    with.FormValue("Name", UserName);
                    with.FormValue("Age", UserAge.ToString());
                });

            CheckResponse(response, UserName, UserAge);
        }
Exemple #56
0
        public static void Amanda_Exposes_No_Parameter_Func()
        {
            var bootstraper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstraper);

            var wasteTime = browser.Get("/api/DoNothing", ctx =>
            {
                ctx.HttpRequest();
            });

            var result = browser.Get("/api/GetWastedTime", ctx =>
            {
                ctx.HttpRequest();
            });

            result.StatusCode.Should().Be(HttpStatusCode.OK);
            result.Body.AsString().Should().Be("1000");
        }
Exemple #57
0
        public void Should_return_list_of_autocomplete_suggestions()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

            var result = browser.Get("/autocomplete", with => {
                with.HttpRequest();
                with.Accept(new Nancy.Responses.Negotiation.MediaRange("application/json"));
                with.Query("q", "man");
            });

            Assert.Equal(HttpStatusCode.OK, result.StatusCode);

            var response = (dynamic)JsonConvert.DeserializeObject<ExpandoObject>(result.Body.AsString());
            Assert.Equal(response.q, "man");
            Assert.Contains(response.d, (Predicate<dynamic>)(destination => (int)destination.k > 0));
            Assert.Contains(response.h, (Predicate<dynamic>)(hotel => (int)hotel.id > 0));
        }
    public void Register()
    {
      var bootstrapper = new DefaultNancyBootstrapper();
      var browser = new Browser(bootstrapper);

      var response = browser.Get("http://127.0.0.1/Poll/Register");
      var obj = JObject.Parse(response.Body.AsString()).ToObject<dynamic>();

      Assert.IsNotNull(obj);
      Assert.IsNotNull(obj.success);
      Assert.IsNotNull(obj.retcode);
      Assert.IsNotNull(obj.messageName);
      Assert.IsNotNull(obj.data);

      Assert.AreEqual(true, obj.success.Value);
      Assert.AreEqual("Ok", obj.retcode.Value);
      Assert.AreEqual(null, obj.messageName.Value);
      Assert.IsTrue(obj.data.Value is string);
    }
        public void Test1OneToOne()
        {
            // given
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper, defaults: to => to.Accept("application/json"));
            ApiBootstrapper.AddOrUpdate("mock", new ApiMock());

            // request simple route.
            var result = browser.Get("mock/routing", with =>
            {
                with.Body(string.Empty);
                with.Header("content-type", "application/json");
                with.Query("vehicle", "car");
                with.Query("loc", "1,1");
                with.Query("loc", "3,4");
                with.HttpRequest();
            });

            // then not acceptable
            Assert.IsNotNull(result);
            var response = OsmSharp.Geo.Streams.GeoJson.GeoJsonConverter.ToFeatureCollection(result.Body.AsString());
            Assert.IsNotNull(response);
            Assert.AreEqual(1, response.Count);

            // request simple route but return full format.
            result = browser.Get("mock/routing", with =>
            {
                with.Body(string.Empty);
                with.Header("content-type", "application/json");
                with.Query("vehicle", "car");
                with.Query("loc", "1,1");
                with.Query("loc", "3,4");
                with.Query("format", "osmsharp");
                with.HttpRequest();
            });

            // then not acceptable
            Assert.IsNotNull(result);
            var route = result.Body.DeserializeJson<OsmSharp.Routing.Route>();
            Assert.IsNotNull(response);
            Assert.AreEqual(1, response.Count);
        }
        public static NancyHostWrapper CreateAndOpenSelfHost(INancyBootstrapper nancyBootstrapper = null, HostConfiguration configuration = null)
        {
            if (nancyBootstrapper == null)
            {
                nancyBootstrapper = new DefaultNancyBootstrapper();
            }

            var host = new NancyHost(nancyBootstrapper, configuration, BaseUri);

            try
            {
                host.Start();
            }
            catch
            {
                throw new Exception();
            }

            return new NancyHostWrapper(host);
        }