private void TestBList(List <BObject> testList) { BList bList = new BList(testList); byte[] encoded = bList.Encode(); Assert.True(BObject.TryParse(encoded, out BList bObject)); Assert.True(bList.Equals(bObject)); using (MemoryStream ms = new MemoryStream()) { bList.Encode(ms); encoded = ms.ToArray(); } Assert.True(BObject.TryParse(encoded, out bObject)); Assert.True(bList.Equals(bObject)); Assert.Equal(encoded.Length, bList.GetEncodedSize()); }
public void EqualityList() { // Make initial list BList testList = new BList(); BString testString = new BString("Hello World"); BInt testInt = new BInt(5); testList.Add(testString); testList.Add(testInt); // Make test list BList testList2 = new BList(); BString testString2 = new BString("Hello World"); BInt testInt2 = new BInt(5); testList2.Add(testString2); testList2.Add(testInt2); // Test equality recursive Assert.AreEqual(testList, testList2); // Test null list BList nullList = null; Assert.IsFalse(testList.Equals(nullList)); // Test different counts testList2.Add(new BInt(10)); Assert.IsFalse(testList.Equals(testList2)); // Test different values testList.Add(new BInt(9)); Assert.IsFalse(testList.Equals(testList2)); }