public void ListDecode_EmptyList_Positive() { BList expectedList = new BList() { Value = new IBObject[] { } }; var inputBytes = "le".GetASCIIBytes(); var inputStream = new MemoryStream(inputBytes); var transform = new ListTransform(new BObjectTransform()); BList actualList = transform.Decode(inputStream); Assert.AreEqual<BObjectType>(expectedList.BType, actualList.BType); Assert.AreEqual<int>(actualList.Value.Length, expectedList.Value.Length); }
public void ListDecode_NestedList_Positive() { BList expectedList = new BList() { Value = new IBObject[] { new BList() { Value = new IBObject[] { } } } }; var inputBytes = "llee".GetASCIIBytes(); var inputStream = new MemoryStream(inputBytes); var transform = new ListTransform(new BObjectTransform()); BList actualList = transform.Decode(inputStream); // Validate outer list: Assert.AreEqual<BObjectType>(expectedList.BType, actualList.BType); Assert.AreEqual<int>(1, actualList.Value.Length); // Validate nested list: Assert.AreEqual<BObjectType>(BObjectType.List, actualList.Value[0].BType); Assert.AreEqual<int>(0, ((BList)actualList.Value[0]).Value.Length); }
public void ListDecode_RegularList_Positive() { BList expectedList = new BList() { Value = new IBObject[] { new BInteger(9L), new BByteString() { Value = "spam".GetASCIIBytes() } } }; var inputBytes = "li9e4:spame".GetASCIIBytes(); var inputStream = new MemoryStream(inputBytes); var transform = new ListTransform(new BObjectTransform()); BList actualList = transform.Decode(inputStream); Assert.AreEqual<BObjectType>(expectedList.BType, actualList.BType); Assert.AreEqual<int>(expectedList.Value.Length, actualList.Value.Length); Assert.AreEqual<BObjectType>(expectedList.Value[0].BType, actualList.Value[0].BType); Assert.AreEqual<long>( ((BInteger)expectedList.Value[0]).Value, ((BInteger)actualList.Value[0]).Value); Assert.AreEqual<string>( ((BByteString)expectedList.Value[1]).ConvertToText(Encoding.ASCII), ((BByteString)actualList.Value[1]).ConvertToText(Encoding.ASCII)); }
public void ListDecode_NullListParam_Exception() { var transform = new ListTransform(new BObjectTransform()); transform.Decode(null); }