Ejemplo n.º 1
0
        public void Test_DeleteManufacturerFromDB_ManufacturerDeleted()
        {
            //Arrange
            IRepository <TruckManufacturer> _truckManufacturerContext = new Mocks.MockTruckCheckUpContext <TruckManufacturer>();
            ILogger _logger = new MockTruckCheckUpLogger();
            TruckManufacturerService truckManufacturerService = new TruckManufacturerService(_truckManufacturerContext, _logger);

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

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

            var manufacturer = new TruckManufacturerViewModel();

            manufacturer.Description = "Chevrolet";

            var manufacturerToDelete = truckManufacturerService.SearchTruckManufacturer(manufacturer);

            //Act
            truckManufacturerService.ValidateTruckManufacturerToDelete(manufacturerToDelete.Id);
            _logger.Info("Test-DeleteManufacturerFromDB-ManufacturerDeleted");
            var result = truckManufacturerService.SearchTruckManufacturer(manufacturer);

            //Assert
            Assert.AreEqual(false, result.ExistInDB);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        public void Test_SearchForManufacturerInDB_ManufacturerDoesNotExist()
        {
            //Arrange
            IRepository <TruckManufacturer> _truckManufacturerContext = new MockTruckCheckUpContext <TruckManufacturer>();
            ILogger _logger = new MockTruckCheckUpLogger();
            TruckManufacturerService truckManufacturerService = new TruckManufacturerService(_truckManufacturerContext, _logger);

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

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

            //Act
            var manufacturer = new TruckManufacturerViewModel();

            manufacturer.Description = "Toyota";

            var result = truckManufacturerService.SearchTruckManufacturer(manufacturer);

            _logger.Info("Test-SearchForManufacturerInDB-ManufacturerDoesNotExist");
            //Assert
            Assert.AreEqual(false, result.ExistInDB);
        }
Ejemplo n.º 4
0
        public void Test_RetrieveTruckManufacturers_ZeroRecords()
        {
            //Arrange
            IRepository <TruckManufacturer> _truckManufacturerContext = new MockTruckCheckUpContext <TruckManufacturer>();
            ILogger _logger = new MockTruckCheckUpLogger();
            TruckManufacturerService truckManufacturerService = new TruckManufacturerService(_truckManufacturerContext, _logger);
            //Act
            var result = truckManufacturerService.RetrieveAllTruckManufacturers();

            _logger.Info("Test-RetrieveTruckManufacturers-ZeroRecords");
            //Assert
            Assert.AreEqual(0, result.Count);
        }
Ejemplo n.º 5
0
        public void Test_RetrieveTruckManufacturers_AllRecords()
        {
            //Arrange
            IRepository <TruckManufacturer> _truckManufacturerContext = new MockTruckCheckUpContext <TruckManufacturer>();
            ILogger _logger = new MockTruckCheckUpLogger();

            //Add couple records to truck manufacturer mock class
            _truckManufacturerContext.Insert(new TruckManufacturer()
            {
                Id = "1", ManufacturerDescription = "Isuzu"
            });
            _truckManufacturerContext.Insert(new TruckManufacturer()
            {
                Id = "2", ManufacturerDescription = "Ford"
            });
            TruckManufacturerService truckManufacturerService = new TruckManufacturerService(_truckManufacturerContext, _logger);
            //Act
            var result = truckManufacturerService.RetrieveAllTruckManufacturers();

            _logger.Info("Test-RetrieveTruckManufacturers-AllRecords");
            //Assert
            Assert.AreEqual(2, result.Count);
        }