Example #1
0
        public async void VehicleTripUpdate()
        {
            // Arrange
            this.FleetDbContext.VehicleTrips.AddRange(
                new VehicleTripEntity()
            {
                VehicleTripId = 1, VehicleId = 1, OdometerStart = 100, StartingTime = new DateTime(2016, 1, 1)
            },
                new VehicleTripEntity()
            {
                VehicleTripId = 2, VehicleId = 1, OdometerStart = 200, StartingTime = new DateTime(2016, 1, 15)
            },
                new VehicleTripEntity()
            {
                VehicleTripId = 3, VehicleId = 2, OdometerStart = 100, StartingTime = new DateTime(2016, 1, 1)
            });

            await this.SaveChangesAsync(this.FleetDbContext);

            VehicleTripModel model = new VehicleTripModel()
            {
                VehicleTripId = 2, VehicleId = 1, OdometerStart = 250, StartingTime = new DateTime(2016, 1, 15)
            };

            // Act
            AjaxModel <NTModel> ajaxModel = await this.Controller.VehicleTripUpdate(model);

            // Assert
            VehicleTripEntity entity = await this.FleetDbContext.VehicleTrips.LastAsync(m => m.VehicleTripId == 2);

            Assert.Equal(entity.OdometerStart, 250);
            Assert.Equal(ajaxModel.Message, FleetMessages.VehicleTripSaveSuccess);
        }
Example #2
0
        public async void VehicleTripAdd()
        {
            // Arrange
            VehicleTripModel model = new VehicleTripModel()
            {
                VehicleTripId = 0, VehicleId = 1, OdometerStart = 100, StartingTime = new DateTime(2016, 1, 1)
            };

            // Act
            AjaxModel <NTModel> ajaxModel = await this.Controller.VehicleTripAdd(model);

            // Assert
            VehicleTripEntity entity = await this.FleetDbContext.VehicleTrips.LastAsync();

            Assert.Equal(entity.OdometerStart, 100);
            Assert.Equal(ajaxModel.Message, FleetMessages.VehicleTripSaveSuccess);
        }