Ejemplo n.º 1
0
        public void ValidateClashExceptionOverlapsWithExistingClashExceptions(
            IEnumerable <ClashException> givenExceptions,
            int offsetHours,
            IEnumerable <ClashException> existingExceptions,
            CustomValidationResult expectedResult
            )
        {
            var result =
                _clashExceptionValidations.ValidateTimeRanges(givenExceptions, offsetHours, existingExceptions);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(result.Successful, expectedResult.Successful);
                Assert.AreEqual(result.Message, expectedResult.Message);
            });
        }
Ejemplo n.º 2
0
        private void ValidateForSave(List <ClashException> incomingClashExceptions)
        {
            foreach (var clashException in incomingClashExceptions)
            {
                var structureRulesViolationValidationResult = _clashExceptionValidations.ValidateClashExceptionForSameStructureRulesViolation(clashException);
                if (!structureRulesViolationValidationResult.Successful)
                {
                    throw new DataSyncException(DataSyncErrorCode.ClashException_StructureRulesViolation, structureRulesViolationValidationResult.Message);
                }
            }

            const int offsetHours             = 6;
            var       existingClashExceptions = _clashExceptionRepository.GetActive().ToList();

            var timeRangesValidationResult = _clashExceptionValidations.ValidateTimeRanges(incomingClashExceptions, offsetHours, existingClashExceptions);

            if (!timeRangesValidationResult.Successful)
            {
                throw new DataSyncException(DataSyncErrorCode.ClashException_TimeRangesOverlap, timeRangesValidationResult.Message);
            }
        }