Пример #1
0
        public OutputFileHelper(string outputDirectory, ISystemFactory systemFactory)
        {
            if (systemFactory == null)
            {
                throw new ArgumentNullException(nameof(systemFactory));
            }

            _dateTime = systemFactory.CreateSystemDateTime();
            if (_dateTime == null)
            {
                throw new InvalidOperationException($"Expected {nameof(_dateTime)} not to be null");
            }

            var environment = systemFactory.CreateSystemEnvironment();

            if (environment == null)
            {
                throw new InvalidOperationException($"Expected {nameof(environment)} not to be null");
            }

            var directory = systemFactory.CreateSystemIODirectory();

            if (directory == null)
            {
                throw new InvalidOperationException($"Expected {nameof(directory)} not to be null");
            }

            if (!string.IsNullOrWhiteSpace(outputDirectory))
            {
                VerifyPathOrThrow(outputDirectory);
                _outputDirectory = outputDirectory;
            }
            else
            {
                _outputDirectory = Path.Combine(environment.CurrentDirectory, DefaultOutputDirectoryName);
            }

            if (!directory.Exists(_outputDirectory))
            {
                directory.CreateDirectory(_outputDirectory);
            }
        }