Пример #1
0
        public void ToString_Shows_Values(
            bool quietOption,
            bool recurseOption,
            bool scanOption,
            IgnoreFlags ignoreFlags,
            GroupStrategy groupStrategy,
            TargetFilenameStrategy targetFilenameStrategy)
        {
            if (quietOption)
            {
                return;
            }

            // arrange
            var src = Guid.NewGuid().ToString();
            var tgt = Guid.NewGuid().ToString();

            var newName = targetFilenameStrategy == TargetFilenameStrategy.New
                ? "NewImage" : null;

            // arrange and act
            var options = new Options(
                recurseOption,
                false,
                scanOption,
                ignoreFlags,
                groupStrategy,
                targetFilenameStrategy,
                newName,
                src,
                tgt);

            // act
            var text = options.ToString();

            var lines = text.Split(
                new []
            {
                '\r',
                '\n'
            });
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Options"/> class.
        /// </summary>
        /// <param name="directoryOnly">The recurse subdirectories option.</param>
        /// <param name="quietMode">The quiet mode option.</param>
        /// <param name="scanOnly">The scan only option.</param>
        /// <param name="ignoreFlags">The ignore flags option.</param>
        /// <param name="groupStrategy">The grouping strategy option.</param>
        /// <param name="targetFilenameStrategy">The filename renaming strategy option.</param>
        /// <param name="newFilename">Name of the new file.</param>
        /// <param name="sourceDirectory">The source (Stellina USB drive) directory.</param>
        /// <param name="targetDirectory">The target directory.</param>
        public Options(
            bool directoryOnly,
            bool quietMode,
            bool scanOnly,
            IgnoreFlags ignoreFlags,
            GroupStrategy groupStrategy,
            TargetFilenameStrategy targetFilenameStrategy,
            string newFilename,
            string sourceDirectory,
            string targetDirectory)
        {
            if (!string.IsNullOrWhiteSpace(newFilename) &&
                targetFilenameStrategy != TargetFilenameStrategy.New)
            {
                throw new InvalidOperationException("New filename option is only valid when target filename strategy is set to 'New'.");
            }

            if (targetFilenameStrategy == TargetFilenameStrategy.New &&
                string.IsNullOrWhiteSpace(newFilename))
            {
                throw new InvalidOperationException("You must specify a new filename using the '-n' or '--new-filename' option when target filename strategy is set to 'New'.");
            }

            if (((int)ignoreFlags & (int)IgnoreFlags.Nothing) > 0 &&
                ignoreFlags != IgnoreFlags.Nothing)
            {
                throw new InvalidOperationException("Cannot use other ignores with 'Nothing'.");
            }

            DirectoryOnly          = directoryOnly;
            QuietMode              = quietMode;
            ScanOnly               = scanOnly;
            Ignore                 = ignoreFlags;
            GroupStrategy          = groupStrategy;
            TargetFilenameStrategy = targetFilenameStrategy;
            NewFilename            = newFilename;
            SourceDirectory        = sourceDirectory;
            TargetDirectory        = targetDirectory;
        }
Пример #3
0
        public void Constructor_Sets_Values(
            bool quietMode,
            bool recurseOption,
            bool scanOption,
            IgnoreFlags ignoreFlags,
            GroupStrategy groupStrategy,
            TargetFilenameStrategy targetFilenameStrategy)
        {
            var src = Guid.NewGuid().ToString();
            var tgt = Guid.NewGuid().ToString();

            var newName = targetFilenameStrategy == TargetFilenameStrategy.New
                ? "NewImage" : null;

            // arrange and act
            var options = new Options(
                recurseOption,
                quietMode,
                scanOption,
                ignoreFlags,
                groupStrategy,
                targetFilenameStrategy,
                newName,
                src,
                tgt);

            // assert
            Assert.Equal(recurseOption, options.DirectoryOnly);
            Assert.Equal(quietMode, options.QuietMode);
            Assert.Equal(scanOption, options.ScanOnly);
            Assert.Equal(ignoreFlags, options.Ignore);
            Assert.Equal(groupStrategy, options.GroupStrategy);
            Assert.Equal(targetFilenameStrategy, options.TargetFilenameStrategy);
            Assert.Equal(newName, options.NewFilename);
            Assert.Equal(src, options.SourceDirectory);
            Assert.Equal(tgt, options.TargetDirectory);
        }
Пример #4
0
		public IgnoreStatus(JObject j) {
			Ignored = j["isIgnored"].Value<bool>();
			Flags = (IgnoreFlags)j["ignoreFlags"].Value<int>();
		}
Пример #5
0
 /// <summary>
 /// Determine whether a flag is set.
 /// </summary>
 /// <param name="flag">The flag to check.</param>
 /// <returns>A value indicating whether the flag is set.</returns>
 public bool HasIgnoreFlag(IgnoreFlags flag) =>
 ((int)flag & (int)Ignore) > 0;
Пример #6
0
 private static Options GetOptions(IgnoreFlags ignoreFlags) =>
Пример #7
0
 public IgnoreStatus(JObject j)
 {
     Ignored = j["isIgnored"].Value <bool>();
     Flags   = (IgnoreFlags)j["ignoreFlags"].Value <int>();
 }