Ejemplo n.º 1
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.º 2
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);
        }