Ejemplo n.º 1
0
 public DataBaseSeeder()
 {
     this.countryService = new CountryService();
     this.townService    = new TownService();
     this.hotelService   = new HotelService();
     this.touristService = new TouristService();
     this.voucherService = new VoucherService();
 }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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"));
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }