public void CanGetCities_CitiesService() { using (var context = new TicketsResellingContext(ContextOptions)) { var citiesService = new CitiesService(context); var cities = citiesService.GetCities().Result.ToList(); cities.Count().Should().Be(3); cities[0].Name.Should().Be("Tallin"); } }
public void CanAddCity_CitiesService() { using (var context = new TicketsResellingContext(ContextOptions)) { var citiesService = new CitiesService(context); var city = new City { Name = "Berlin", Status = CityStatuses.Avaliable }; citiesService.AddCity(city); var cities = citiesService.GetCities().Result.ToList(); cities.Count().Should().Be(4); cities[3].Name.Should().Be("Berlin"); } }
public void GetCitiesTest() { var mockRepository = new Mock <IDeletableEntityRepository <City> >(); mockRepository.Setup(x => x.All()).Returns(this.GetCityData()); var service = new CitiesService(mockRepository.Object); var cityNames = service.GetCities(); var result = new List <string> { "Sofia", "Plovdiv", "Tokyo" }.OrderBy(n => n); Assert.Equal(result, cityNames); }
public ActionResult Index() { ViewBag.Cities = service.GetCities(); ViewBag.Types = service.GetTypes(); return(View()); }