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

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

58 Examples 7

1. Example

Project: BrightstarDB
Source File: TestUtils.cs
View license
public static void AssertBuffersEqual(byte[] expected, byte[] actual)
        {
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i], "Buffers differed at index {0}", i);
            }
        }

2. Example

Project: AssertMessage
Source File: NunitTests.cs
View license
public void AreEqual_should_have_message_original_formated_message()
        {
            var expected = 1;
            var actual = 2;

            Assert.AreEqual(expected, actual, "{0}_{1}", "original", "message");
        }

3. Example

Project: NStack
Source File: Utf8Test.cs
View license
[Test]
		public void TestEncodeRune ()
		{
			var result = new byte [10];
			Utf8.EncodeRune (0x10000, result);
			foreach (var rm in runeMap) {
				var n = Utf8.EncodeRune (rm.Rune, result);
				for (int i = 0; i < rm.Bytes.Length; i++)
					Assert.AreEqual (rm.Bytes [i], result [i], "Failure with rune {0} (0x{0:x}) at index {1}", rm.Rune, i);
			}
		}

4. Example

View license
[Test]
    public void TestCalcTitleWidthZero ()
    {

      MacroscopeAnalyzePageTitles AnalyzePageTitles = new MacroscopeAnalyzePageTitles ();

      int Width = AnalyzePageTitles.CalcTitleWidth( "" );

      Assert.AreEqual( Width, 0, "Width not equal to zero", 1 );

    }

5. Example

Project: Buildron
Source File: EventAssertExtension.cs
View license
public void Assert()
		{
			NUnit.Framework.Assert.AreEqual (
				m_expectedRaiseCount,
				m_actualRaiseCount, 
				"{0} expected raised {1} times, but was {2}", m_eventName, m_expectedRaiseCount, m_actualRaiseCount);
		}

6. Example

Project: SciChart.Wpf.UI
Source File: XmlCompareTests.cs
View license
public void VerifyAll()
            {
                Assert.AreEqual(expectedCallbacks.Count, nextCallback, "Expected {0} callbacks, but got only {1}.", expectedCallbacks.Count, nextCallback);
            }

7. Example

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

8. Example

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

9. Example

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

10. Example

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

11. Example

Project: BrightstarDB
Source File: PageFileTests.cs
View license
private static void ValidateBuffer(byte[] buffer)
        {
            Assert.AreEqual(8192, buffer.Length);
            for(int i = 0; i < buffer.Length;i++)
            {
                Assert.AreEqual(TestBuffer[i], buffer[i], "Mismatch in buffer at index {0}", i);
            }
        }

12. Example

View license
private static void ValidateSearch(BPlusTree tree, int keyCount, string pageStoreName)
        {
            var value = new byte[64];
            for (int key = 0; key < keyCount; key++)
            {
                Assert.IsTrue(tree.Search((ulong) key, value, null), "Could not find entry for key {0} in store {1}", key, pageStoreName);
                Assert.AreEqual(key, BitConverter.ToInt32(value, 0), "Incorrect value found for key {0} in store {1}", key, pageStoreName);
            }
        }

13. Example

Project: helix-toolkit
Source File: ObjReaderTests.cs
View license
public static void AssertHasVertices(this Model3D model, params double[][] vertices) 
        {
            var geometryModel = (GeometryModel3D) model;
            var geometry = (MeshGeometry3D) geometryModel.Geometry;
            Assert.AreEqual(vertices.Length, geometry.Positions.Count, "Expected to find {0} vertices in model", vertices.Length);
            foreach (var vertex in vertices)
                Assert.IsTrue(geometry.Positions.Contains(new Point3D(vertex[0], vertex[1], vertex[2])), "Expected geometry to contain vertex [{0},{1},{2}]", vertex[0],vertex[1],vertex[2]);
        }

14. Example

Project: mongodb-csharp
Source File: TestCollection.cs
View license
[Test]
        public void TestUpdatePartial()
        {
            var updates = DB["updates"];
            var coolness = 5;
            var einstein = new Document {{"Last", "Einstien"}, {"First", "Albert"}, {"Coolness", coolness++}};
            updates.Insert(einstein);
            var selector = new Document {{"_id", einstein["_id"]}};

            updates.Update(new Document {{"$inc", new Document {{"Coolness", 1}}}}, selector);
            Assert.AreEqual(coolness++, Convert.ToInt32(updates.FindOne(selector)["Coolness"]), "Coolness field not incremented", true);

            updates.Update(new Document
            {
                {"$set", new Document {{"Last", "Einstein"}}},
                {"$inc", new Document {{"Coolness", 1}}}
            },
                selector,
                true);
            Assert.AreEqual(coolness++, Convert.ToInt32(updates.FindOne(selector)["Coolness"]), "Coolness field not incremented");
        }

15. Example

Project: mongodb-csharp
Source File: TestCollection_1.cs
View license
[Test]
        public void TestUpdatePartial(){
            var updates = DB.GetCollection<CountsEntity>("updates");
            var coolness = 5;
            var einstein = new CountsEntity {Last = "Einstein", First = "Albret", Coolness = coolness++};
            updates.Insert(einstein);
            var selector = new {Last = "Einstein"};

            updates.Update(new Document {{"$inc", new Document("cnt", 1)}}, selector);
            Assert.AreEqual(coolness++, Convert.ToInt32(updates.FindOne(selector).Coolness), "Coolness field not incremented", true);

            updates.Update(new Document
            {
                {"$set", new {First = "Albert"}},
                {"$inc", new Document {{"cnt", 1}}}
            },
                selector,
                true);
            Assert.AreEqual(coolness++, Convert.ToInt32(updates.FindOne(selector).Coolness), "Coolness field not incremented");
        }

16. Example

