public void TestGetTouristSpotBad() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); ITouristSpotRepository touristSpotRepo = new TouristSpotRepository(context); touristSpotRepo.Get(aTouristSpot.Id); }
public void TestUpdateTouristSpotNullInvalid() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); ITouristSpotRepository touristSpotRepo = new TouristSpotRepository(context); touristSpotRepo.Update(null); }
public void TestGetTouristSpotsByCategoriesIdAndRegionIdBad() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); ITouristSpotRepository touristSpotRepo = new TouristSpotRepository(context); TouristSpot aTouristSpot2 = new TouristSpot() { Id = Guid.NewGuid(), Name = "La Paloma", Description = "Un gran lugar", Region = aRegion, ListOfCategories = new List <CategoryTouristSpot>() { } }; categoryTouristSpot.TouristSpot = aTouristSpot2; categoryTouristSpot.TouristSpotId = aTouristSpot2.Id; aTouristSpot2.ListOfCategories.Add(categoryTouristSpot); touristSpotRepo.Add(aTouristSpot2); List <TouristSpot> listToCompare = new List <TouristSpot>() { aTouristSpot2 }; List <Guid> listOfCategoriesIdToSearch = new List <Guid>() { categoryTouristSpot.CategoryId }; List <TouristSpot> touristSpotsByRegionAndCategories = touristSpotRepo.GetTouristSpotsByCategoriesAndRegion(listOfCategoriesIdToSearch, Guid.NewGuid()); }
public void TestRemoveTouristSpotInvalid() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); ITouristSpotRepository touristSpotRepo = new TouristSpotRepository(context); touristSpotRepo.Remove(aTouristSpot); }
public void GetReviewByReserveIdTest() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); IReviewRepository reviewRepo = new ReviewRepository(context); ITouristSpotRepository touristSpotRepo = new TouristSpotRepository(context); ILodgingRepository lodgingRepo = new LodgingRepository(context); IRepository <Reserve> reserveRepo = new BaseRepository <Reserve>(context); touristSpotRepo.Add(touristSpot); lodgingRepo.Add(lodging); reserveRepo.Add(reserve); Review reviewToAdd = new Review() { Id = Guid.NewGuid(), Description = "Me gusto mucho la estadia", IdOfReserve = reserve.Id, LastNameOfWhoComments = reserve.LastName, NameOfWhoComments = reserve.Name, LodgingOfReview = lodging, Score = 4 }; reviewRepo.Add(reviewToAdd); Review reviewResult = reviewRepo.GetReviewByReserveId(reserve.Id); Assert.IsTrue(reviewResult.Equals(reviewToAdd)); }
public void Setup() { TouristSpots = new List <TouristSpot>(); Options = new DbContextOptionsBuilder <UruguayNaturalContext>() .UseInMemoryDatabase("UruguayNaturalDBTest").Options; Context = new UruguayNaturalContext(Options); Repository = new TouristSpotRepository(Context); var region = new Region() { Id = 1, Name = "region 1" }; var category = new Category() { Id = 1, Name = "category 1" }; var touristSpot1 = CreateTouristSpot(1, region, category); var touristSpot2 = CreateTouristSpot(2, region, category); TouristSpots.Add(touristSpot1); TouristSpots.Add(touristSpot2); }
public void TestInvalidAddTouristSpot() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); ITouristSpotRepository touristSpotRepo = new TouristSpotRepository(context); IRepository <Region> regionRepo = new BaseRepository <Region>(context); regionRepo.Add(aRegion); touristSpotRepo.Add(null); }
public void TestGetTouristSpotByNameOk() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); ITouristSpotRepository touristSpotRepo = new TouristSpotRepository(context); touristSpotRepo.Add(aTouristSpot); TouristSpot touristSpotResult = touristSpotRepo.GetTouristSpotByName(aTouristSpot.Name); Assert.AreEqual(aTouristSpot, touristSpotResult); }
public void TestGetTouristSpotOK() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); ITouristSpotRepository touristSpotRepo = new TouristSpotRepository(context); IRepository <Region> regionRepo = new BaseRepository <Region>(context); regionRepo.Add(aRegion); touristSpotRepo.Add(aTouristSpot); TouristSpot touristSpotOfDb = touristSpotRepo.Get(aTouristSpot.Id); Assert.AreEqual(aTouristSpot, touristSpotOfDb); }
public void TestAddTouristSpotOK() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); ITouristSpotRepository touristSpotRepo = new TouristSpotRepository(context); IRepository <Region> regionRepo = new BaseRepository <Region>(context); regionRepo.Add(aRegion); touristSpotRepo.Add(aTouristSpot); List <TouristSpot> listOfTouristSpots = touristSpotRepo.GetAll().ToList(); Assert.AreEqual(aTouristSpot, listOfTouristSpots[0]); }
public void TestUpdateTouristSpotOK() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); ITouristSpotRepository touristSpotRepo = new TouristSpotRepository(context); touristSpotRepo.Add(aTouristSpot); aTouristSpot.Name = "Piscinas"; touristSpotRepo.Update(aTouristSpot); List <TouristSpot> listOfTouristSpots = touristSpotRepo.GetAll().ToList(); Assert.AreEqual("Piscinas", listOfTouristSpots[0].Name); }
public void TestGenerateReportWithoutLodgings() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); ILodgingRepository lodgingRepository = new LodgingRepository(context); ITouristSpotRepository touristSpotRepository = new TouristSpotRepository(context); ICategoryRepository categoryRepository = new CategoryRepository(context); categoryRepository.Add(aCategory); touristSpotRepository.Add(touristSpot); lodgingRepository.Add(lodging); DateTime checkInDate = new DateTime(2020, 05, 24); DateTime checkOutDate = new DateTime(2020, 06, 11); List <Lodging> listOfLodgingsWithReserve = lodgingRepository.GetLodgingsWithReserves(touristSpot.Id, checkInDate, checkOutDate); }
public void TestGetAllTouristSpotsOK() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); ITouristSpotRepository touristSpotRepo = new TouristSpotRepository(context); TouristSpot aTouristSpot2 = new TouristSpot() { Id = Guid.NewGuid(), Name = "La Paloma", Description = "Un gran lugar", Region = aRegion }; touristSpotRepo.Add(aTouristSpot); touristSpotRepo.Add(aTouristSpot2); List <TouristSpot> listTest = new List <TouristSpot>(); listTest.Add(aTouristSpot); listTest.Add(aTouristSpot2); List <TouristSpot> listOfTouristSpots = touristSpotRepo.GetAll().ToList(); CollectionAssert.AreEqual(listTest, listOfTouristSpots); }
public void TestGenerateReportOKWithMoreReserves() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); ILodgingRepository lodgingRepository = new LodgingRepository(context); ITouristSpotRepository touristSpotRepository = new TouristSpotRepository(context); ICategoryRepository categoryRepository = new CategoryRepository(context); IRepository <Reserve> reserveRepository = new BaseRepository <Reserve>(context); categoryRepository.Add(aCategory); touristSpotRepository.Add(touristSpot); lodgingRepository.Add(lodging); lodgingRepository.Add(lodging2); reserve.LodgingOfReserve = lodging3; reserveRepository.Add(reserve); reserveRepository.Add(reserve2); DateTime checkInDate = new DateTime(2020, 05, 24); DateTime checkOutDate = new DateTime(2020, 06, 11); List <Lodging> listOfLodgingsWithReserve = lodgingRepository.GetLodgingsWithReserves(touristSpot.Id, checkInDate, checkOutDate); Assert.IsTrue(listOfLodgingsWithReserve.Contains(lodging3)); }
public void TestGenerateReportOK() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); ILodgingRepository lodgingRepository = new LodgingRepository(context); ITouristSpotRepository touristSpotRepository = new TouristSpotRepository(context); ICategoryRepository categoryRepository = new CategoryRepository(context); IRepository <Reserve> reserveRepository = new BaseRepository <Reserve>(context); categoryRepository.Add(aCategory); touristSpotRepository.Add(touristSpot); lodgingRepository.Add(lodging); lodgingRepository.Add(lodging2); reserveRepository.Add(reserve); DateTime checkInDate = new DateTime(2020, 05, 24); DateTime checkOutDate = new DateTime(2020, 06, 11); List <Lodging> listOfLodgingsWithReserve = lodgingRepository.GetLodgingsWithReserves(touristSpot.Id, checkInDate, checkOutDate); Assert.IsTrue(listOfLodgingsWithReserve[0].Equals(lodging) && listOfLodgingsWithReserve.Count == 1 && listOfLodgingsWithReserve[0].QuantityOfReserveForThePeriod(checkInDate, checkOutDate) == 1); }
public void TestGetTouristSpotsByCategoriesAndRegionIdInvalid() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); ITouristSpotRepository touristSpotRepo = new TouristSpotRepository(context); List <TouristSpot> touristSpotsByCategoriesAndRegion = touristSpotRepo.GetTouristSpotsByCategoriesAndRegion(null, aRegion.Id); }