public void Evaluating_equals_throws_an_exception_if_the_left_Thumbnail_is_null()
        {
            Type   expected = typeof(NullReferenceException);
            string fullSize = "fullSize";

            ImagePairNames left  = new ImagePairNames(fullSize, null);
            ImagePairNames right = new ImagePairNames();

            try
            {
                bool result = left == right;
            }
            catch (Exception e)
            {
                Assert.AreEqual(expected, e.GetType());
            }

            try
            {
                bool result = left != right;
            }
            catch (Exception e)
            {
                Assert.AreEqual(expected, e.GetType());
            }

            try
            {
                bool result = left.Equals(right);
            }
            catch (Exception e)
            {
                Assert.AreEqual(expected, e.GetType());
            }
        }
        public void Evaluating_equals_throws_an_exception_if_the_object_is_not_an_ImagePairNames()
        {
            ImagePairNames pair = new ImagePairNames();
            object         obj  = new object();

            Assert.Throws <InvalidCastException>(() => pair.Equals(obj));
        }
예제 #3
0
        public void Evaluating_equals_throws_an_exception_if_the_object_is_not_an_ImagePairNames()
        {
            ImagePairNames pair = new ImagePairNames();
            object         obj  = new object();

            pair.Equals(obj);
        }
        public void GetHashCode_throws_an_exception_if_Thumbnail_is_null()
        {
            string fullSize = "fullSize";

            ImagePairNames pair = new ImagePairNames(fullSize, null);

            Assert.Throws <NullReferenceException>(() => pair.GetHashCode());
        }
        public void GetHashCode_throws_an_exception_if_FullSize_is_null()
        {
            string thumbnail = "thumbnail";

            ImagePairNames pair = new ImagePairNames(null, thumbnail);

            Assert.Throws <NullReferenceException>(() => pair.GetHashCode());
        }
        public void GetHashCode_is_the_combined_HashCode_of_FullSize_and_Thumbnail()
        {
            string fullSize  = "fullSize";
            string thumbnail = "thumbnail";
            int    expected  = fullSize.GetHashCode() + thumbnail.GetHashCode();

            ImagePairNames pair = new ImagePairNames(fullSize, thumbnail);

            Assert.AreEqual(expected, pair.GetHashCode());
        }
예제 #7
0
        public void GetHashCode_throws_an_exception_if_FullSize_is_null()
        {
            string thumbnail = "thumbnail";

            ImagePairNames pair = new ImagePairNames();

            pair.Thumbnail = thumbnail;

            pair.GetHashCode();
        }
예제 #8
0
        public void Constructor_parameters_are_not_altered()
        {
            string fullSize = "fullSize";
            string thumbnail = "thumbnail";

            ImagePairNames pair = new ImagePairNames(fullSize, thumbnail);

            Assert.AreEqual(fullSize, pair.FullSize);
            Assert.AreEqual(thumbnail, pair.Thumbnail);
        }
예제 #9
0
        public void GetHashCode_throws_an_exception_if_Thumbnail_is_null()
        {
            string fullSize = "fullSize";

            ImagePairNames pair = new ImagePairNames();

            pair.FullSize = fullSize;

            pair.GetHashCode();
        }
예제 #10
0
        public void Constructor_parameters_are_not_altered()
        {
            string fullSize  = "fullSize";
            string thumbnail = "thumbnail";

            ImagePairNames pair = new ImagePairNames(fullSize, thumbnail);

            Assert.AreEqual(fullSize, pair.FullSize);
            Assert.AreEqual(thumbnail, pair.Thumbnail);
        }
예제 #11
0
        public void Two_ImagePairNames_are_not_equal_if_FullSize_differs()
        {
            string thumbnail = "thumbnail";

            ImagePairNames left  = new ImagePairNames("left", thumbnail);
            ImagePairNames right = new ImagePairNames("right", thumbnail);

            Assert.IsFalse(left == right);
            Assert.IsTrue(left != right);
            Assert.IsFalse(left.Equals(right));
        }
예제 #12
0
        public void Two_ImagePairNames_are_not_equal_if_Thumbnail_differs()
        {
            string fullSize = "fullSize";

            ImagePairNames left  = new ImagePairNames(fullSize, "left");
            ImagePairNames right = new ImagePairNames(fullSize, "right");

            Assert.IsFalse(left == right);
            Assert.IsTrue(left != right);
            Assert.IsFalse(left.Equals(right));
        }
예제 #13
0
        public void Two_ImagePairNames_are_equal_if_FullSize_and_Thumbnail_match()
        {
            string fullSize  = "fullSize";
            string thumbnail = "thumbnail";

            ImagePairNames left  = new ImagePairNames(fullSize, thumbnail);
            ImagePairNames right = new ImagePairNames(fullSize, thumbnail);

            Assert.IsTrue(left == right);
            Assert.IsFalse(left != right);
            Assert.IsTrue(left.Equals(right));
        }
