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); }
public void ChamadaARaiz() { var bootstrapper = new FakeBoostrapper(); var browser = new Browser(bootstrapper); var result = browser.Get("/", with => { with.HttpRequest(); }); Assert.Equal(HttpStatusCode.OK, result.StatusCode); }
public void MenorDistancia() { var bootstrapper = new FakeBoostrapper(); var browser = new Browser(bootstrapper); var query = new Query { Addresses = new List<Address> { new Address { City = "São Paulo", State = "SP", Name = "Av. Paulista", Number = "1000" }, new Address { City = "São Paulo", State = "SP", Name = "Av. Paulista", Number = "2000" } }, Type = RouteType.FastestRoute }; var route = "{\"Time\":{\"Days\":0,\"Hours\":0,\"Minutes\":30,\"Seconds\":0,\"Milliseconds\":0},\"Distance\":1,\"FuelCost\":1,\"TotalCost\":1}"; bootstrapper.RouteQuery = GetRoute1(); var result = browser.Post("/", with => { with.HttpRequest(); with.JsonBody(query); }); var output = result.Body.AsString(); Assert.Equal(route, output); }
public void NenhumEnderecoInformado() { var bootstrapper = new FakeBoostrapper(); var browser = new Browser(bootstrapper); var query = new Query { Addresses = new List<Address>(), Type = RouteType.LessTraffic }; var result = browser.Post("/", with => { with.HttpRequest(); with.JsonBody(query); }); Assert.Equal(HttpStatusCode.BadRequest, result.StatusCode); }
public void NenhumaEntrada() { var bootstrapper = new FakeBoostrapper(); var browser = new Browser(bootstrapper); var result = browser.Post("/", with => { with.HttpRequest(); }); Assert.Equal(HttpStatusCode.BadRequest, result.StatusCode); }
public void MenosTransito() { var bootstrapper = new FakeBoostrapper(); var browser = new Browser(bootstrapper); var query = new Query {Addresses = new List<Address>{new Address(), new Address()}, Type = RouteType.LessTraffic}; var route = "{\"Time\":{\"Days\":0,\"Hours\":0,\"Minutes\":40,\"Seconds\":0,\"Milliseconds\":0},\"Distance\":2,\"FuelCost\":2,\"TotalCost\":2}"; bootstrapper.RouteQuery = GetRoute2(); var result = browser.Post("/", with => { with.HttpRequest(); with.JsonBody(query); }); var output = result.Body.AsString(); Assert.Equal(route, output); }