示例#1
0
文件: Program.cs 项目: Miista/Krav
        private static void DoWarmup()
        {
            var foo = Guid.NewGuid().ToString() + Environment.TickCount.ToString();

            stopwatch.Start();
            while (stopwatch.ElapsedMilliseconds < 2000)
            {
                Require.That(foo, "foo").IsNotNullOrEmpty();
                Require.That(() => foo).IsNotNullOrEmpty();
                RequireThat.NotNullOrEmpty(foo, "foo");
            }

            stopwatch.Stop();
        }
示例#2
0
文件: Program.cs 项目: Miista/Krav
        private static long[] RunSimpleTests()
        {
            Console.WriteLine("Running {0} iterations of {1} simple requirements each.", numberOfIterations, callsPerIteration);
            var results = new long[numberOfIterations];

            for (int i = 0; i < numberOfIterations; i++)
            {
                var foo = Guid.NewGuid().ToString() + Environment.TickCount.ToString();
                stopwatch.Reset();
                stopwatch.Start();
                for (int callCount = 0; callCount < callsPerIteration; callCount++)
                {
                    RequireThat.NotNullOrEmpty(foo, "foo");
                }

                stopwatch.Stop();
                results[i] = stopwatch.ElapsedTicks;
            }

            return(results);
        }
示例#3
0
 public void WhenNotEmptyEnumerable_DoesNotThrow()
 {
     RequireThat.NotNullOrEmpty(Enumerable.Range(1, 1), "name");
 }
示例#4
0
 public void WhenEmptyEnumerable_ThrowsException()
 {
     Assert.Throws <ArgumentException>(
         () => RequireThat.NotNullOrEmpty(Enumerable.Empty <object>(), "name"));
 }
示例#5
0
 public void WhenNullEnumerable_ThrowsException()
 {
     Assert.Throws <ArgumentNullException>(
         () => RequireThat.NotNullOrEmpty(null as IEnumerable, "name"));
 }
示例#6
0
 public void WhenNotEmptyString_DoesNotThrow()
 {
     RequireThat.NotNullOrEmpty("value", "name");
 }
示例#7
0
 public void WhenEmptyString_ThrowsException()
 {
     Assert.Throws <ArgumentException>(
         () => RequireThat.NotNullOrEmpty("", "name"));
 }
示例#8
0
 public void WhenNull_ThrowsException()
 {
     Assert.Throws <ArgumentNullException>(
         () => RequireThat.NotNullOrEmpty(null as string, "name"));
 }