NUnit.Framework.Assert.AreEqual(object, object, string, params object[])

Here are the examples of the csharp api class NUnit.Framework.Assert.AreEqual(object, object, string, params object[]) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

83 Examples 7

1. Example

Project: msgpack-cli
Source File: DirectoryAssert.cs
View license
static public void AreEqual(DirectoryInfo expected, DirectoryInfo actual, string message, params object[] args)
        {
            Assert.AreEqual(expected, actual, message, args);
        }

2. Example

Project: SharpTAL
Source File: TalAttributesTests.cs
View license
[Test]
		public void TestCustomFormatResult()
		{
			string template = @"<html tal:attributes=""value 1.05""> </html>";
			string expected = @"<html value=""1,05""> </html>";

			ITemplate t = new CustomTemplate(template);

			string actual = t.Render(globals);
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, "Conversion using invariant culture failed", template, actual, expected);
		}

3. Example

Project: nunit
Source File: DirectoryAssert.cs
View license
static public void AreEqual(DirectoryInfo expected, DirectoryInfo actual, string message, params object[] args)
        {
            Assert.AreEqual(expected, actual, message, args);
        }

4. Example

View license
[Test]
		public void TestReuseTemplateInfo()
		{
			TemplateInfo ti = Cache.CompileTemplate(@"<template></template>", Globals, RefAssemblies);
			string hash1 = ti.TemplateKey;

			ti = Cache.CompileTemplate(@"<template></template>", Globals, RefAssemblies);
			string hash2 = ti.TemplateKey;
			Assert.AreEqual(hash1, hash2, "Reusing generated template in Cache failed. Hash1: {0}, Hash2: {1}", hash1, hash2);
		}

5. Example

Project: SharpTAL
Source File: TalAttributesTests.cs
View license
[Test]
		public void TestAttributeInvariantCulture()
		{
			string template = @"<html tal:attributes=""value 1.05""> </html>";
			string expected = @"<html value=""1.05""> </html>";
			string actual = new Template(template).Render(globals);
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, "Conversion using invariant culture failed", template, actual, expected);
		}

6. Example

Project: SharpTAL
Source File: TalAttributesTests.cs
View license
public static void RunTest(string template, string expected, string errMsg)
		{
			string actual = new Template(template).Render(globals);
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

7. Example

Project: SharpTAL
Source File: TalAttributesTests.cs
View license
[Test]
		public void TestAttributeLocalCulture()
		{
			string template = @"<html tal:attributes=""value 1.05""> </html>";
			string expected = @"<html value=""1,05""> </html>";

			Template t = new Template(template);
			t.Culture = new CultureInfo("fi-FI");

			string actual = t.Render(globals);
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, "Conversion using invariant culture failed", template, actual, expected);
		}

8. Example

Project: 32feet
Source File: Assert.cs
View license
static public void AreEqual(Object expected, Object actual, string message) 
		{
			Assert.AreEqual(expected, actual, message, null);
		}

9. Example

Project: 32feet
Source File: Assert.cs
View license
static public void AreEqual(Object expected, Object actual) 
		{
			Assert.AreEqual(expected, actual, string.Empty, null);
		}

10. Example

Project: 32feet
Source File: Assert.cs
View license
static public void AreEqual(Object expected, Object actual) 
		{
			Assert.AreEqual(expected, actual, string.Empty, null);
		}

11. Example

Project: 32feet
Source File: Assert.cs
View license
static public void AreEqual(Object expected, Object actual, string message) 
		{
			Assert.AreEqual(expected, actual, message, null);
		}

12. Example

View license
[Test]
		public void TestReuseTemplateInfo()
		{
			TemplateInfo ti = Cache.CompileTemplate(@"<template></template>", Globals, RefAssemblies);
			string hash1 = ti.TemplateKey;

			ti = Cache.CompileTemplate(@"<template></template>", Globals, RefAssemblies);
			string hash2 = ti.TemplateKey;
			Assert.AreEqual(hash1, hash2, "Reusing generated template in cache failed. Hash1: {0}, Hash2: {1}", hash1, hash2);
		}

