示例#1
0
        public void Conv_stringonethousandof1andminus1_numarrayonethousandof1andminus1returned()
        {
            Stopwatch stopWatch = new Stopwatch();

            // arrange
            string x = "";

            int[] expected = new int[1000];
            for (int i = 0; i < 1000; i++)
            {
                x          += (-1 ^ i).ToString() + " ";
                expected[i] = -1 ^ i;
            }
            x = x.Trim();

            // act
            stopWatch.Start();
            int[] actual = Rep.Conv(x);
            stopWatch.Stop();

            // assert
            CollectionAssert.AreEqual(expected, actual);
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                 ts.Hours, ts.Minutes, ts.Seconds,
                                                 ts.Milliseconds / 10);

            Console.WriteLine("RunTime " + elapsedTime);
        }
示例#2
0
        public void Conv_WhenStringContainsRealNumbers_ShouldThrowFormatException()
        {
            Stopwatch stopWatch = new Stopwatch();
            // Arrange
            string x = "1.618";

            // Act and assert
            stopWatch.Start();
            Assert.ThrowsException <FormatException>(() => Rep.Conv(x));
            stopWatch.Stop();
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                 ts.Hours, ts.Minutes, ts.Seconds,
                                                 ts.Milliseconds / 10);

            Console.WriteLine("RunTime " + elapsedTime);
        }
示例#3
0
        public void Conv_string2147483647_numarray2147483647returned()
        {
            Stopwatch stopWatch = new Stopwatch();

            // arrange
            string x = "2147483647";

            int[] expected = { 2147483647 };

            // act
            stopWatch.Start();
            int[] actual = Rep.Conv(x);
            stopWatch.Stop();

            // assert
            CollectionAssert.AreEqual(expected, actual);
            TimeSpan ts          = stopWatch.Elapsed;
            string   elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                 ts.Hours, ts.Minutes, ts.Seconds,
                                                 ts.Milliseconds / 10);

            Console.WriteLine("RunTime " + elapsedTime);
        }