コード例 #1
0
        public void GET_Given_An_Url_Shortened_Should_Return_Data_Of_The_Url()
        {
            //Arrange
            var url = new Model.Url("http://www.2dsolucoes.net");
            var repository = new StubUrlStorage(url);
            var bootstrapper = new ConfigurableBootstrapper(with =>
            {
                with.Dependency<IUrlStorage>(repository);
            });
            var browser = new Browser(bootstrapper);

            //Act
            var urlAPI = string.Format("/urls/{0}", url.Short);
            var response = browser.Get(urlAPI, ctx =>
            {
                ctx.HttpRequest();
            });

            dynamic result = response.Body.ToDynamic();

            //Assert
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
            Assert.That((string)result.Source, Is.EqualTo(url.Source));
            Assert.That((string)result.Short, Is.EqualTo(url.Short));
        }
コード例 #2
0
        public void GET_When_No_Url_Should_Return_StatsuCode_404()
        {
            //Arrange
            var url = new Model.Url("http://www.2dsolucoes.net");
            var repository = new StubUrlStorage(url);
            var bootstrapper = new ConfigurableBootstrapper(with =>
            {
                with.Dependency<IUrlStorage>(repository);
            });
            var browser = new Browser(bootstrapper);

            //Act
            var urlAPI = "/urls/abCD1";
            var response = browser.Get(urlAPI, ctx =>
            {
                ctx.HttpRequest();
            });

            dynamic result = response.Body.ToDynamic();

            //Assert
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
        }