13. Example

Project: SharpTAL
Source File: TalConditionTests.cs
View license
public static void RunTest(string template, string expected, string errMsg)
		{
			string actual = new Template(template).Render(globals);
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

14. Example

Project: SharpTAL
Source File: InterpolationTests.cs
View license
public static void RunTest(string template, string expected, string errMsg)
		{
			string actual = new Template(template).Render(new Dictionary<string, object> { });
			actual = actual.Replace("{", "{").Replace("}", "}");
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

15. Example

Project: SharpTAL
Source File: TalRepeatTests.cs
View license
public static void RunTest(string template, string expected, string errMsg)
        {
			string actual = new Template(template).Render(globals);
			actual = actual.Replace("{", "{{").Replace("}", "}}");
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

16. Example

Project: SharpTAL
Source File: MetalNameSpaceTests.cs
View license
public static void RunTest(string macros, string template, string expected, string errMsg)
		{
			template += macros;
			string actual = new Template(template).Render(globals);
			actual = actual.Replace("{", "{{").Replace("}", "}}");
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

17. Example

Project: SharpTAL
Source File: CodeBlocksTests.cs
View license
public static void RunTest(string template, string expected, string errMsg)
		{
			string actual = new Template(template).Render(new Dictionary<string, object> { });
			actual = actual.Replace("{", "{").Replace("}", "}");
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

18. Example

Project: SharpTAL
Source File: MetalDefineSlotsTests.cs
View license
public static void RunTest(string macros, string template, string expected, string errMsg)
		{
			template += macros;
			string actual = new Template(template).Render(globals);
			actual = actual.Replace("{", "{{").Replace("}", "}}");
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

19. Example

Project: SharpTAL
Source File: TalDefineTests.cs
View license
public static void RunTest(string template, string expected, string errMsg)
		{
			try
			{
				string actual = new Template(template).Render(globals);
				actual = actual.Replace("{", "{{").Replace("}", "}}");
				Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
					Environment.NewLine, errMsg, template, actual, expected);
			}
			finally
			{
			}
		}

20. Example

Project: SharpTAL
Source File: TalReplaceTests.cs
View license
public static void RunTest(string template, string expected, string errMsg)
		{
			string actual = new Template(template).Render(globals);
			actual = actual.Replace("{", "{{").Replace("}", "}}");
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

21. Example

Project: SharpTAL
Source File: MetalDefineParamsTests.cs
View license
public static void RunTest(string macros, string template, string expected, string errMsg)
		{
			template += macros;
			string actual = new Template(template).Render(globals);
			actual = actual.Replace("{", "{{").Replace("}", "}}");
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

22. Example

Project: SharpTAL
Source File: TalOmitTagTests.cs
View license
public static void RunTest(string template, string expected, string errMsg)
		{
			string actual = new Template(template).Render(globals);
			actual = actual.Replace("{", "{{").Replace("}", "}}");
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

23. Example

Project: SharpTAL
Source File: MetalDefineMacroTests.cs
View license
public static void RunTest(string template, string expected, string errMsg)
		{
			string actual = new Template(template).Render(globals);
			actual = actual.Replace("{", "{{").Replace("}", "}}");
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

24. Example

Project: SharpTAL
Source File: TalContentTests.cs
View license
public static void RunTest(string template, string expected, string errMsg)
		{
			List<Assembly> referencedAssemblies = new List<Assembly>()
			{
				typeof(TalContentTests).Assembly
			};
			string actual = new Template(template, referencedAssemblies).Render(globals);
			actual = actual.Replace("{", "{{").Replace("}", "}}");
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

25. Example

Project: SharpTAL
Source File: TalesStringTests.cs
View license
public static void RunTest(string template, string expected, string errMsg)
		{
			string actual = new Template(template).Render(globals);
			actual = actual.Replace("{", "{").Replace("}", "}");
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

26. Example

Project: SharpTAL
Source File: MetalImportTests.cs
View license
public static void RunTest(string template, string expected, string errMsg)
		{
			string actual = new Template(template).Render(globals);
			actual = actual.Replace("{", "{{").Replace("}", "}}");
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

27. Example

Project: nunit
Source File: SetUpFixtureData.cs
View license
public static void Verify(params string[] expectedEvents)
        {
            foreach (string expected in expectedEvents)
            {
                int item = 0;
                string actual = _events.Count > 0 ? _events.Dequeue() : null;
                Assert.AreEqual( expected, actual, "Item {0}", item++ );
            }
        }

28. Example

Project: SharpTAL
Source File: TalesCSharpPathTests.cs
View license
public static void RunTest(string template, string expected, string errMsg)
		{
			globals = new Dictionary<string, object>();
			globals.Add("top", "Hello from the top");
			globals.Add("helloFunc", new TestFuncDelegate(simpleFunction));
			globals.Add("helloFunction", new TestFuncDelegate2(helloFunction));
			globals.Add("myList", new List<int>() { 1, 2, 3, 4, 5, 6 });
			globals.Add("testing", "testing");
			globals.Add("map", new Dictionary<string, object>() { { "test", "maptest" } });
			globals.Add("data", new Dictionary<string, object>() { { "one", 1 }, { "zero", 0 } });
			string actual = new Template(template).Render(globals);
			actual = actual.Replace("{", "{{").Replace("}", "}}");
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

29. Example

Project: Jayrock
Source File: TestUnixTime.cs
View license
[ Test ]
        public void Milliseconds()
        {
            DateTime t1 = new DateTime(2006, 7, 17, 10, 56, 56, 456);
            const double u1 = 1153133816.456;
            
            DateTime t2 = new DateTime(2006, 7, 17, 11, 00, 44, 567);
            const double u2 = 1153134044.567;

            DateTime ut1 = UnixTime.ToDateTime(u1).ToUniversalTime();
            Assert.AreEqual(t1, ut1, "ms expected = {0}, ms actual = {1}", t1.Millisecond, ut1.Millisecond);
            
            DateTime ut2 = UnixTime.ToDateTime(u2).ToUniversalTime();
            Assert.AreEqual(t2, ut2, "ms expected = {0}, ms actual = {1}", t2.Millisecond, ut2.Millisecond);

            Assert.AreEqual(u1, UnixTime.ToDouble(t1.ToLocalTime()), 0.0001);
            Assert.AreEqual(u2, UnixTime.ToDouble(t2.ToLocalTime()), 0.0001);

            Assert.AreEqual(new DateTime(1098, 7, 6, 5, 43, 21, 234), UnixTime.ToDateTime(-27501531398.766).ToUniversalTime());
            Assert.AreEqual(UnixTime.EpochUtc.AddMilliseconds(+123), UnixTime.ToDateTime(0, +123).ToUniversalTime());
            Assert.AreEqual(UnixTime.EpochUtc.AddMilliseconds(-123), UnixTime.ToDateTime(0, -123).ToUniversalTime());
        }

30. Example

Project: NCrontab
Source File: CrontabScheduleTests.cs
View license
static void CronCall(string startTimeString, string cronExpression, string nextTimeString, ParseOptions options)
        {
            var schedule = CrontabSchedule.Parse(cronExpression, options);
            var next = schedule.GetNextOccurrence(Time(startTimeString));

            Assert.AreEqual(nextTimeString, TimeString(next),
                "Occurrence of <{0}> after <{1}>.", cronExpression, startTimeString);
        }

31. Example

Project: NCrontab
Source File: CrontabScheduleTests.cs
View license
static void CronFinite(string cronExpression, string startTimeString, string endTimeString, ParseOptions options)
        {
            var schedule = CrontabSchedule.Parse(cronExpression, options);
            var occurrence = schedule.GetNextOccurrence(Time(startTimeString), Time(endTimeString));

            Assert.AreEqual(endTimeString, TimeString(occurrence),
                "Occurrence of <{0}> after <{1}> did not terminate with <{2}>.",
                cronExpression, startTimeString, endTimeString);
        }

32. Example

Project: MimeKit
Source File: EncoderTests.cs
View license
static void AssertIsDecoderFilter (ContentEncoding encoding, ContentEncoding expected)
		{
			var filter = DecoderFilter.Create (encoding);

			Assert.IsInstanceOf<DecoderFilter> (filter, "Expected DecoderFilter for ContentEncoding.{0}", encoding);

			var decoder = (DecoderFilter) filter;

			Assert.AreEqual (expected, decoder.Encoding, "Expected decoder's Encoding to be ContentEncoding.{0}", expected);
		}

33. Example

Project: MimeKit
Source File: InternetAddressListTests.cs
View license
[Test]
		public void TestEncodingSimpleMailboxWithQuotedName ()
		{
			const string expected = "\"Stedfast, Jeffrey\" <[email protected]>";
			var mailbox = new MailboxAddress ("Stedfast, Jeffrey", "[email protected]");
			var list = new InternetAddressList ();
			list.Add (mailbox);

			var actual = list.ToString (UnixFormatOptions, true);

			Assert.AreEqual (expected, actual, "Encoding quoted mailbox did not match expected result: {0}", expected);
		}

34. Example

Project: MimeKit
Source File: EncoderTests.cs
View license
static void AssertIsDecoderFilter (string encoding, ContentEncoding expected)
		{
			var filter = DecoderFilter.Create (encoding);

			Assert.IsInstanceOf<DecoderFilter> (filter, "Expected DecoderFilter for \"{0}\"", encoding);

			var decoder = (DecoderFilter) filter;

			Assert.AreEqual (expected, decoder.Encoding, "Expected decoder's Encoding to be ContentEncoding.{0}", expected);
		}

35. Example

Project: MimeKit
Source File: EncoderTests.cs
View license
static void AssertIsEncoderFilter (string encoding, ContentEncoding expected)
		{
			var filter = EncoderFilter.Create (encoding);

			Assert.IsInstanceOf<EncoderFilter> (filter, "Expected EncoderFilter for \"{0}\"", encoding);

			var encoder = (EncoderFilter) filter;

			Assert.AreEqual (expected, encoder.Encoding, "Expected encoder's Encoding to be ContentEncoding.{0}", expected);
		}

36. Example

Project: SharpTAL
Source File: TextTemplateTests.cs
View license
public static void RunTest(string template, string expected, string errMsg)
		{
			globals = new Dictionary<string, object>();
			globals.Add("name", "world");
			string actual = new Template(template).Render(globals);
			actual = actual.Replace("{", "{").Replace("}", "}");
			Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
				Environment.NewLine, errMsg, template, actual, expected);
		}

37. Example

Project: MimeKit
Source File: EncoderTests.cs
View license
static void AssertIsEncoderFilter (ContentEncoding encoding, ContentEncoding expected)
		{
			var filter = EncoderFilter.Create (encoding);

			Assert.IsInstanceOf<EncoderFilter> (filter, "Expected EncoderFilter for ContentEncoding.{0}", encoding);

			var encoder = (EncoderFilter) filter;

			Assert.AreEqual (expected, encoder.Encoding, "Expected encoder's Encoding to be ContentEncoding.{0}", expected);
		}

38. Example

Project: MimeKit
Source File: HtmlEntityDecoderTests.cs
View license
static void TestDecodeNumericEntity (string text, string expected)
		{
			var decoder = new HtmlEntityDecoder ();

			for (int i = 0; i < text.Length; i++)
				Assert.IsTrue (decoder.Push (text[i]), "Failed to push char #{0} of \"{1}\".", i, text);

			Assert.AreEqual (expected, decoder.GetValue (), "Decoded entity did not match for \"{0}\".", text);
		}

39. Example

View license
[Test]
        public void GetYearMonthDay_DaysSinceEpoch()
        {
            var calculator = new UmAlQuraYearMonthDayCalculator();
            int daysSinceEpoch = calculator.GetStartOfYearInDays(calculator.MinYear);
            for (int year = calculator.MinYear; year <= calculator.MaxYear; year++)
            {
                for (int month = 1; month <= 12; month++)
                {
                    for (int day = 1; day <= calculator.GetDaysInMonth(year, month); day++)
                    {
                        var actual = calculator.GetYearMonthDay(daysSinceEpoch);
                        var expected = new YearMonthDay(year, month, day);
                        Assert.AreEqual(expected, actual, "daysSinceEpoch={0}", daysSinceEpoch);
                        daysSinceEpoch++;
                    }
                }
            }
        }

40. Example

Project: keepassrpc
Source File: TestJsonTextReader.cs
View license
private void AssertTokenText(JsonTokenClass token, string text)
        {
            Assert.IsTrue(_reader.Read());
            Assert.AreEqual(token, _reader.TokenClass, "Found {0} (with text \x201c{1}\x201d) when expecting {2} (with text \x201c{3}\x201d).", _reader.TokenClass, _reader.Text, token, text);
            if (text != null)
                Assert.AreEqual(text, _reader.Text);
        }

41. Example

Project: MimeKit
Source File: DkimTests.cs
View license
static void VerifyDkimBodyHash (MimeMessage message, DkimSignatureAlgorithm algorithm, string expectedHash)
		{
			var value = message.Headers[HeaderId.DkimSignature];
			var parameters = value.Split (';');
			string hash = null;

			for (int i = 0; i < parameters.Length; i++) {
				var param = parameters[i].Trim ();

				if (param.StartsWith ("bh=", StringComparison.Ordinal)) {
					hash = param.Substring (3);
					break;
				}
			}

			Assert.AreEqual (expectedHash, hash, "The {0} hash does not match the expected value.", algorithm.ToString ().ToUpperInvariant ().Substring (3));
		}

42. Example

Project: MimeKit
Source File: InternetAddressListTests.cs
View license
[Test]
		public void TestEncodingSimpleMailboxWithLatin1Name ()
		{
			var latin1 = Encoding.GetEncoding ("iso-8859-1");
			var mailbox = new MailboxAddress (latin1, "Kristoffer Brånemyr", "[email protected]");
			var list = new InternetAddressList ();
			list.Add (mailbox);

			var expected = "Kristoffer =?iso-8859-1?q?Br=E5nemyr?= <[email protected]>";
			var actual = list.ToString (UnixFormatOptions, true);

			Assert.AreEqual (expected, actual, "Encoding latin1 mailbox did not match expected result: {0}", expected);

			mailbox = new MailboxAddress (latin1, "T?õivo Leedj?ärv", "[email protected]");
			list = new InternetAddressList ();
			list.Add (mailbox);

			expected = "=?iso-8859-1?b?VIH1aXZvIExlZWRqgeRydg==?= <[email protected]>";
			actual = list.ToString (UnixFormatOptions, true);

			Assert.AreEqual (expected, actual, "Encoding latin1 mailbox did not match expected result: {0}", expected);
		}

43. Example

Project: nunit-console
Source File: CommandLineTests.cs
View license
[TestCase("ShowHelp", "help|h")]
        [TestCase("ShowVersion", "version|V")]
        [TestCase("S/n ..... /n //View Source file for more details /n }

44. Example

View license
[TestCase("ShowHelp", "help|h")]
        [TestCase("ShowVersion", "version|V")]
        [TestCase("S/n ..... /n //View Source file for more details /n }

45. Example

Project: ContinuousTests
Source File: CommandLineTests.cs
View license
private void TestBooleanOption( string fieldName, string option )
		{
			FieldInfo field = typeof(ConsoleOptions).GetField( fieldName );
			Assert.IsNotNull( field, "Field '{0}' not found", fieldName );
			Assert.AreEqual( typeof(bool), field.FieldType, "Field '{0}' is wrong type", fieldName );

			ConsoleOptions options = new ConsoleOptions( "-" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize -" + option );
			options = new ConsoleOptions( "--" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize --" + option );
			options = new ConsoleOptions( false, "/" + option );
			Assert.AreEqual( false, (bool)field.GetValue( options ), "Incorrectly recognized /" + option );
			options = new ConsoleOptions( true, "/" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize /" + option );
		}

46. Example

Project: 3DNUS
Source File: BindObjectTests.cs
View license
[Test]
        [TestCase("VoidRetValIsUndefined", "bound.EchoVoid() === undefined", false)]

/*
|=CL/n ..... /n //View Source file for more details /n }

47. Example

Project: AutoTest.Net
Source File: CommandLineTests.cs
View license
private void TestBooleanOption( string fieldName, string option )
		{
			FieldInfo field = typeof(ConsoleOptions).GetField( fieldName );
			Assert.IsNotNull( field, "Field '{0}' not found", fieldName );
			Assert.AreEqual( typeof(bool), field.FieldType, "Field '{0}' is wrong type", fieldName );

			ConsoleOptions options = new ConsoleOptions( "-" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize -" + option );
			options = new ConsoleOptions( "--" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize --" + option );
			options = new ConsoleOptions( false, "/" + option );
			Assert.AreEqual( false, (bool)field.GetValue( options ), "Incorrectly recognized /" + option );
			options = new ConsoleOptions( true, "/" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize /" + option );
		}

48. Example

Project: AutoTest.Net
Source File: CommandLineTests.cs
View license
private void TestBooleanOption( string fieldName, string option )
		{
			FieldInfo field = typeof(ConsoleOptions).GetField( fieldName );
			Assert.IsNotNull( field, "Field '{0}' not found", fieldName );
			Assert.AreEqual( typeof(bool), field.FieldType, "Field '{0}' is wrong type", fieldName );

			ConsoleOptions options = new ConsoleOptions( "-" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize -" + option );
			options = new ConsoleOptions( "--" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize --" + option );
			options = new ConsoleOptions( false, "/" + option );
			Assert.AreEqual( false, (bool)field.GetValue( options ), "Incorrectly recognized /" + option );
			options = new ConsoleOptions( true, "/" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize /" + option );
		}

49. Example

Project: AutoTest.Net
Source File: CommandLineTests.cs
View license
[TestCase( "nologo", "nologo")]
		[TestCase( "help", "help" )]
		[TestCase( "help", "?" )]
		[TestCase( "wait", "wait" )]
		[TestCase( "xmlConsole", "xmlConsole")]
		[TestCase( "labels", "labels")]
		[TestCase( "noshadow", "noshadow" )]
		[TestCase( "nothread", "nothread" )]
		public void BooleanOptionAreRecognized( string fieldName, string option )
		{
			FieldInfo field = typeof(ConsoleOptions).GetField( fieldName );
			Assert.IsNotNull( field, "Field '{0}' not found", fieldName );
			Assert.AreEqual( typeof(bool), field.FieldType, "Field '{0}' is wrong type", fieldName );

			ConsoleOptions options = new ConsoleOptions( "-" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize -" + option );
			options = new ConsoleOptions( "--" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize --" + option );
			options = new ConsoleOptions( false, "/" + option );
			Assert.AreEqual( false, (bool)field.GetValue( options ), "Incorrectly recognized /" + option );
			options = new ConsoleOptions( true, "/" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize /" + option );
		}

50. Example

Project: ContinuousTests
Source File: CommandLineTests.cs
View license
private void TestBooleanOption( string fieldName, string option )
		{
			FieldInfo field = typeof(ConsoleOptions).GetField( fieldName );
			Assert.IsNotNull( field, "Field '{0}' not found", fieldName );
			Assert.AreEqual( typeof(bool), field.FieldType, "Field '{0}' is wrong type", fieldName );

			ConsoleOptions options = new ConsoleOptions( "-" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize -" + option );
			options = new ConsoleOptions( "--" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize --" + option );
			options = new ConsoleOptions( false, "/" + option );
			Assert.AreEqual( false, (bool)field.GetValue( options ), "Incorrectly recognized /" + option );
			options = new ConsoleOptions( true, "/" + option );
			Assert.AreEqual( true, (bool)field.GetValue( options ), "Didn't recognize /" + option );
		}