/ src / modules / imageresizer / tests / Views / TimeRemainingConverterTests.cs
TimeRemainingConverterTests.cs
 1  #pragma warning disable IDE0073
 2  // Copyright (c) Brice Lambson
 3  // The Brice Lambson licenses this file to you under the MIT license.
 4  // See the LICENSE file in the project root for more information.  Code forked from Brice Lambson's https://github.com/bricelam/ImageResizer/
 5  #pragma warning restore IDE0073
 6  
 7  using System;
 8  using System.Globalization;
 9  
10  using ImageResizer.Properties;
11  using Microsoft.VisualStudio.TestTools.UnitTesting;
12  
13  namespace ImageResizer.Views
14  {
15      public class TimeRemainingConverterTests
16      {
17          [DataTestMethod]
18          [DataRow("HourMinute", 1, 1, 0)]
19          [DataRow("HourMinutes", 1, 2, 0)]
20          [DataRow("HoursMinute", 2, 1, 0)]
21          [DataRow("HoursMinutes", 2, 2, 0)]
22          [DataRow("MinuteSecond", 0, 1, 1)]
23          [DataRow("MinuteSeconds", 0, 1, 2)]
24          [DataRow("MinutesSecond", 0, 2, 1)]
25          [DataRow("MinutesSeconds", 0, 2, 2)]
26          [DataRow("Second", 0, 0, 1)]
27          [DataRow("Seconds", 0, 0, 2)]
28          public void ConvertWorks(string resource, int hours, int minutes, int seconds)
29          {
30              var timeRemaining = new TimeSpan(hours, minutes, seconds);
31              var converter = new TimeRemainingConverter();
32  
33              // Using InvariantCulture since these are internal
34              var result = converter.Convert(
35                  timeRemaining,
36                  targetType: null,
37                  parameter: null,
38                  CultureInfo.InvariantCulture);
39  
40              Assert.AreEqual(
41                  string.Format(
42                      CultureInfo.InvariantCulture,
43                      Resources.ResourceManager.GetString("Progress_TimeRemaining_" + resource, CultureInfo.InvariantCulture),
44                      hours,
45                      minutes,
46                      seconds),
47                  result);
48          }
49      }
50  }