public void Generate_map_null_serialize_empty() { var input = new TestMapStrings { MapTest = null }; var serial = new BlazeSerializer(); var resultStream = new MemoryStream(); //Act serial.SerializeObjectProperties(resultStream, input, new StringBuilder()); //Assert var result = resultStream.ToArray(); result.Should().BeEmpty(); }
public void Generates_map_strings() { var input = new TestMapStrings { MapTest = new Dictionary <int, string> { { 1, "Test1" }, { 2, "areallylongstring" }, { 3, "testing" } } }; var serial = new BlazeSerializer(); var resultStream = new MemoryStream(); //Act serial.SerializeObjectProperties(resultStream, input, new StringBuilder()); //Assert var validBody = new byte[] { 0xd3, 0x3d, 0x21, //TSTA 0xc3, //map, 3 elements 0x6f, 0x04, //int length 4, 0x00, 0x00, 0x00, 0x01, 0x1F, 0x06, // string, length 6 0x54, 0x65, 0x73, 0x74, 0x31, 0x00, //Test1 0x00, 0x00, 0x00, 0x02, 0x12, //18 length 0x61, 0x72, 0x65, 0x61, 0x6C, 0x6C, 0x79, 0x6C, 0x6F, 0x6E, 0x67, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x00, //areallylongstring 0x00, 0x00, 0x00, 0x03, 0x08, //8 length 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x00, }; var result = resultStream.ToArray(); result.Should().BeEquivalentTo(validBody); }