public void LastCheckWasPerformedTooRecentlyToBeRepeated_ReturnsFalse()
        {
            // Arrange
            _configFileHelperStub.PrsErrorCheckFrequency = 10;   // Errors should be checked every 10 minutes
            _configFileHelperStub.TimeLastPrsErrorCheckWasRun = DateTime.Now.AddMinutes(-9);   // Last check was run 9 minutes ago
            DetermineIfPrsErrorActivityShouldBeChecked _checkToolStatus = new DetermineIfPrsErrorActivityShouldBeChecked(_configFileHelperStub, _log);
            bool _shouldCheckBeRun = true;   // Defaulting to the value I'm not expecting

            // Act
            _shouldCheckBeRun = _checkToolStatus.Run();

            // Assert
            Assert.IsFalse(_shouldCheckBeRun, "Date last checked fell within the check frequency so this should return false.");
        }
        public void LastCheckWasPerformedLongEnoughAgoToNeedRepeated_ReturnsTrue()
        {
            // Arrange
            _configFileHelperStub.PrsErrorCheckFrequency = 10;  // Errors should be checked every 10 minutes
            _configFileHelperStub.TimeLastPrsErrorCheckWasRun = DateTime.Now.AddMinutes(-11);  // Last check was run 11 minutes ago
            DetermineIfPrsErrorActivityShouldBeChecked _checkToolStatus = new DetermineIfPrsErrorActivityShouldBeChecked(_configFileHelperStub, _log);
            bool _shouldCheckBeRun = false;

            // Act
            _shouldCheckBeRun = _checkToolStatus.Run();

            // Assert
            Assert.IsTrue(_shouldCheckBeRun, "Date last check was ran exceeded the check frequency so this should return true.");
        }
        public void CheckErrorFrequencyEqualsTwoMinutes_LastTimePrsErrorsCheckedEqualsCurrentDateTime_ReturnsFalse()
        {
            // Arrange
            _configFileHelperStub.PrsErrorCheckFrequency = 2;
            DetermineIfPrsErrorActivityShouldBeChecked _checkToolStatus = new DetermineIfPrsErrorActivityShouldBeChecked(_configFileHelperStub, _log);
            bool _shouldCheckBeRun = true; // Defaulting to the value I'm not expecting
            _configFileHelperStub.TimeLastPrsErrorCheckWasRun = DateTime.Now;

            // Act
            _shouldCheckBeRun = _checkToolStatus.Run();

            // Assert
            Assert.IsFalse(_shouldCheckBeRun);
        }
        public void CheckErrorFrequencyEqualsOneMinute_ReturnsTrue()
        {
            // Arrange
            _configFileHelperStub.PrsErrorCheckFrequency = 1;
            DetermineIfPrsErrorActivityShouldBeChecked _checkToolStatus = new DetermineIfPrsErrorActivityShouldBeChecked(_configFileHelperStub, _log);
            bool _shouldCheckBeRun = false;
            // Found I had to set the following values after noticing the method returned true if I set the frequency to 2.
            // Turns out the default value for _lastTimePrsErrorsWereChecked was old enough to cause the method to return true in the second check
            _configFileHelperStub.TimeLastPrsErrorCheckWasRun = DateTime.Now;

            // Act
            _shouldCheckBeRun = _checkToolStatus.Run();

            // Assert
            Assert.IsTrue(_shouldCheckBeRun, "Check should be run if check frequency equals one minute.");
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            ILogger _log = new Logger();
            ePharmacyEntities _ePharmEntity = new ePharmacyEntities();
            ReportingEntities _reportingEntity = new ReportingEntities();
            Repository _repository = new Repository(_ePharmEntity, _reportingEntity);

            try
            {
                // Check ePharmacy.tbAuditExchangeInbound for any PRS errors that have occured in the previous minute
                RecordPRSErrorActivity _recordPrsErrorActivity = new RecordPRSErrorActivity(_repository, _log);
                _recordPrsErrorActivity.RecordPRSErrorCounts();

                // ConfigFileHelper: Utility class to assist reading from / writing to the config file
                ConfigFileHelper _configFileHelper = new ConfigFileHelper();

                DetermineIfPrsErrorActivityShouldBeChecked _checkToolStatus = new DetermineIfPrsErrorActivityShouldBeChecked(_configFileHelper, _log);
                bool _shouldPrsErrorCheckBeRun = _checkToolStatus.Run();

                CheckPrsErrorLevels _checkPrsErrorLevels = new CheckPrsErrorLevels(_repository, _configFileHelper, _log);
                bool _unavailableErrorLimitExceeded = _checkPrsErrorLevels.PrsUnavailableErrorLevelExceeded();
                bool _timeoutErrorLimitExceeded = _checkPrsErrorLevels.PrsTimeoutErrorLevelExceeded();
                bool _totalErrorLimitExceeded = _checkPrsErrorLevels.PrsTotalErrorLevelExceeded();

                // If either of the bool values are true, then send a warning email
                if (_unavailableErrorLimitExceeded || _timeoutErrorLimitExceeded || _totalErrorLimitExceeded)
                {
                    ReportPrsErrors _reportErrors = new ReportPrsErrors(_log);
                    _reportErrors.SendEmail(_unavailableErrorLimitExceeded, _timeoutErrorLimitExceeded, _totalErrorLimitExceeded);
                }
            }
            catch(Exception ex)
            {
                _log.Add("Error Detected: " + ex.Message + ex.InnerException);
            }
            finally
            {
                _log.Write();
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            ILogger           _log             = new Logger();
            ePharmacyEntities _ePharmEntity    = new ePharmacyEntities();
            ReportingEntities _reportingEntity = new ReportingEntities();
            Repository        _repository      = new Repository(_ePharmEntity, _reportingEntity);

            try
            {
                // Check ePharmacy.tbAuditExchangeInbound for any PRS errors that have occured in the previous minute
                RecordPRSErrorActivity _recordPrsErrorActivity = new RecordPRSErrorActivity(_repository, _log);
                _recordPrsErrorActivity.RecordPRSErrorCounts();

                // ConfigFileHelper: Utility class to assist reading from / writing to the config file
                ConfigFileHelper _configFileHelper = new ConfigFileHelper();

                DetermineIfPrsErrorActivityShouldBeChecked _checkToolStatus = new DetermineIfPrsErrorActivityShouldBeChecked(_configFileHelper, _log);
                bool _shouldPrsErrorCheckBeRun = _checkToolStatus.Run();

                CheckPrsErrorLevels _checkPrsErrorLevels = new CheckPrsErrorLevels(_repository, _configFileHelper, _log);
                bool _unavailableErrorLimitExceeded      = _checkPrsErrorLevels.PrsUnavailableErrorLevelExceeded();
                bool _timeoutErrorLimitExceeded          = _checkPrsErrorLevels.PrsTimeoutErrorLevelExceeded();
                bool _totalErrorLimitExceeded            = _checkPrsErrorLevels.PrsTotalErrorLevelExceeded();

                // If either of the bool values are true, then send a warning email
                if (_unavailableErrorLimitExceeded || _timeoutErrorLimitExceeded || _totalErrorLimitExceeded)
                {
                    ReportPrsErrors _reportErrors = new ReportPrsErrors(_log);
                    _reportErrors.SendEmail(_unavailableErrorLimitExceeded, _timeoutErrorLimitExceeded, _totalErrorLimitExceeded);
                }
            }
            catch (Exception ex)
            {
                _log.Add("Error Detected: " + ex.Message + ex.InnerException);
            }
            finally
            {
                _log.Write();
            }
        }