public async Task EditAsync_ShouldSuccessfullyEdit()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            await this.SeedDataAsync(context);

            var truckService          = new TruckService(context);
            var editTruckServiceModel = new EditTruckServiceModel();
            var truckId = 1;
            var truckRegistrationNumber = "FN 3";

            editTruckServiceModel.Id = truckId;
            editTruckServiceModel.RegistrationNumber = truckRegistrationNumber;

            await truckService.EditAsync(editTruckServiceModel);

            var expectedResult = truckRegistrationNumber;
            var actualResult   = truckService
                                 .All()
                                 .First()
                                 .RegistrationNumber;

            Assert.True(expectedResult == actualResult);
        }
        public async Task EditAsync_WithNonExistingIdShouldThrowArgumentNullException()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            await this.SeedDataAsync(context);

            var truckService          = new TruckService(context);
            var editTruckServiceModel = new EditTruckServiceModel();

            editTruckServiceModel.Id = 3;

            await Assert.ThrowsAsync <ArgumentNullException>(async() =>
            {
                await truckService.EditAsync(editTruckServiceModel);
            });
        }
        public async Task EditAsync_WithOverMaxNameLengthShouldThrowInvalidOperationException()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            await this.SeedDataAsync(context);

            var truckService            = new TruckService(context);
            var editTruckServiceModel   = new EditTruckServiceModel();
            var truckRegistrationNumber = "qwertyuiop qwertyuiop qwertyuiop qwertyuiop qwertyuiop";

            editTruckServiceModel.RegistrationNumber = truckRegistrationNumber;
            editTruckServiceModel.Id = 1;
            var message = "Truck's Registration number cannot be more than 8 characters.";

            var exception = await Assert.ThrowsAsync <InvalidOperationException>(async() =>
            {
                await truckService.EditAsync(editTruckServiceModel);
            });

            Assert.Equal(message, exception.Message);
        }
        public async Task EditAsync_WithExistingNameShouldThrowInvalidOperationException()
        {
            MapperInitializer.InitializeMapper();
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            await this.SeedDataAsync(context);

            var truckService            = new TruckService(context);
            var editTruckServiceModel   = new EditTruckServiceModel();
            var truckregistrationNumber = "TRN 2";

            editTruckServiceModel.RegistrationNumber = truckregistrationNumber;
            editTruckServiceModel.Id = 1;
            var message = "Truck's Registration number already exists.";

            var exception = await Assert.ThrowsAsync <InvalidOperationException>(async() =>
            {
                await truckService.EditAsync(editTruckServiceModel);
            });

            Assert.Equal(message, exception.Message);
        }