예제 #14
0
        public ImagePairNames Parse(string extension)
        {
            fileExtension = extension;
            string fullImageTemplate = GetFullImageTemplate();
            string thumbImageTemplate = GetThumbImageTemplate();

            ImagePairNames names = new
                ImagePairNames(fullImageTemplate, thumbImageTemplate);

            names = TryAddTemplateDateOrTime(names);
            names = TryAddTemplateExtension(names);
            names = TryAddTemplateUser(names);
            names = TryAddTemplateDomain(names);
            names = TryAddTemplateMachine(names);
            names = SetFileExtension(names);
            names = SetFullPath(names);
            names = TryAddTemplatePrompt(names);
            names = GetNextImagePairNames(names);
            return names;
        }
예제 #15
0
 private static ImagePairNames TryAddTemplatePrompt(ImagePairNames startNames)
 {
     if (startNames.FullSize.IndexOf(Templates.Prompt) >= 0 || startNames.Thumbnail.IndexOf(Templates.Prompt) >= 0)
     {
         Prompt prompt = new Prompt();
         prompt.TopMost = true;
         prompt.StartPosition = FormStartPosition.CenterParent;
         if (prompt.ShowDialog(Configuration.Current.ActiveCropWindow) == DialogResult.OK)
         {
             startNames.FullSize = startNames.FullSize.Replace(Templates.Prompt, prompt.Value);
             startNames.Thumbnail = startNames.Thumbnail.Replace(Templates.Prompt, prompt.Value);
         }
         else
         {
             startNames.FullSize = startNames.FullSize.Replace(Templates.Prompt, string.Empty);
             startNames.Thumbnail = startNames.Thumbnail.Replace(Templates.Prompt, String.Empty);
         }
     }
     return startNames;
 }
예제 #16
0
		private static ImagePairNames TryAddTemplateMachine(ImagePairNames startNames)
		{
			startNames.FullSize = startNames.FullSize.Replace(Templates.Machine, Environment.MachineName);
			startNames.Thumbnail = startNames.Thumbnail.Replace(Templates.Machine, Environment.MachineName);
			return startNames;
		}
예제 #17
0
		private static ImagePairNames TryAddTemplateDomain(ImagePairNames startNames)
		{
			startNames.FullSize = startNames.FullSize.Replace(Templates.Domain, Environment.UserDomainName);
			startNames.Thumbnail = startNames.Thumbnail.Replace(Templates.Domain, Environment.UserDomainName);
			return startNames;
		}
예제 #18
0
		private ImagePairNames TryAddTemplateExtension(ImagePairNames startNames)
		{
			startNames.FullSize = startNames.FullSize.Replace(Templates.Extension, fileExtension);
			startNames.Thumbnail = startNames.Thumbnail.Replace(Templates.Extension, fileExtension);
			return startNames;
		}
예제 #19
0
        public void Evaluating_equals_throws_an_exception_if_the_object_is_not_an_ImagePairNames()
        {
            ImagePairNames pair = new ImagePairNames();
            object obj = new object();

            pair.Equals(obj);
        }
예제 #20
0
        public void GetHashCode_is_the_combined_HashCode_of_FullSize_and_Thumbnail()
        {
            string fullSize = "fullSize";
            string thumbnail = "thumbnail";
            int expected = fullSize.GetHashCode() + thumbnail.GetHashCode();

            ImagePairNames pair = new ImagePairNames(fullSize, thumbnail);

            Assert.AreEqual(expected, pair.GetHashCode());
        }
예제 #21
0
        public void Two_ImagePairNames_are_not_equal_if_Thumbnail_differs()
        {
            string fullSize = "fullSize";

            ImagePairNames left = new ImagePairNames(fullSize, "left");
            ImagePairNames right = new ImagePairNames(fullSize, "right");

            Assert.IsFalse(left == right);
            Assert.IsTrue(left != right);
            Assert.IsFalse(left.Equals(right));
        }
예제 #22
0
        public void Evaluating_equals_throws_an_exception_if_the_left_FullSize_is_null()
        {
            Type expected = typeof(NullReferenceException);
            string thumbnail = "thumbnail";

            ImagePairNames left = new ImagePairNames();
            left.Thumbnail = thumbnail;
            ImagePairNames right = new ImagePairNames();

            try
            {
                bool result = left == right;
            }
            catch (Exception e)
            {
                Assert.AreEqual(expected, e.GetType());
            }

            try
            {
                bool result = left != right;
            }
            catch (Exception e)
            {
                Assert.AreEqual(expected, e.GetType());
            }

            try
            {
                bool result = left.Equals(right);
            }
            catch (Exception e)
            {
                Assert.AreEqual(expected, e.GetType());
            }
        }
예제 #23
0
        public void Two_ImagePairNames_are_not_equal_if_FullSize_differs()
        {
            string thumbnail = "thumbnail";

            ImagePairNames left = new ImagePairNames("left", thumbnail);
            ImagePairNames right = new ImagePairNames("right", thumbnail);

            Assert.IsFalse(left == right);
            Assert.IsTrue(left != right);
            Assert.IsFalse(left.Equals(right));
        }
