Пример #1
0
        public void Test_ManufacturerDescriptionFieldContainsNotAllowedCharacters_ManufacturerNotUpdated()
        {
            //Arrange
            IRepository <TruckManufacturer> _truckManufacturerContext = new Mocks.MockTruckCheckUpContext <TruckManufacturer>();
            ILogger _logger = new MockTruckCheckUpLogger();
            TruckManufacturerService truckManufacturerService = new TruckManufacturerService(_truckManufacturerContext, _logger);

            truckManufacturerService.ValidateTruckManufacturerToAdd(new TruckManufacturerViewModel()
            {
                Id = "7", Description = "Hyundai"
            });
            //Add record with characters not allowed
            var manufacturerToUpdate = new TruckManufacturerViewModel()
            {
                Id = "7", Description = "Kenw@rth"
            };

            //Act
            if (truckManufacturerService.ValidateManufacturerString(manufacturerToUpdate.Description))
            {
                truckManufacturerService.UpdateTruckManufacturerData(manufacturerToUpdate, new Log4NetLogger());
            }

            var manufacturerUpdated = new TruckManufacturerViewModel();

            manufacturerUpdated.Description = "Hyundai";

            var result = truckManufacturerService.SearchTruckManufacturer(manufacturerUpdated);

            //Assert
            Assert.AreEqual("Hyundai", result.Description);
        }
Пример #2
0
        public void Test_ManufacturerDescriptionFieldEmptyOrNull_NoRecordUpdated()
        {
            //Arrange
            IRepository <TruckManufacturer> _truckManufacturerContext = new Mocks.MockTruckCheckUpContext <TruckManufacturer>();
            ILogger _logger = new MockTruckCheckUpLogger();
            TruckManufacturerService truckManufacturerService = new TruckManufacturerService(_truckManufacturerContext, _logger);

            truckManufacturerService.ValidateTruckManufacturerToAdd(new TruckManufacturerViewModel()
            {
                Description = "Toyota"
            });

            var manufacturer = new TruckManufacturerViewModel();

            manufacturer.Description = "Toyota";
            var manufacturerSearchResult = truckManufacturerService.SearchTruckManufacturer(manufacturer);

            var manufacturerToUpdate = new TruckManufacturerViewModel()
            {
                Id          = manufacturerSearchResult.Id,
                Description = ""
            };

            //Act
            if (!string.IsNullOrEmpty(manufacturerToUpdate.Description))
            {
                truckManufacturerService.UpdateTruckManufacturerData(manufacturerToUpdate, new Log4NetLogger());
                _logger.Info("Test-ManufacturerDescriptionFieldEmptyOrNull-NoRecordUpdated");
            }

            var result = truckManufacturerService.SearchTruckManufacturer(manufacturer);

            //Assert
            Assert.AreEqual("Toyota", result.Description);
        }
Пример #3
0
        public void Test_ManufacturerDescriptionIsNotEmptyOrNullAndContainsOnlyLettersOrNumbersAndDoesNotExistAlreadyInDB_RecordUpdated()
        {
            //Arrange =
            IRepository <TruckManufacturer> _truckManufacturerContext = new Mocks.MockTruckCheckUpContext <TruckManufacturer>();
            ILogger _logger = new MockTruckCheckUpLogger();
            TruckManufacturerService truckManufacturerService = new TruckManufacturerService(_truckManufacturerContext, _logger);

            truckManufacturerService.ValidateTruckManufacturerToAdd(
                new TruckManufacturerViewModel()
            {
                Id = "1", Description = "Chevrolet"
            });

            var manufacturerViewModel = new TruckManufacturerViewModel()
            {
                Id          = "1",
                Description = "Chevrolet"
            };

            var manufacturerSearchResult = truckManufacturerService.SearchTruckManufacturer(manufacturerViewModel);

            var manufacturerToUpdateViewModel = new TruckManufacturerViewModel()
            {
                Id = manufacturerSearchResult.Id, Description = "Chevy"
            };

            if (!string.IsNullOrEmpty(manufacturerToUpdateViewModel.Description))
            {
                if (truckManufacturerService.ValidateManufacturerString(manufacturerToUpdateViewModel.Description))
                {
                    if (!truckManufacturerService.RetrieveTruckManufacturerName(manufacturerToUpdateViewModel.Description))
                    {
                        truckManufacturerService.UpdateTruckManufacturerData(manufacturerToUpdateViewModel, new Log4NetLogger());
                    }
                }
            }

            //Act
            var manufacturerToSearchAfterUpdate = new TruckManufacturerViewModel();

            manufacturerToSearchAfterUpdate.Description = "Chevy";
            var result = truckManufacturerService.SearchTruckManufacturer(manufacturerToSearchAfterUpdate);

            //Assert
            Assert.AreEqual("Chevy", result.Description);
        }