Project: MimeKit
Source File: AssortedTests.cs
View license
[Test]
		public void TestCharsetUtilsGetCodePage ()
		{
			for (int i = 1; i < 16; i++) {
				int/n ..... /n //View Source file for more details /n }

17. Example

Project: helix-toolkit
Source File: ObjReaderTests.cs
View license
public static void AssertContains(this PointCollection collection, params double[][] points) {
            Assert.AreEqual(points.Length, collection.Count, "Expected to find {0} points in collection", points.Length);
            foreach (var point in points)
                Assert.IsTrue(collection.Contains(new Point(point[0],point[1])), "Expected collection to contain point [{0},{1}]", point[0], point[1]);
        }

18. Example

Project: helix-toolkit
Source File: ObjReaderTests.cs
View license
public static void AssertContains(this Point3DCollection collection, params double[][] points) {
            Assert.AreEqual(points.Length, collection.Count, "Expected to find {0} points in collection", points.Length);
            foreach (var point in points)
                Assert.IsTrue(collection.Contains(new Point3D(point[0],point[1],point[2])), "Expected collection to contain point [{0},{1},{2}]", point[0], point[1], point[2]);
        }

19. Example

Project: helix-toolkit
Source File: ObjReaderTests.cs
View license
public static void AssertContains(this Vector3DCollection collection, params double[][] points) {
            Assert.AreEqual(points.Length, collection.Count, "Expected to find {0} points in collection", points.Length);
            foreach (var point in points)
                Assert.IsTrue(collection.Contains(new Vector3D(point[0],point[1],point[2])), "Expected collection to contain point [{0},{1},{2}]", point[0], point[1], point[2]);
        }

20. Example

Project: MimeKit
Source File: ChainedStreamTests.cs
View license
[Test]
		public async void TestWriteAsync ()
		{
			var buffer = new byte[(int) chained.Length];

			for (int i = 0; i < buffer.Length; i++)
				buffer[i] = (byte) (i & 0xff);

			chained.Position = 0;
			await chained.WriteAsync (buffer, 0, buffer.Length);
			await chained.FlushAsync ();

			var array = backing.ToArray ();
			for (int i = 0; i < buffer.Length; i++)
				Assert.AreEqual (buffer[i], array[i], "Written byte @ offset {0} did not match", i);
		}

21. Example

View license
protected void AssertSingle(TaskId task, string messageType)
        {
            var messages = (from m in messageElements
                where m.Name == messageType && task.MatchesTaskElement(m)
                select m.Name.ToString()).ToList();
            Assert.AreEqual(1, messages.Count, "Expected one item of {0} for task {1}", messageType, task);
        }

22. Example

Project: NStack
Source File: Utf8Test.cs
View license
public void TestSequence (ustring s)
		{
			var index = new(int idx, uint rune) [s.Length];
			var si = 0;
			var j = 0;
			foreach ((var i, var rune) in s.Range ()) {
				Assert.AreEqual (i, si, "Sequence mismatch at index {0} = {1}", i, si);
				index [j] = (i, rune);
				j++;
				(var r1, var size1) = Utf8.DecodeRune (Subset (s.ToByteArray (), i, -1));
				Assert.AreEqual (rune, r1, "DecodeRune 0x{0:x} = want 0x{1:x} with {2}", r1, rune, s);
				(var r2, var size2) = Utf8.DecodeRune (s [i, 0]);
				Assert.AreEqual (size1, size2);
				si += size1;
			}
			j--;

			for (si = s.Length; si > 0;) {
				(var r1, var size1) = Utf8.DecodeLastRune (Subset (s.ToByteArray (), 0, si));
				(var r2, var size2) = Utf8.DecodeLastRune (ustring.Make (Subset (s.ToByteArray (), 0, si)));
				(var r3, var size3) = Utf8.DecodeLastRune (s [0, si]);
				Assert.AreEqual (size1, size2);
				Assert.AreEqual (size1, size3);
				Assert.AreEqual (r1, index [j].rune);
				Assert.AreEqual (r2, index [j].rune);
				Assert.AreEqual (r3, index [j].rune);
				si -= size1;
				Assert.AreEqual (si, index [j].idx);
				j--;
			}
			Assert.AreEqual (si, 0, "DecodeLastRune finished at {0} not 0", si);
		}

23. Example

Project: MimeKit
Source File: ChainedStreamTests.cs
View license
[Test]
		public void TestWrite ()
		{
			var buffer = new byte[(int) chained.Length];

			for (int i = 0; i < buffer.Length; i++)
				buffer[i] = (byte) (i & 0xff);

			chained.Position = 0;
			chained.Write (buffer, 0, buffer.Length);
			chained.Flush ();

			var array = backing.ToArray ();
			for (int i = 0; i < buffer.Length; i++)
				Assert.AreEqual (buffer[i], array[i], "Written byte @ offset {0} did not match", i);
		}

24. Example

Project: MimeKit
Source File: ChainedStreamTests.cs
View license
void AssertSeekResults (string operation)
		{
			int n = (int) Math.Min (master.Length - master.Position, mbuf.Length);
			int nread = chained.Read (cbuf, 0, n);
			int mread = master.Read (mbuf, 0, n);

			Assert.AreEqual (mread, nread, "Did not read the expected number of bytes from the chained stream after {0}", operation);
			Assert.AreEqual (master.Position, chained.Position, "The chained stream's position did not match after {0}", operation);

			for (int i = 0; i < n; i++)
				Assert.AreEqual (mbuf[i], cbuf[i], "The bytes read do not match after {0}", operation);
		}

25. Example

View license
private static void ValidateScan(IEnumerable<KeyValuePair<byte [], byte []>> scan, int keyCount, string pageStoreName)
        {
            int ix = 0;
            foreach (var keyValuePair in scan)
            {
                Assert.AreEqual((ulong) ix, BitConverter.ToUInt64(keyValuePair.Key, 0), "Unexpected key at index {0} in test store {1}", ix, pageStoreName);
                Assert.AreEqual(ix, BitConverter.ToInt32(keyValuePair.Value, 0), "Unexpected value at index {0} in test store {1}", ix, pageStoreName);
                ix++;
                Assert.IsTrue(ix <= keyCount, "Scan returned more entries than expected in test store {0}", pageStoreName);
            }
            Assert.AreEqual(keyCount, ix, "Scan returned unexpected number of entries in test store {0}",pageStoreName);
        }

26. Example

Project: MimeKit
Source File: ChainedStreamTests.cs
View license
async Task AssertSeekResultsAsync (string operation)
		{
			int n = (int) Math.Min (master.Length - master.Position, mbuf.Length);
			int nread = await chained.ReadAsync (cbuf, 0, n);
			int mread = await master.ReadAsync (mbuf, 0, n);

			Assert.AreEqual (mread, nread, "Did not read the expected number of bytes from the chained stream after {0}", operation);
			Assert.AreEqual (master.Position, chained.Position, "The chained stream's position did not match after {0}", operation);

			for (int i = 0; i < n; i++)
				Assert.AreEqual (mbuf[i], cbuf[i], "The bytes read do not match after {0}", operation);
		}

27. Example

Project: MimeKit
Source File: EncoderTests.cs
View license
static void AssertState (object encoder, object clone)
		{
			foreach (var field in encoder.GetType ().GetFields (BindingFlags.NonPublic | BindingFlags.Instance)) {
				var expected = field.GetValue (encoder);
				var actual = field.GetValue (clone);

				if (expected.GetType () == typeof (Crc32)) {
					var crc0 = (Crc32) expected;
					var crc1 = (Crc32) actual;

					Assert.AreEqual (crc0.Checksum, crc1.Checksum, "The cloned {0}.{1} does not match.", encoder.GetType ().Name, field.Name);
				} else {
					Assert.AreEqual (expected, actual, "The cloned {0}.{1} does not match.", encoder.GetType ().Name, field.Name);
				}
			}
		}

28. Example

View license
private static void ValidateSenseControls(object iView, bool isSubsense)
		{
			var label = isSubsen/n ..... /n //View Source file for more details /n }

29. Example

Project: BrightstarDB
Source File: StoreTestsBase.cs
View license
public virtual void TestBatchedInserts()
        {
            var sid = "TestBatchedInserts_" + Dat/n ..... /n //View Source file for more details /n }

30. Example

Project: BrightstarDB
Source File: StoreTestsBase.cs
View license
public virtual void TestBatchedInsertsRepeatable()
        {
            var sid = "TestBatchedInser/n ..... /n //View Source file for more details /n }

31. Example

Project: MimeKit
Source File: InternetAddressListTests.cs
View license
static void AssertInternetAddressListsEqual (string text, InternetAddressList expected, InternetAddressList result)
		{
			Assert.AreEqual (expected.Count, result.Count, "Unexpected number of addresses: {0}", text);

			for (int i = 0; i < expected.Count; i++) {
				Assert.AreEqual (expected.GetType (), result.GetType (),  "Address #{0} differs in type: {1}", i, text);

				Assert.AreEqual (expected[i].ToString (), result[i].ToString (), "Display strings differ for {0}", text);
			}

			var encoded = result.ToString (true).Replace ("\r\n", "\n");

			Assert.AreEqual (text, encoded, "Encoded strings differ for {0}", text);
		}

32. Example

View license
protected int GetMessageIndex(TaskId task, string messageType)
        {
            var indices = (messageElements.Select((e, i) => new {Element = e, Index = i})
                .Where(x => x.Element.Name == messageType && task.MatchesTaskElement(x.Element))
                .Select(x => x.Index)).ToList();
            Assert.AreEqual(1, indices.Count, "Expected single message of type {0} for task {1}", messageType, task);
            return indices.Single();
        }

33. Example

Project: MimeKit
Source File: FilteredStreamTests.cs
View license
[Test]
		public void TestRead ()
		{
			using (var original = new MemoryStream ()) {
				using (var file = File.OpenRead ("../../TestData/encoders/photo.jpg"))
					file.CopyTo (original, 4096);

				using (var decoded = new MemoryStream ()) {
					using (var file = File.OpenRead ("../../TestData/encoders/photo.b64")) {
						using (var filtered = new FilteredStream (file)) {
							filtered.Add (DecoderFilter.Create (ContentEncoding.Base64));
							filtered.CopyTo (decoded, 4096);
						}
					}

					var buf0 = original.GetBuffer ();
					var buf1 = decoded.GetBuffer ();
					int n = (int) original.Length;

					Assert.AreEqual (original.Length, decoded.Length, "Decoded length is incorrect.");

					for (int i = 0; i < n; i++)
						Assert.AreEqual (buf0[i], buf1[i], "The byte at offset {0} does not match.", i);
				}
			}
		}

34. Example

Project: MimeKit
Source File: EncoderTests.cs
View license
[Test]
		public void TestUUDecode ()
		{
			using (var original = new MemoryStream ()) {
				using (var file = File.OpenRead ("../../TestData/encoders/photo.jpg"))
					file.CopyTo (original, 4096);

				using (var decoded = new MemoryStream ()) {
					using (var file = File.OpenRead ("../../TestData/encoders/photo.uu")) {
						using (var filtered = new FilteredStream (file)) {
							filtered.Add (DecoderFilter.Create (ContentEncoding.UUEncode));
							filtered.CopyTo (decoded, 4096);
						}
					}

					var buf0 = original.GetBuffer ();
					var buf1 = decoded.GetBuffer ();
					int n = (int) original.Length;

					Assert.AreEqual (original.Length, decoded.Length, "Decoded length is incorrect.");

					for (int i = 0; i < n; i++)
						Assert.AreEqual (buf0[i], buf1[i], "The byte at offset {0} does not match.", i);
				}
			}
		}

35. Example

Project: MimeKit
Source File: FilteredStreamTests.cs
View license
[Test]
		public async void TestReadAsync ()
		{
			using (var original = new MemoryStream ()) {
				using (var file = File.OpenRead ("../../TestData/encoders/photo.jpg"))
					file.CopyTo (original, 4096);

				using (var decoded = new MemoryStream ()) {
					using (var file = File.OpenRead ("../../TestData/encoders/photo.b64")) {
						using (var filtered = new FilteredStream (file)) {
							filtered.Add (DecoderFilter.Create (ContentEncoding.Base64));
							await filtered.CopyToAsync (decoded, 4096);
						}
					}

					var buf0 = original.GetBuffer ();
					var buf1 = decoded.GetBuffer ();
					int n = (int) original.Length;

					Assert.AreEqual (original.Length, decoded.Length, "Decoded length is incorrect.");

					for (int i = 0; i < n; i++)
						Assert.AreEqual (buf0[i], buf1[i], "The byte at offset {0} does not match.", i);
				}
			}
		}

36. Example

Project: maccore
Source File: ApiSignatureTest.cs
View license
[Test]
		public void Signatures ()
		{
			int n = 0;
			Errors = 0;
			
			foreach (Type t in Assembly.GetTypes ()) {

				if (t.IsNested || !NSObjectType.IsAssignableFrom (t))
					continue;

				if (Skip (t))
					continue;

				CurrentType = t;

				FieldInfo fi = t.GetField ("class_ptr", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
				if (fi == null)
					continue; // e.g. *Delegate
				IntPtr class_ptr = (IntPtr) fi.GetValue (null);

				foreach (MethodBase m in t.GetMethods (BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance)) 
					CheckMemberSignature (m, t, class_ptr, ref n);
				foreach (MethodBase m in t.GetConstructors (BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance)) 
					CheckMemberSignature (m, t, class_ptr, ref n);
			}
			Assert.AreEqual (0, Errors, "{0} errors found in {1} signatures validated", Errors, n);
		}

37. Example

Project: MimeKit
Source File: MimePartTests.cs
View license
[Test]
		public async void TestTranscodingAsync ()
		{
			var path = Path.Combine ("..", "..", "TestData", "images", "girl.jpg");
			var expected = File.ReadAllBytes (path);

			var part = new MimePart ("image", "jpeg") {
				ContentObject = new ContentObject (new MemoryStream (expected, false)),
				ContentTransferEncoding = ContentEncoding.Base64,
				FileName = "girl.jpg"
			};

			// encode in base64
			using (var output = new MemoryStream ()) {
				await part.WriteToAsync (output);
				output.Position = 0;

				part = (MimePart) await MimeEntity.LoadAsync (output);
			}

			// transcode to uuencode
			part.ContentTransferEncoding = ContentEncoding.UUEncode;
			using (var output = new MemoryStream ()) {
				await part.WriteToAsync (output);
				output.Position = 0;

				part = (MimePart) await MimeEntity.LoadAsync (output);
			}

			// verify decoded content
			using (var output = new MemoryStream ()) {
				await part.ContentObject.DecodeToAsync (output);
				output.Position = 0;

				var actual = output.ToArray ();

				Assert.AreEqual (expected.Length, actual.Length);
				for (int i = 0; i < expected.Length; i++)
					Assert.AreEqual (expected[i], actual[i], "Image content differs at index {0}", i);
			}
		}

38. Example

View license
protected void AssertContainsFinish(TaskId task, string expectedTaskResult, string expectedMessage = null)
        {
            var messages = (from e in messageElements
                where e.Name == TaskAction.Finish && task.MatchesTaskElement(e)
                select new
                {
                    Result = e.Attribute("result").Value,
                    Message = GetElementValue(e, "message")
                }).ToList();
            Assert.AreEqual(1, messages.Count, "Expected single message of type {0} for task {1}", TaskAction.Finish, task);
            var result = messages.Single();
            Assert.AreEqual(expectedTaskResult, result.Result);
            if (!string.IsNullOrEmpty(expectedMessage))
                Assert.AreEqual(expectedMessage, result.Message);
        }

39. Example

Project: MimeKit
Source File: MimePartTests.cs
View license
[Test]
		public void TestTranscoding ()
		{
			var path = Path.Combine ("..", "..", "TestData", "images", "girl.jpg");
			var expected = File.ReadAllBytes (path);

			var part = new MimePart ("image", "jpeg") {
				ContentObject = new ContentObject (new MemoryStream (expected, false)),
				ContentTransferEncoding = ContentEncoding.Base64,
				FileName = "girl.jpg"
			};

			// encode in base64
			using (var output = new MemoryStream ()) {
				part.WriteTo (output);
				output.Position = 0;

				part = (MimePart) MimeEntity.Load (output);
			}

			// transcode to uuencode
			part.ContentTransferEncoding = ContentEncoding.UUEncode;
			using (var output = new MemoryStream ()) {
				part.WriteTo (output);
				output.Position = 0;

				part = (MimePart) MimeEntity.Load (output);
			}

			// verify decoded content
			using (var output = new MemoryStream ()) {
				part.ContentObject.DecodeTo (output);
				output.Position = 0;

				var actual = output.ToArray ();

				Assert.AreEqual (expected.Length, actual.Length);
				for (int i = 0; i < expected.Length; i++)
					Assert.AreEqual (expected[i], actual[i], "Image content differs at index {0}", i);
			}
		}

40. Example

Project: maccore
Source File: ApiFieldTest.cs
View license
[Test]
		public void NonNullNSStringFields ()
		{
			Errors = 0;
			int c = 0, n = 0;
			foreach (Type t in Assembly.GetTypes ()) {
				if (Skip (t) || SkipDueToAttribute (t))
					continue;

				if (LogProgress)
					Console.WriteLine ("{0}. {1}", c++, t.FullName);

				foreach (var p in t.GetProperties (BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) {
					// looking for properties with getters only
					if (p.CanWrite || !p.CanRead)
						continue;
					
					// FIXME: testing NSString only (vast majority but there are others)
					if (p.PropertyType.FullName != NSStringType)
						continue;

					string name;
					bool result = CheckAgainstNull (p, out name);
					if (!ContinueOnFailure)
						Assert.IsTrue (result, name);
					else if (!result) {
						Console.WriteLine ("[FAIL] {0}", name);
						Errors++;
					}
					n++;
				}
			}
			Assert.AreEqual (0, Errors, "{0} errors found in {1} fields validated", Errors, n);
		}

41. Example

Project: MimeKit
Source File: FilteredStreamTests.cs
View license
[Test]
		public void TestWrite ()
		{
			using (var original = new MemoryStream ()) {
				using (var file = File.OpenRead ("../../TestData/encoders/photo.jpg"))
					file.CopyTo (original, 4096);

				using (var decoded = new MemoryStream ()) {
					using (var file = File.OpenRead ("../../TestData/encoders/photo.b64")) {
						using (var filtered = new FilteredStream (decoded)) {
							filtered.Add (DecoderFilter.Create (ContentEncoding.Base64));
							file.CopyTo (filtered, 4096);
							filtered.Flush ();
						}
					}

					var buf0 = original.GetBuffer ();
					var buf1 = decoded.GetBuffer ();
					int n = (int) original.Length;

					Assert.AreEqual (original.Length, decoded.Length, "Decoded length is incorrect.");

					for (int i = 0; i < n; i++)
						Assert.AreEqual (buf0[i], buf1[i], "The byte at offset {0} does not match.", i);
				}
			}
		}

42. Example

Project: MimeKit
Source File: YEncodingTests.cs
View license
[Test]
		public void TestYDecodeMultiPart ()
		{
			var expected = File.ReadAllBytes ("../../TestData/yenc/joystick.jpg");

			using (var decoded = new MemoryStream ()) {
				using (var file = File.OpenRead ("../../TestData/yenc/00000020.ntx")) {
					var ydec = new YDecoder ();

					using (var filtered = new FilteredStream (decoded)) {
						filtered.Add (new DecoderFilter (ydec));
						file.CopyTo (filtered, 1);
						filtered.Flush ();
					}

					Assert.AreEqual (11250, decoded.Length, "The decoded size does not match (part 1).");
					Assert.AreEqual (0xbfae5c0b, ydec.Checksum ^ 0xffffffff, "The decoded checksum does not match (part 1).");
				}

				using (var file = File.OpenRead ("../../TestData/yenc/00000021.ntx")) {
					var ydec = new YDecoder ();

					using (var filtered = new FilteredStream (decoded)) {
						filtered.Add (new DecoderFilter (ydec));
						file.CopyTo (filtered, 1);
						filtered.Flush ();
					}

					Assert.AreEqual (19338, decoded.Length, "The decoded size does not match (part 2).");
					Assert.AreEqual (0xaca76043, ydec.Checksum ^ 0xffffffff, "The decoded checksum does not match (part 2).");
				}

				var actual = decoded.GetBuffer ();

				for (int i = 0; i < expected.Length; i++)
					Assert.AreEqual (expected[i], actual[i], "different content at index {0}", i);
			}
		}

43. Example

Project: MimeKit
Source File: EncoderTests.cs
View license
[Test]
		public void TestBase64Encode ()
		{
			using (var original = new MemoryStream ()) {
				using (var file = File.OpenRead ("../../TestData/encoders/photo.b64")) {
					using (var filtered = new FilteredStream (original)) {
						filtered.Add (new Dos2UnixFilter ());
						file.CopyTo (filtered, 4096);
						filtered.Flush ();
					}
				}

				using (var encoded = new MemoryStream ()) {
					using (var filtered = new FilteredStream (encoded)) {
						filtered.Add (EncoderFilter.Create (ContentEncoding.Base64));

						using (var file = File.OpenRead ("../../TestData/encoders/photo.jpg"))
							file.CopyTo (filtered, 4096);

						filtered.Flush ();
					}

					var buf0 = original.GetBuffer ();
					var buf1 = encoded.GetBuffer ();
					int n = (int) original.Length;

					Assert.AreEqual (original.Length, encoded.Length, "Encoded length is incorrect.");

					for (int i = 0; i < n; i++)
						Assert.AreEqual (buf0[i], buf1[i], "The byte at offset {0} does not match.", i);
				}
			}
		}

44. Example

Project: MimeKit
Source File: FilteredStreamTests.cs
View license
[Test]
		public async void TestWriteAsync ()
		{
			using (var original = new MemoryStream ()) {
				using (var file = File.OpenRead ("../../TestData/encoders/photo.jpg"))
					file.CopyTo (original, 4096);

				using (var decoded = new MemoryStream ()) {
					using (var file = File.OpenRead ("../../TestData/encoders/photo.b64")) {
						using (var filtered = new FilteredStream (decoded)) {
							filtered.Add (DecoderFilter.Create (ContentEncoding.Base64));
							await file.CopyToAsync (filtered, 4096);
							await filtered.FlushAsync ();
						}
					}

					var buf0 = original.GetBuffer ();
					var buf1 = decoded.GetBuffer ();
					int n = (int) original.Length;

					Assert.AreEqual (original.Length, decoded.Length, "Decoded length is incorrect.");

					for (int i = 0; i < n; i++)
						Assert.AreEqual (buf0[i], buf1[i], "The byte at offset {0} does not match.", i);
				}
			}
		}

45. Example

Project: Gorgon
Source File: TarTests.cs
View license
[Test]
        [Category("Tar")]
        public void BlockFactorHandling()
		{
			const int MinimumB/n ..... /n //View Source file for more details /n }

46. Example

Project: SharpZipLib
Source File: TarTests.cs
View license
[Test]
		[Category("Tar")]
		public void BlockFactorHandling()
		{
			const int MinimumBlockFactor =/n ..... /n //View Source file for more details /n }

47. Example

View license
[Test]
        public void New_TryEnqueueItem_x50_TryEnqueueConsumer_x50_ItemCount_ConsumerCount() {/n ..... /n //View Source file for more details /n }

48. Example

Project: ActivityManager
Source File: TarTests.cs
View license
[Test]
        [Category("Tar")]
        public void BlockFactorHandling()
		{
			const int MinimumB/n ..... /n //View Source file for more details /n }

49. Example

Project: MimeKit
Source File: EncoderTests.cs
View license
[Test]
		public void TestUUEncode ()
		{
			using (var original = new MemoryStream ()) {
				using (var file = File.OpenRead ("../../TestData/encoders/photo.uu")) {
					using (var filtered = new FilteredStream (original)) {
						filtered.Add (new Dos2UnixFilter ());
						file.CopyTo (filtered, 4096);
						filtered.Flush ();
					}
				}

				using (var encoded = new MemoryStream ()) {
					var begin = Encoding.ASCII.GetBytes ("begin 644 photo.jpg\n");
					var end = Encoding.ASCII.GetBytes ("end\n");

					encoded.Write (begin, 0, begin.Length);

					using (var filtered = new FilteredStream (encoded)) {
						filtered.Add (EncoderFilter.Create (ContentEncoding.UUEncode));

						using (var file = File.OpenRead ("../../TestData/encoders/photo.jpg"))
							file.CopyTo (filtered, 4096);

						filtered.Flush ();
					}

					encoded.Write (end, 0, end.Length);

					var buf0 = original.GetBuffer ();
					var buf1 = encoded.GetBuffer ();
					int n = (int) original.Length;

					Assert.AreEqual (original.Length, encoded.Length, "Encoded length is incorrect.");

					for (int i = 0; i < n; i++)
						Assert.AreEqual (buf0[i], buf1[i], "The byte at offset {0} does not match.", i);
				}
			}
		}

50. Example

Project: maccore
Source File: ApiSelectorTest.cs
View license
[Test]
		public void StaticMethods ()
		{
			Errors = 0;
			int n = 0;
			
			IntPtr responds_handle = Selector.GetHandle ("respondsToSelector:");
			
			foreach (Type t in Assembly.GetTypes ()) {
				if (t.IsNested || !NSObjectType.IsAssignableFrom (t))
					continue;

				if (Skip (t) || SkipDueToAttribute (t))
					continue;

				FieldInfo fi = t.GetField ("class_ptr", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
				if (fi == null)
					continue; // e.g. *Delegate
				IntPtr class_ptr = (IntPtr) fi.GetValue (null);
				
				foreach (var m in t.GetMethods (BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static)) {
					if (SkipDueToAttribute (m))
						continue;

					foreach (object ca in m.GetCustomAttributes (true)) {
						if (ca is ExportAttribute) {
							string name = (ca as ExportAttribute).Selector;
							bool result = Messaging.bool_objc_msgSend_IntPtr (class_ptr, responds_handle, Selector.GetHandle (name));
							bool response = CheckStaticResponse (result, t, m.DeclaringType, ref name);
							if (!ContinueOnFailure)
								Assert.IsTrue (response, name);
							else if (!response) {
								Console.WriteLine ("[FAIL] {0}", name);
								Errors++;
							}
							n++;
						}
					}
				}
			}
			Assert.AreEqual (0, Errors, "{0} errors found in {1} static selector validated", Errors, n);
		}