NUnit.Framework.Assert.Less(long, long)

Here are the examples of the csharp api class NUnit.Framework.Assert.Less(long, long) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

9 Examples 7

1. Example

Project: DReAM
Source File: NumericTests.cs
View license
[Test]
        public void ToInt_for_small_long_gets_capped_at_min_value() {
            var small = (long)int.MinValue - 1000;
            Assert.Less(small, int.MaxValue);
            Assert.AreEqual(int.MinValue, small.ToInt());
        }

2. Example

Project: NewId
Source File: Provider_Specs.cs
View license
[Test, Explicit]
        public void Should_not_lag_time()
        {
            TimeSpan timeDelta = TimeSpan.FromMinutes(1);

            var startProvider = new StopwatchTickProvider();
            Thread.Sleep(timeDelta);
            var endProvider = new StopwatchTickProvider();


            long deltaTicks = Math.Abs(endProvider.Ticks - startProvider.Ticks);
            // 0.01% acceptable delta
            var acceptableDelta = (long)(timeDelta.Ticks * 0.0001);

            Assert.Less(deltaTicks, acceptableDelta);
        }

3. Example

Project: DiskQueue
Source File: TransactionLogTests.cs
View license
[Test]
		public void Transaction_log_size_shrink_after_queue_disposed()
		{
			long txSizeWhenOpen;
			var txLogInfo = new FileInfo(Path.Combine(path, "transaction.log"));
			using (var queue = new PersistentQueue(path))
			{
				queue.Internals.ParanoidFlushing = false;
				using (var session = queue.OpenSession())
				{
					for (int j = 0; j < 10; j++)
					{
						session.Enqueue(Guid.NewGuid().ToByteArray());
					}
					session.Flush();
				}

				using (var session = queue.OpenSession())
				{
					for (int j = 0; j < 10; j++)
					{
						session.Dequeue();
					}
					session.Flush();
				}
				txSizeWhenOpen = txLogInfo.Length;
			}
			txLogInfo.Refresh();
			Assert.Less(txLogInfo.Length, txSizeWhenOpen);
		}

4. Example

Project: NewId
Source File: Provider_Specs.cs
View license
[Test, Explicit]
        public void Should_keep_accurate_time()
        {
            TimeSpan timeDelta = TimeSpan.FromSeconds(3);

            var timestamp = DateTime.UtcNow;
            var provider = new StopwatchTickProvider();
            long start = provider.Ticks;
            Thread.Sleep(timeDelta);
            long stop = provider.Ticks;

            var startTime = new DateTime(start);
            Console.WriteLine("Start time: {0}, Original: {1}", startTime, timestamp);


            long deltaTicks = Math.Abs(stop - start);
            // 0.01% acceptable delta
            var acceptableDelta = (long)(timeDelta.Ticks);

            Assert.Less(deltaTicks, acceptableDelta);
        }

5. Example

Project: DiskQueue
Source File: TransactionLogTests.cs
View license
[Test]
		public void If_tx_log_grows_too_large_it_will_be_trimmed_while_queue_is_in_operation()
		{
			var txLogInfo = new FileInfo(Path.Combine(path, "transaction.log"));

			using (var queue = new PersistentQueue(path)
			{
				SuggestedMaxTransactionLogSize = 32 // single entry
			})
			{
				queue.Internals.ParanoidFlushing = false;

				using (var session = queue.OpenSession())
				{
					for (int j = 0; j < 20; j++)
					{
						session.Enqueue(Guid.NewGuid().ToByteArray());
					}
					session.Flush();
				}
				// there is no way optimize here, so we should get expected size, even though it is bigger than
				// what we suggested as the max
				txLogInfo.Refresh();
				long txSizeWhenOpen = txLogInfo.Length;

				using (var session = queue.OpenSession())
				{
					for (int j = 0; j < 20; j++)
					{
						session.Dequeue();
					}
					Assert.IsNull(session.Dequeue());

					session.Flush();
				}
				txLogInfo.Refresh();
				Assert.Less(txLogInfo.Length, txSizeWhenOpen);
			}
		}

