Esempio n. 1
0
        public void WhenCanAddReminderWithInvalidDueDistance_ThenReturnsValidationResult()
        {
            var vehicle1 = new Vehicle
            {
                VehicleId = DefaultVehicleId,
                Name      = "vehicle1",
                Fillups   = new[] { new FillupEntry {
                                        Odometer = 7000
                                    } }
            };

            _vehicleRepositoryMock
            .Setup(vr => vr.GetVehicle(DefaultUserId, DefaultVehicleId))
            .Returns(vehicle1);

            var handler = new CanAddReminder(_vehicleRepositoryMock.Object);

            var formModel = new ReminderFormModel {
                VehicleId = DefaultVehicleId, Title = "Test", DueDistance = 5000
            };

            var result = handler.Execute(DefaultUserId, formModel);

            Assert.NotEmpty(result);
        }
Esempio n. 2
0
        public void WhenCanAddReminderWithInvalidVehicleId_ThenReturnsValidationResult()
        {
            const int nonExistentVehicleId = -1;

            _vehicleRepositoryMock
            .Setup(vr => vr.GetVehicle(DefaultUserId, nonExistentVehicleId))
            .Returns((Vehicle)null);

            var handler = new CanAddReminder(_vehicleRepositoryMock.Object);

            var formModel = new ReminderFormModel {
                VehicleId = nonExistentVehicleId, Title = "Test", DueDistance = 20000
            };

            var result = handler.Execute(DefaultUserId, formModel);

            Assert.NotEmpty(result);
        }
Esempio n. 3
0
        public void WhenCanAddReminder_ThenReturnsEmptyCollection()
        {
            var vehicle1 = new Vehicle {
                VehicleId = DefaultVehicleId, Name = "vehicle1"
            };

            _vehicleRepositoryMock
            .Setup(r => r.GetVehicle(DefaultUserId, DefaultVehicleId))
            .Returns(vehicle1);

            var handler = new CanAddReminder(_vehicleRepositoryMock.Object);

            var formModel = new ReminderFormModel {
                VehicleId = DefaultVehicleId, Title = "Test", DueDistance = 20000
            };

            var result = handler.Execute(DefaultUserId, formModel);

            Assert.Empty(result);
        }
 public PostRemindersController(CanAddReminder canAddReminder, AddReminderToVehicle addReminderToVehicle)
 {
     this.addReminderToVehicle = addReminderToVehicle;
     this.canAddReminder       = canAddReminder;
 }