public DataBaseSeeder() { this.countryService = new CountryService(); this.townService = new TownService(); this.hotelService = new HotelService(); this.touristService = new TouristService(); this.voucherService = new VoucherService(); }
public void ChangeTouristAgeShouldThrowExceptionWithInvalidId() { Mock <DbSet <Tourist> > mockSet = SeedDataBase(); var mockContext = new Mock <TravelSimulatorContext>(); mockContext.Setup(c => c.Tourists).Returns(mockSet.Object); var service = new TouristService(mockContext.Object); Assert.Throws <InvalidOperationException>(() => service.ChangeTouristAge(27)); }
public void ShowTouristsByCountryShouldThrowExceptionWithInvalidCountry() { Mock <DbSet <Tourist> > mockSet = SeedDataBase(); var mockContext = new Mock <TravelSimulatorContext>(); mockContext.Setup(c => c.Tourists).Returns(mockSet.Object); var service = new TouristService(mockContext.Object); Assert.Throws <InvalidOperationException>(() => service.ShowAllTouristsByCountryTheyComeFrom("Romania")); }
public void ChangeTouristAgeShouldUpdateAge() { Mock <DbSet <Tourist> > mockSet = SeedDataBase(); var mockContext = new Mock <TravelSimulatorContext>(); mockContext.Setup(c => c.Tourists).Returns(mockSet.Object); var service = new TouristService(mockContext.Object); int updatedTouristAge = service.ChangeTouristAge(10); int expectedTouristAge = 21; Assert.AreEqual(expectedTouristAge, updatedTouristAge); }
public void ShowTouristsByCountryShouldReturnAllTouristsInCountry() { Mock <DbSet <Tourist> > mockSet = SeedDataBase(); var mockContext = new Mock <TravelSimulatorContext>(); mockContext.Setup(c => c.Tourists).Returns(mockSet.Object); var service = new TouristService(mockContext.Object); var tourists = service.ShowAllTouristsByCountryTheyComeFrom("England"); int expectedTouristCount = 7; Assert.AreEqual(expectedTouristCount, tourists.Count); }
public void GetTouristByIdShouldReturnTourist() { Mock <DbSet <Tourist> > mockSet = SeedDataBase(); var mockContext = new Mock <TravelSimulatorContext>(); mockContext.Setup(c => c.Tourists).Returns(mockSet.Object); var service = new TouristService(mockContext.Object); var tourist = service.GetTouristById(3); string expectedTouristName = "John Smith"; string resultedTouristName = String.Concat($"{tourist.TouristFirstName}" + " " + $"{tourist.TouristLastName}"); Assert.AreEqual(expectedTouristName, resultedTouristName); }