NUnit.Framework.AssertionHelper.Expect(object, NUnit.Framework.Constraints.IResolveConstraint)

Here are the examples of the csharp api class NUnit.Framework.AssertionHelper.Expect(object, NUnit.Framework.Constraints.IResolveConstraint) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

101. Example

Project: CLAP
Source File: Tests.cs
[Test]
        public void Execute_HandleError_Registered_DefaultNoRethrow()
        {
            var p = new Parser<Sample_39>();
            var handled = false;

            p.Register.ErrorHandler(ex =>
            {
                handled = true;
            });

            p.RunStatic(new string[] { });

            Expect(handled, Is.True);
        }

102. Example

Project: CLAP
Source File: Tests.cs
[Test]
        public void Execute_HandleError_Registered_UnhandledParameters()
        {
            var mock = new Mock<IPrinter>();
            var sample = new Sample_02 { Printer = mock.Object };

            var p = new Parser<Sample_02>();

            var handled = false;

            p.Register.ErrorHandler(ex =>
            {
                handled = true;
            });

            p.Run(new[]
            {
                "-count:1",
                "-message:a",
                "-prefix:p",
                "-upper",
                "-what:x"
            }, sample);

            Expect(handled, Is.True);
        }

103. Example

Project: CLAP
Source File: Tests.cs
[Test]
        public void Execute_HandleError_Registered_ValidationError()
        {
            var sample = new ValidationSample_01();

            var p = new Parser<ValidationSample_01>();
            var handled = false;

            p.Register.ErrorHandler(ex =>
            {
                handled = true;
            });

            p.Run(new[] { "morethan5", "/n=1" }, sample);

            Expect(handled, Is.True);
        }

104. Example

Project: Dnn.Platform
Source File: CollectionExtensionTests.cs
[Test]
        public void can_get_default_bool_from_hashtable()
        {
            var value = true;
            var table = new Hashtable { { "app id", "abc123" } };

            value = table.GetValueOrDefault("Allow Windows Live Writer", value);

            Expect(value, Is.True);
        }

105. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void NotOperator()
		{
			// The ! operator is only available in the new syntax
			Assert.That(42, !Is.Null);
			// Inherited syntax
			Expect( 42, !Null );
		}

106. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void NotOperator()
		{
			// The ! operator is only available in the new syntax
			Assert.That(42, !Is.Null);
			// Inherited syntax
			Expect( 42, !Null );
		}

107. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void NotOperator()
		{
			// The ! operator is only available in the new syntax
			Assert.That(42, !Is.Null);
			// Inherited syntax
			Expect( 42, !Null );
		}

108. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void NotOperator()
		{
			// The ! operator is only available in the new syntax
			Assert.That(42, !Is.Null);
			// Inherited syntax
			Expect( 42, !Null );
		}

109. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void NotOperator()
		{
			// The ! operator is only available in the new syntax
			Assert.That(42, !Is.Null);
			// Inherited syntax
			Expect( 42, !Null );
		}

110. Example

Project: Dnn.Platform
Source File: CollectionExtensionTests.cs
[Test]
        public void can_get_sequence_with_no_value_from_namevaluecollection()
        {
            var collection = new NameValueCollection { { "state", "CA" } };

            var value = collection.GetValues<string>("cat");

            Expect(value, Is.Empty);
        }

111. Example

Project: grisu.net
Source File: AssertSyntaxTests.cs
[Test]
		public void NotOperator()
		{
			// The ! operator is only available in the new syntax
			Assert.That(42, !Is.Null);
			// Inherited syntax
			Expect( 42, !Null );
		}

112. Example

Project: nunit-csharp-samples
Source File: AssertSyntaxTests.cs
[Test]
        public void NotOperator()
        {
            // The ! operator is only available in the new syntax
            Assert.That(42, !Is.Null);
            // Inherited syntax
            Expect( 42, !Null );
        }

113. Example

Project: Pash
Source File: AssertSyntaxTests.cs
[Test]
		public void NotOperator()
		{
			// The ! operator is only available in the new syntax
			Assert.That(42, !Is.Null);
			// Inherited syntax
			Expect( 42, !Null );
		}

114. Example

Project: AutoTest.Net
Source File: AssertSyntaxTests.cs
[Test]
		public void NotOperator()
		{
			// The ! operator is only available in the new syntax
			Assert.That(42, !Is.Null);
			// Inherited syntax
			Expect( 42, !Null );
		}

115. Example

Project: AutoTest.Net
Source File: AssertSyntaxTests.cs
[Test]
		public void NotOperator()
		{
			// The ! operator is only available in the new syntax
			Assert.That(42, !Is.Null);
			// Inherited syntax
			Expect( 42, !Null );
		}