예제 #24
0
		private static ImagePairNames SetFullPath(ImagePairNames names)
		{
			names.FullSize = Path.Combine(Configuration.Current.OutputPath, names.FullSize);
			names.Thumbnail = Path.Combine(Configuration.Current.OutputPath, names.Thumbnail);
			return names;
		}
예제 #25
0
		private static ImagePairNames TryAddTemplateDateOrTime(ImagePairNames startNames)
		{
			var now = DateTime.Now;

			startNames.FullSize = startNames.FullSize.Replace(Templates.Date, now.ToString("MM-dd-yyyy"));
			startNames.Thumbnail = startNames.Thumbnail.Replace(Templates.Date, now.ToString("MM-dd-yyyy"));

			startNames.FullSize = startNames.FullSize.Replace(Templates.Time, now.ToString("hh-mm-ss tt"));
			startNames.Thumbnail = startNames.Thumbnail.Replace(Templates.Time, now.ToString("hh-mm-ss tt"));

			startNames.FullSize = startNames.FullSize.Replace(Templates.Timestamp, now.ToString("yyyy-MM-dd-HH-mm-ss-fffffff"));
			startNames.Thumbnail = startNames.Thumbnail.Replace(Templates.Timestamp, now.ToString("yyyy-MM-dd-HH-mm-ss-fffffff"));

			return startNames;
		}
예제 #26
0
        public void GetHashCode_throws_an_exception_if_Thumbnail_is_null()
        {
            string fullSize = "fullSize";

            ImagePairNames pair = new ImagePairNames();
            pair.FullSize = fullSize;

            pair.GetHashCode();
        }
예제 #27
0
        public override bool Equals(object obj)
        {
            ImagePairNames imagePair = (ImagePairNames)obj;

            return(this == imagePair);
        }
예제 #28
0
		private ImagePairNames SetFileExtension(ImagePairNames names)
		{
			names.FullSize = String.Format("{0}.{1}", names.FullSize, fileExtension);
			names.Thumbnail = String.Format("{0}.{1}", names.Thumbnail, fileExtension);
			return names;
		}
예제 #29
0
        public void GetHashCode_throws_an_exception_if_FullSize_is_null()
        {
            string thumbnail = "thumbnail";

            ImagePairNames pair = new ImagePairNames();
            pair.Thumbnail = thumbnail;

            pair.GetHashCode();
        }
예제 #30
0
		private ImagePairNames GetNextImagePairNames(ImagePairNames startNames)
		{
			if (!Directory.Exists(Path.GetDirectoryName(startNames.FullSize)))
				Directory.CreateDirectory(Path.GetDirectoryName(startNames.FullSize));

			if (!Directory.Exists(Path.GetDirectoryName(startNames.Thumbnail)))
				Directory.CreateDirectory(
					Path.GetDirectoryName(startNames.Thumbnail));

			string fullTemplate = startNames.FullSize;
			string thumbTemplate = startNames.Thumbnail;

			startNames.FullSize = fullTemplate.Replace(Templates.Increment, lastIncrement.ToString());
			startNames.Thumbnail = thumbTemplate.Replace(Templates.Increment, lastIncrement.ToString());

			if (!File.Exists(startNames.FullSize) && !File.Exists(startNames.Thumbnail))
			{
				ResetIncrement();
				startNames.FullSize = fullTemplate.Replace(Templates.Increment, lastIncrement.ToString());
				startNames.Thumbnail = thumbTemplate.Replace(Templates.Increment, lastIncrement.ToString());
			}

			while (File.Exists(startNames.FullSize) || File.Exists(startNames.Thumbnail))
			{
				lastIncrement++;

				if (fullTemplate.IndexOf(Templates.Increment) < 0)
					fullTemplate = fullTemplate.Insert(fullTemplate.LastIndexOf('.'), " [" + Templates.Increment + "]");
				if (thumbTemplate.IndexOf(Templates.Increment) < 0)
					thumbTemplate = thumbTemplate.Insert(thumbTemplate.LastIndexOf('.'), " [" + Templates.Increment + "]");

				startNames.FullSize = fullTemplate.Replace(Templates.Increment, lastIncrement.ToString());
				startNames.Thumbnail = thumbTemplate.Replace(Templates.Increment, lastIncrement.ToString());
			}

			return startNames;
		}
예제 #31
0
        public void Two_ImagePairNames_are_equal_if_FullSize_and_Thumbnail_match()
        {
            string fullSize = "fullSize";
            string thumbnail = "thumbnail";

            ImagePairNames left = new ImagePairNames(fullSize, thumbnail);
            ImagePairNames right = new ImagePairNames(fullSize, thumbnail);

            Assert.IsTrue(left == right);
            Assert.IsFalse(left != right);
            Assert.IsTrue(left.Equals(right));
        }