6. Example

Project: nhibernate-core
Source File: Fixture.cs
View license
[Test, Explicit]
		public void MemoryLeak()
		{

			long initialMemory = GC.GetTotalMemory(true);
			long nextId = 1;
			long nextIdChild = 1;

			using (ISession session = OpenSession())
			using (session.BeginTransaction())
			{
				// We try to insert 100.000 entities, cleaning the sessions
				// every 1000.
				// We keep track of memory, that should be increasing forever.
				// We took a maximum of 250000 that can change to greater number but
				// not increase forever.
				for (int i = 0; i < 100; i++)
				{
					GC.Collect();
					long currentMemory = GC.GetTotalMemory(true);
					long memoryIncrease = currentMemory - initialMemory;

					Assert.Less(memoryIncrease, 400000);
					// Console.WriteLine(memoryIncrease);
					for (int j = 0; j < 1000; j++)
					{
						Parent a = new Parent();
						a.Id = nextId++;

						Child c = new Child();
						c.Id = nextIdChild++;

						a.Childs.Add(c);

						session.Save(c);
						session.Save(a);
					}
					session.Flush();
					session.Clear();
				}
			}
		}

7. Example

Project: nhibernate-core
Source File: Fixture.cs
View license
[Test, Explicit]
		public async Task MemoryLeakAsync()
		{

			long initialMemory = GC.GetTotalMemory(true);
			long nextId = 1;
			long nextIdChild = 1;

			using (ISession session = OpenSession())
			using (session.BeginTransaction())
			{
				// We try to insert 100.000 entities, cleaning the sessions
				// every 1000.
				// We keep track of memory, that should be increasing forever.
				// We took a maximum of 250000 that can change to greater number but
				// not increase forever.
				for (int i = 0; i < 100; i++)
				{
					GC.Collect();
					long currentMemory = GC.GetTotalMemory(true);
					long memoryIncrease = currentMemory - initialMemory;

					Assert.Less(memoryIncrease, 400000);
					// Console.WriteLine(memoryIncrease);
					for (int j = 0; j < 1000; j++)
					{
						Parent a = new Parent();
						a.Id = nextId++;

						Child c = new Child();
						c.Id = nextIdChild++;

						a.Childs.Add(c);

						await (session.SaveAsync(c));
						await (session.SaveAsync(a));
					}
					await (session.FlushAsync());
					session.Clear();
				}
			}
		}

8. Example

Project: ObjectDiffer
Source File: DifferTests.cs
View license
[Test]
        public void ShouldBePerformantForArrayDiffs()
        {
            var oldList = Enumerable.Range(0, 50);
            var newList = Enumerable.Range(0, 50);

            var sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            Enumerable.Range(0, 100).Select(i =>
            {
                newList = newList.Select(e => e + 1);
                return _differ.Diff(newList, oldList);
            }).ToList();
            sw.Stop();
            Assert.Less(sw.ElapsedMilliseconds, 1000);
            Console.WriteLine(sw.ElapsedMilliseconds);
        }

9. Example

Project: ObjectDiffer
Source File: DifferTests.cs
View license
[Test]
        public void ShouldBePerformantForObjectDiffs()
        {
            var oldObj = new TestObj
            {
                Id = 1,
                Primative = "A",
                Object = new TestObj
                {
                    Primative = "A"
                }
            };
            var newObj = new TestObj
            {
                Id = 1,
                Primative = "B",
                Object = new TestObj
                {
                    Primative = "B"
                }
            };

            var sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            Enumerable.Range(0, 1000).Select(i =>
            {
                oldObj.Primative = i.ToString();
                return _differ.Diff(newObj, oldObj);
            }).ToList();
            sw.Stop();
            Assert.Less(sw.ElapsedMilliseconds, 1000);
            Console.WriteLine(sw.ElapsedMilliseconds);
        }