116. Example

Project: AutoTest.Net
Source File: AssertSyntaxTests.cs
[Test]
		public void NotOperator()
		{
			// The ! operator is only available in the new syntax
			Assert.That(42, !Is.Null);
			// Inherited syntax
			Expect( 42, !Null );
		}

117. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void IsNull()
		{
			object nada = null;

			// Classic syntax
			Assert.IsNull(nada);

			// Helper syntax
			Assert.That(nada, Is.Null);

			// Inherited syntax
			Expect(nada, Null);
		}

118. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void IsNotNull()
		{
			// Classic syntax
			Assert.IsNotNull(42);

			// Helper syntax
			Assert.That(42, Is.Not.Null);

			// Inherited syntax
			Expect( 42, Not.Null );
		}

119. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void IsFalse()
		{
			// Classic syntax
			Assert.IsFalse(2+2==5);

			// Helper syntax
			Assert.That(2+2== 5, Is.False);
			
			// Inherited syntax
			Expect(2+2==5, False);
		}

120. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void IsNaN()
		{
			double d = double.NaN;
			float f = float.NaN;

			// Classic syntax
			Assert.IsNaN(d);
			Assert.IsNaN(f);

			// Helper syntax
			Assert.That(d, Is.NaN);
			Assert.That(f, Is.NaN);
			
			// Inherited syntax
			Expect(d, NaN);
			Expect(f, NaN);
		}

121. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void NotTests()
		{
			// Not available using the classic syntax

			// Helper syntax
			Assert.That(42, Is.Not.Null);
			Assert.That(42, Is.Not.True);
			Assert.That(42, Is.Not.False);
			Assert.That(2.5, Is.Not.NaN);
			Assert.That(2 + 2, Is.Not.EqualTo(3));
			Assert.That(2 + 2, Is.Not.Not.EqualTo(4));
			Assert.That(2 + 2, Is.Not.Not.Not.EqualTo(5));

			// Inherited syntax
			Expect(42, Not.Null);
			Expect(42, Not.True);
			Expect(42, Not.False);
			Expect(2.5, Not.NaN);
			Expect(2 + 2, Not.EqualTo(3));
			Expect(2 + 2, Not.Not.EqualTo(4));
			Expect(2 + 2, Not.Not.Not.EqualTo(5));
		}

122. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void ArraysOfInt()
		{
			int[] a = new int[] { 1, 2, 3 };
			int[] b = new int[] { 1, 2, 3 };
            Assert.AreEqual(a, b);
            Assert.AreEqual(b, a);
            Expect(a, EqualTo(b));
            Expect(b, EqualTo(a));
        }

123. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void ArraysOfDouble()
		{
			double[] a = new double[] { 1.0, 2.0, 3.0 };
			double[] b = new double[] { 1.0, 2.0, 3.0 };
            Assert.AreEqual(a, b);
            Assert.AreEqual(b, a);
            Expect(a, EqualTo(b));
            Expect(b, EqualTo(a));
        }

124. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void ArraysOfDecimal()
		{
			decimal[] a = new decimal[] { 1.0m, 2.0m, 3.0m };
			decimal[] b = new decimal[] { 1.0m, 2.0m, 3.0m };
            Assert.AreEqual(a, b);
            Assert.AreEqual(b, a);
            Expect(a, EqualTo(b));
            Expect(b, EqualTo(a));
        }

125. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void ArrayOfIntAndArrayOfDouble()
		{
			int[] a = new int[] { 1, 2, 3 };
			double[] b = new double[] { 1.0, 2.0, 3.0 };
            Assert.AreEqual(a, b);
            Assert.AreEqual(b, a);
            Expect(a, EqualTo(b));
            Expect(b, EqualTo(a));
        }

126. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void ArraysOfMixedTypes()
		{
			DateTime now = DateTime.Now;
			object[] array1 = new object[] { 1, 2.0f, 3.5d, 7.000m, "Hello", now };
			object[] array2 = new object[] { 1.0d, 2, 3.5, 7, "Hello", now };
			Assert.AreEqual( array1, array2 );
			Assert.AreEqual(array2, array1);
            Expect(array1, EqualTo(array2));
            Expect(array2, EqualTo(array1));
		}

127. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void DoubleDimensionedArrays()
		{
			int[,] a = new int[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
			int[,] b = new int[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
            Assert.AreEqual(a, b);
            Assert.AreEqual(b, a);
            Expect(a, EqualTo(b));
            Expect(b, EqualTo(a));
        }

128. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void TripleDimensionedArrays()
		{
			int[, ,] expected = new int[,,] { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } };
			int[,,] actual = new int[,,] { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } };

			Assert.AreEqual(expected, actual);
            Expect(actual, EqualTo(expected));
		}

129. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void FiveDimensionedArrays()
		{
			int[, , , ,] expected = new int[2, 2, 2, 2, 2] { { { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } }, { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } } }, { { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } }, { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } } } };
			int[, , , ,] actual = new int[2, 2, 2, 2, 2] { { { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } }, { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } } }, { { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } }, { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } } } };

			Assert.AreEqual(expected, actual);
            Expect(actual, EqualTo(expected));
		}

130. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void ArraysOfArrays()
		{
			int[][] a = new int[][] { new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 }, new int[] { 7, 8, 9 } };
			int[][] b = new int[][] { new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 }, new int[] { 7, 8, 9 } };
            Assert.AreEqual(a, b);
            Assert.AreEqual(b, a);
            Expect(a, EqualTo(b));
            Expect(b, EqualTo(a));
        }

131. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void JaggedArrays()
		{
			int[][] expected = new int[][] { new int[] { 1, 2, 3 }, new int[] { 4, 5, 6, 7 }, new int[] { 8, 9 } };
			int[][] actual = new int[][] { new int[] { 1, 2, 3 }, new int[] { 4, 5, 6, 7 }, new int[] { 8, 9 } };

			Assert.AreEqual(expected, actual);
            Expect(actual, EqualTo(expected));
		}

132. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void ArraysPassedAsObjects()
		{
			object a = new int[] { 1, 2, 3 };
			object b = new double[] { 1.0, 2.0, 3.0 };
            Assert.AreEqual(a, b);
            Assert.AreEqual(b, a);
            Expect(a, EqualTo(b));
            Expect(b, EqualTo(a));
        }

133. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void ArrayAndCollection()
		{
			int[] a = new int[] { 1, 2, 3 };
			ICollection b = new ArrayList( a );
            Assert.AreEqual(a, b);
            Assert.AreEqual(b, a);
            Expect(a, EqualTo(b));
            Expect(b, EqualTo(a));
        }

134. Example

Project: ContinuousTests
Source File: ArrayNotEqualFixture.cs
[Test]
		public void DifferentLengthArrays()
		{
			string[] array1 = { "one", "two", "three" };
			string[] array2 = { "one", "two", "three", "four", "five" };

			Assert.AreNotEqual(array1, array2);
			Assert.AreNotEqual(array2, array1);
            Expect(array1, Not.EqualTo(array2));
            Expect(array2, Not.EqualTo(array1));
		}

135. Example

Project: ContinuousTests
Source File: ArrayNotEqualFixture.cs
[Test]
		public void SameLengthDifferentContent()
		{
			string[] array1 = { "one", "two", "three" };
			string[] array2 = { "one", "two", "ten" };
			Assert.AreNotEqual(array1, array2);
			Assert.AreNotEqual(array2, array1);
            Expect(array1, Not.EqualTo(array2));
            Expect(array2, Not.EqualTo(array1));
		}

136. Example

Project: ContinuousTests
Source File: ArrayNotEqualFixture.cs
[Test]
		public void ArraysDeclaredAsDifferentTypes()
		{
			string[] array1 = { "one", "two", "three" };
			object[] array2 = { "one", "three", "two" };
			Assert.AreNotEqual(array1, array2);
            Expect(array1, Not.EqualTo(array2));
            Expect(array2, Not.EqualTo(array1));
		}

137. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void IsNull()
		{
			object nada = null;

			// Classic syntax
			Assert.IsNull(nada);

			// Helper syntax
			Assert.That(nada, Is.Null);

			// Inherited syntax
			Expect(nada, Null);
		}

138. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void IsNotNull()
		{
			// Classic syntax
			Assert.IsNotNull(42);

			// Helper syntax
			Assert.That(42, Is.Not.Null);

			// Inherited syntax
			Expect( 42, Not.Null );
		}

139. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void IsFalse()
		{
			// Classic syntax
			Assert.IsFalse(2+2==5);

			// Helper syntax
			Assert.That(2+2== 5, Is.False);
			
			// Inherited syntax
			Expect(2+2==5, False);
		}

140. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void IsNaN()
		{
			double d = double.NaN;
			float f = float.NaN;

			// Classic syntax
			Assert.IsNaN(d);
			Assert.IsNaN(f);

			// Helper syntax
			Assert.That(d, Is.NaN);
			Assert.That(f, Is.NaN);
			
			// Inherited syntax
			Expect(d, NaN);
			Expect(f, NaN);
		}

