public void Test_Create_ReturnsFalseForInvalidHours()
        {
            // Arrange
            IUnitOfWork stubUnitOfWork = MockRepository.GenerateStub<IUnitOfWork>();
            RideService controller = new RideService(stubUnitOfWork);
            DateTime dateRidden = new DateTime(2011, 01, 01);

            // Act
            bool result = controller.Create(1, 1, dateRidden, -1, 0, 0);

            // Assert
            Assert.IsFalse(result);
        }
        public void Test_Create_SucceedsWithNoTimeTaken()
        {
            // Arrange
            IUnitOfWork stubUnitOfWork = MockRepository.GenerateStub<IUnitOfWork>();
            StubRepository<Ride> stubRideRepository = new StubRepository<Ride>();
            stubUnitOfWork.Stub(s => s.GetRepository<Ride>()).Return(stubRideRepository);
            RideService service = new RideService(stubUnitOfWork);
            DateTime dateRidden = new DateTime(2011, 01, 01);

            // Act
            bool result = service.Create(1, 1, dateRidden, null, null, null);

            // Assert
            Ride ride = stubRideRepository.InsertItems[0];
            Assert.IsTrue(result);
            Assert.AreEqual(1, ride.RouteID);
            Assert.AreEqual(dateRidden, ride.TimeOfRide);
            Assert.AreEqual(null, ride.TimeTaken);
            Assert.AreEqual(1, ride.AccountID);
            stubUnitOfWork.AssertWasCalled(uw => uw.Save());
        }
        public void Test_Create_ThrowsServiceExceptionOnUnitOfWorkError()
        {
            // Arrange
            IUnitOfWork stubUnitOfWork = MockRepository.GenerateStub<IUnitOfWork>();
            StubRepository<Ride> stubRideRepository = new StubRepository<Ride>();
            stubUnitOfWork.Stub(s => s.GetRepository<Ride>()).Return(stubRideRepository);
            stubUnitOfWork.Stub(s => s.Save()).Throw(new Exception());
            RideService service = new RideService(stubUnitOfWork);
            DateTime dateRidden = new DateTime(2011, 01, 01);
            bool exceptionThrown = false;

            // Act
            try
            {
                service.Create(1, 1, dateRidden, null, null, null);
            }
            catch (ServiceException)
            {
                exceptionThrown = true;
            }
            

            // Assert
            Assert.IsTrue(exceptionThrown);
        }