Esempio n. 1
0
        public void Test_UpdateSituationWhenSituationEnteredExistInDatabaseAndDoesNOTContainsOnlyLetters_SituationDescriptionNOTUpdated()
        {
            //Arrange
            IRepository <Situation> _situationContext = new MockTruckCheckUpContext <Situation>();
            IValidateUserInput      _validate         = new ValidateUserInput();
            ILogger           _logger           = new MockTruckCheckUpLogger();
            ISituationService _situationService = new SituationService(_situationContext, _logger, _validate);

            //Populate table, so we can test whether there is data available
            _situationContext.Insert(new Situation()
            {
                Id = "1", CreationDate = DateTimeOffset.Now, Description = "InProgress", Status = true
            });
            _situationContext.Insert(new Situation()
            {
                Id = "2", CreationDate = DateTimeOffset.Now, Description = "Open", Status = true
            });
            //Act
            _situationService.EvaluateSituationDescriptionBeforeUpdating(new SituationViewModel()
            {
                Id = "1", Description = "Open88", Status = true, ExistInDB = true, IsValid = true
            });
            var result = _situationService.RetrieveSituationById("1");

            //Assert
            Assert.AreEqual("InProgress", result.Description);
        }
Esempio n. 2
0
        public void Test_RetrieveSituationRecordByIdWhenSearchingForNonExistentId_ReturnsNullSituationViewModelObject()
        {
            //Arrange
            IRepository <Situation> _situationContext = new MockTruckCheckUpContext <Situation>();
            ILogger            _logger            = new MockTruckCheckUpLogger();
            IValidateUserInput _validateUserInput = new ValidateUserInput();
            ISituationService  _situationService  = new SituationService(_situationContext, _logger, _validateUserInput);

            //Populate table, so we can test whether the method is returning the right record
            _situationContext.Insert(new Situation()
            {
                Id = "1", CreationDate = DateTimeOffset.Now, Description = "InProgress", Status = true
            });
            _situationContext.Insert(new Situation()
            {
                Id = "2", CreationDate = DateTimeOffset.Now, Description = "Open", Status = true
            });
            //Act
            var result = _situationService.RetrieveSituationById("3");

            //Assert
            Assert.AreEqual(null, result.Description);
        }