141. Example

Project: ContinuousTests
Source File: AssertSyntaxTests.cs
[Test]
		public void NotTests()
		{
			// Not available using the classic syntax

			// Helper syntax
			Assert.That(42, Is.Not.Null);
			Assert.That(42, Is.Not.True);
			Assert.That(42, Is.Not.False);
			Assert.That(2.5, Is.Not.NaN);
			Assert.That(2 + 2, Is.Not.EqualTo(3));
			Assert.That(2 + 2, Is.Not.Not.EqualTo(4));
			Assert.That(2 + 2, Is.Not.Not.Not.EqualTo(5));

			// Inherited syntax
			Expect(42, Not.Null);
			Expect(42, Not.True);
			Expect(42, Not.False);
			Expect(2.5, Not.NaN);
			Expect(2 + 2, Not.EqualTo(3));
			Expect(2 + 2, Not.Not.EqualTo(4));
			Expect(2 + 2, Not.Not.Not.EqualTo(5));
		}

142. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void ArraysOfInt()
		{
			int[] a = new int[] { 1, 2, 3 };
			int[] b = new int[] { 1, 2, 3 };
            Assert.AreEqual(a, b);
            Assert.AreEqual(b, a);
            Expect(a, EqualTo(b));
            Expect(b, EqualTo(a));
        }

143. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void ArraysOfDouble()
		{
			double[] a = new double[] { 1.0, 2.0, 3.0 };
			double[] b = new double[] { 1.0, 2.0, 3.0 };
            Assert.AreEqual(a, b);
            Assert.AreEqual(b, a);
            Expect(a, EqualTo(b));
            Expect(b, EqualTo(a));
        }

144. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void ArraysOfDecimal()
		{
			decimal[] a = new decimal[] { 1.0m, 2.0m, 3.0m };
			decimal[] b = new decimal[] { 1.0m, 2.0m, 3.0m };
            Assert.AreEqual(a, b);
            Assert.AreEqual(b, a);
            Expect(a, EqualTo(b));
            Expect(b, EqualTo(a));
        }

145. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void ArrayOfIntAndArrayOfDouble()
		{
			int[] a = new int[] { 1, 2, 3 };
			double[] b = new double[] { 1.0, 2.0, 3.0 };
            Assert.AreEqual(a, b);
            Assert.AreEqual(b, a);
            Expect(a, EqualTo(b));
            Expect(b, EqualTo(a));
        }

146. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void ArraysOfMixedTypes()
		{
			DateTime now = DateTime.Now;
			object[] array1 = new object[] { 1, 2.0f, 3.5d, 7.000m, "Hello", now };
			object[] array2 = new object[] { 1.0d, 2, 3.5, 7, "Hello", now };
			Assert.AreEqual( array1, array2 );
			Assert.AreEqual(array2, array1);
            Expect(array1, EqualTo(array2));
            Expect(array2, EqualTo(array1));
		}

147. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void DoubleDimensionedArrays()
		{
			int[,] a = new int[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
			int[,] b = new int[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
            Assert.AreEqual(a, b);
            Assert.AreEqual(b, a);
            Expect(a, EqualTo(b));
            Expect(b, EqualTo(a));
        }

148. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void TripleDimensionedArrays()
		{
			int[, ,] expected = new int[,,] { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } };
			int[,,] actual = new int[,,] { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } };

			Assert.AreEqual(expected, actual);
            Expect(actual, EqualTo(expected));
		}

149. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void FiveDimensionedArrays()
		{
			int[, , , ,] expected = new int[2, 2, 2, 2, 2] { { { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } }, { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } } }, { { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } }, { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } } } };
			int[, , , ,] actual = new int[2, 2, 2, 2, 2] { { { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } }, { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } } }, { { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } }, { { { 1, 2 }, { 3, 4 } }, { { 5, 6 }, { 7, 8 } } } } };

			Assert.AreEqual(expected, actual);
            Expect(actual, EqualTo(expected));
		}

150. Example

Project: ContinuousTests
Source File: ArrayEqualsFixture.cs
[Test]
		public void ArraysOfArrays()
		{
			int[][] a = new int[][] { new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 }, new int[] { 7, 8, 9 } };
			int[][] b = new int[][] { new int[] { 1, 2, 3 }, new int[] { 4, 5, 6 }, new int[] { 7, 8, 9 } };
            Assert.AreEqual(a, b);
            Assert.AreEqual(b, a);
            Expect(a, EqualTo(b));
            Expect(b, EqualTo(a));
        }