Esempio n. 1
0
        public void TestGetTimeInterval()
        {
            var someIntervals = new System.Collections.Generic.List <string> {
                "10 Seconds",
                "11 Minutes",
                "12 Hours",
                "13 Days",
                "14 Weeks",
                "15 Months"
            };

            var testIntervals = new System.Collections.Generic.List <string> {
                "Seconds",
                "Minutes",
                "Hours",
                "Days",
                "Weeks",
                "Months"
            };

            var parser = new RfiCoder.Utilities.Parser();

            for (int i = 0; i < 6; i++)
            {
                var result = parser.GetTimeInterval(someIntervals[i]);

                switch (testIntervals[i])
                {
                case "Seconds":
                    Assert.That(result.ContainsKey(RfiCoder.Enum.TimeInterval.Seconds), Is.True);

                    Assert.That(result[RfiCoder.Enum.TimeInterval.Seconds], Is.EqualTo(10));

                    break;

                case "Minutes":
                    Assert.That(result.ContainsKey(RfiCoder.Enum.TimeInterval.Minutes), Is.True);

                    Assert.That(result[RfiCoder.Enum.TimeInterval.Minutes], Is.EqualTo(11));

                    break;

                case "Hours":
                    Assert.That(result.ContainsKey(RfiCoder.Enum.TimeInterval.Hours), Is.True);

                    Assert.That(result[RfiCoder.Enum.TimeInterval.Hours], Is.EqualTo(12));

                    break;

                case "Days":
                    Assert.That(result.ContainsKey(RfiCoder.Enum.TimeInterval.Days), Is.True);

                    Assert.That(result[RfiCoder.Enum.TimeInterval.Days], Is.EqualTo(13));

                    break;

                case "Weeks":
                    Assert.That(result.ContainsKey(RfiCoder.Enum.TimeInterval.Weeks), Is.True);

                    Assert.That(result[RfiCoder.Enum.TimeInterval.Weeks], Is.EqualTo(14));

                    break;

                case "Months":
                    Assert.That(result.ContainsKey(RfiCoder.Enum.TimeInterval.Months), Is.True);

                    Assert.That(result[RfiCoder.Enum.TimeInterval.Months], Is.EqualTo(15));

                    break;

                default:
                    throw new ArgumentException("failed to parse interval");

                    // break;
                }
            }
        }