public void TestGetByIdTourist() { Tourist testTourist = new Tourist() { Id = 1, Name = "Pepe", LastName = "Lopez", Email = "*****@*****.**", Bookings = null, }; List <Tourist> touristList = new List <Tourist>() { new Tourist() { Id = 2, Name = "Pepe", LastName = "Lopez", Email = "*****@*****.**", Bookings = null, }, }; touristList.Add(testTourist); touristList.ForEach(r => _context.Add(r)); _context.SaveChanges(); var repository = new TouristRepository(_context); var result = repository.GetById(1); Assert.AreEqual(testTourist, result); }
public void TestGetByEmail() { Tourist testTourist = new Tourist() { Id = 1, Name = "Pepe", LastName = "Lopez", Email = "*****@*****.**", Bookings = null, }; List <Tourist> touristList = new List <Tourist>() { new Tourist() { Id = 2, Name = "Pepe", LastName = "Lopez", Email = "*****@*****.**", Bookings = null, }, testTourist }; touristList.ForEach(s => _context.Add(s)); _context.SaveChanges(); var repository = new TouristRepository(_context); var result = repository.GetByEmail("*****@*****.**"); Assert.IsTrue(testTourist.Equals(result)); }
public void TestGetAllTouristsOk() { List <Tourist> touristsToReturn = new List <Tourist>() { new Tourist() { Id = 1, Name = "Juan", LastName = "Perez", Email = "*****@*****.**", Bookings = null, }, new Tourist() { Id = 2, Name = "Pepe", LastName = "Lopez", Email = "*****@*****.**", Bookings = null, }, }; touristsToReturn.ForEach(s => _context.Add(s)); _context.SaveChanges(); var repository = new TouristRepository(_context); var result = repository.GetAll(); Assert.IsTrue(touristsToReturn.SequenceEqual(result)); }
public void TestAddTourist() { Tourist tourist = new Tourist() { Id = 3, Name = "Pepe", LastName = "Lopez", Email = "*****@*****.**", Bookings = null, }; var repository = new TouristRepository(_context); repository.AddAndSave(tourist); Assert.AreEqual(_context.Find <Tourist>(3), tourist); }
public void DeleteTouristsTest() { Tourist tourist = new Tourist() { Id = 1, Name = "Pedro", LastName = "Korea", Email = "*****@*****.**", Bookings = null, }; _context.Add(tourist); _context.SaveChanges(); var repository = new TouristRepository(_context); repository.Delete(tourist); Assert.IsNull(_context.Find <Tourist>(1)); }