static void Main(string[] args) { //RestaurantReviews.Library.Restaurant restaurant = new Library.Restaurant() //{ // Id = 1, // Name = "Miboo", // Address = "9 5th Hill", // PhoneNumber = "727-962-8551", // City = "Clearwater", // State = "Florida" //}; //RestaurantCRUD restaurantCRUD = new RestaurantCRUD(); //restaurantCRUD.InsertRestaurant(restaurant); //List<RestaurantReviews.Library.Restaurant> restTest = DeseralizeItems.Deseralize<List<RestaurantReviews.Library.Restaurant>>(@"D:\revature\misale-ethan-project0\RestaurantInfo.txt"); //int k = 1; //for(int i = 0; i < restTest.Count ; i++) //{ // RestaurantReviews.Library.Restaurant restaurant = new Library.Restaurant(); // restaurant.Id = i + 1; // restaurant.Name = restTest[i].Name; // restaurant.PhoneNumber = restTest[i].PhoneNumber; // restaurant.State = restTest[i].State; // restaurant.Address = restTest[i].Address; // restaurant.City = restTest[i].City; // restaurantCRUD.InsertRestaurant(restaurant); // for (int j = 0; j < restTest[i].Reviews.Count ; j++, k++) // { // RestaurantReviews.Library.Review review = new Library.Review(); // review.Id = k; // review.Rating = restTest[i].Reviews[j].Rating; // review.Comment = restTest[i].Reviews[j].Comment; // review.RestaurantId = i+1; // restaurantCRUD.InsertReview(review); // } RestaurantDataAccess access = new RestaurantDataAccess(); // List<Restaurant> show = (List<Restaurant>)access.ShowRestaurants(); //// var sortTop = Sort1.SortTop3Rating(show); // foreach(Restaurant rest in show) // { // Console.WriteLine("Restaurant name: " + rest.Name ); // } List <Restaurant> restList = new List <Restaurant>(); restList = (List <Restaurant>)(access.ShowRestaurants()); foreach (Restaurant rest in restList) { //Console.WriteLine(rest.Name); Library.SerializeItems.Seralize(rest); } }
public async Task UpdateAsync() { var dataAccess = new RestaurantDataAccess(this.Context); //Act var sutCreate = new CreateRestaurantCommandHandler(dataAccess); var resultCreate = await sutCreate.Handle(new CreateRestaurantCommand { Data = RestaurantTestData.RestaurantDataDTO }, CancellationToken.None); //Act var sutUpdate = new UpdateRestaurantCommandHandler(dataAccess); var resultUpdate = await sutUpdate.Handle(new UpdateRestaurantCommand { Id = resultCreate.Data.Id, Data = new Common.DTO.RestaurantDataDTO { Name = "New Restaurant" } }, CancellationToken.None); //Assert Assert.IsTrue(resultUpdate.Succeeded); }
public async Task DeleteAsync() { var handler = new RestaurantDataAccess(this.Context, Mapper()); var entity = RestaurantTestData.RestaurantDTO; await handler.SaveAsync(entity); var response = await handler.DeleteAsync(entity.Id); Assert.IsTrue(response); }
public async Task SaveAsync() { var handler = new RestaurantDataAccess(this.Context, Mapper()); var entity = RestaurantTestData.RestaurantDTO; var result = await handler.SaveAsync(entity); var outcome = result.Id != 0; Assert.IsTrue(outcome); }
public async Task GetAsync() { var handler = new RestaurantDataAccess(this.Context, Mapper(), this.CachingService); var entity = RestaurantTestData.RestaurantDTO; await handler.SaveAsync(entity); var response = await handler.GetAsync(entity.Id); Assert.IsTrue(response != null); }
public async Task GetAllAsync() { var handler = new RestaurantDataAccess(this.Context, Mapper()); var entity = RestaurantTestData.RestaurantDTO; await handler.SaveAsync(entity); var response = await handler.GetAllAsync(new RestaurantDTO()); var outcome = response.Count; Assert.IsTrue(outcome == 1); }
public async Task SaveAsync() { var dataAccess = new RestaurantDataAccess(this.Context); //Act var sutCreate = new CreateRestaurantCommandHandler(dataAccess); var resultCreate = await sutCreate.Handle(new CreateRestaurantCommand { Data = RestaurantTestData.RestaurantDataDTO }, CancellationToken.None); Assert.IsTrue(resultCreate.Succeeded); }
public async Task UpdateAsync() { var handler = new RestaurantDataAccess(this.Context, Mapper()); var entity = RestaurantTestData.RestaurantDTO; var originalRestaurant = entity; await handler.SaveAsync(entity); entity.Name = new Faker().Commerce.Department(); var response = await handler.UpdateAsync(entity); var outcome = response.Name.Equals(originalRestaurant.Name); Assert.IsTrue(outcome); }
public async Task GetAllAsync() { var dataAccess = new RestaurantDataAccess(this.Context); //Act var sutCreate = new CreateRestaurantCommandHandler(dataAccess); var resultCreate = await sutCreate.Handle(new CreateRestaurantCommand { Data = RestaurantTestData.RestaurantDataDTO }, CancellationToken.None); //Act var sutGetAll = new GetRestaurantsQueryHandler(dataAccess); var resultGetAll = await sutGetAll.Handle(new GetRestaurantsQuery(), CancellationToken.None); Assert.IsTrue(resultGetAll?.Data.Count == 1); }
public async Task GetAsync() { var dataAccess = new RestaurantDataAccess(this.Context); //Act var sutCreate = new CreateRestaurantCommandHandler(dataAccess); var resultCreate = await sutCreate.Handle(new CreateRestaurantCommand { Data = RestaurantTestData.RestaurantDataDTO }, CancellationToken.None); //Act var sutGet = new GetRestaurantQueryHandler(dataAccess); var resultGet = await sutGet.Handle(new GetRestaurantQuery { Id = resultCreate.Data.Id }, CancellationToken.None); Assert.IsTrue(resultGet?.Data != null); }
public async Task DeleteAsync() { var dataAccess = new RestaurantDataAccess(this.Context, Mapper(), this.CachingService); //Act var sutCreate = new CreateRestaurantCommandHandler(dataAccess); var resultCreate = await sutCreate.Handle(new CreateRestaurantCommand { Data = RestaurantTestData.RestaurantDTO }, CancellationToken.None); //Act var sutDelete = new DeleteRestaurantCommandHandler(dataAccess); var outcomeDelete = await sutDelete.Handle(new DeleteRestaurantCommand { Id = resultCreate.Data.Id }, CancellationToken.None); //Assert Assert.IsTrue(outcomeDelete.Succeeded); }