static bool AsyncWriteBase64Test(MemoryStream ms, byte[] byteArray, Encoding encoding, MyStreamProvider myStreamProvider)
 {
     XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(ms);
     writer.WriteStartElement("Root");
     Task writeValueBase64Asynctask = writer.WriteBase64Async(byteArray, 0, byteArray.Length);
     writeValueBase64Asynctask.Wait();
     Assert.True(myStreamProvider.StreamReleased, "Error, stream not released.");
     writer.WriteEndElement();
     writer.Flush();
     return true;
 }
Example #2
0
    static bool AsyncWriteBase64Test(MemoryStream ms, byte[] byteArray, Encoding encoding, MyStreamProvider myStreamProvider)
    {
        XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(ms);

        writer.WriteStartElement("Root");
        Task writeValueBase64Asynctask = writer.WriteBase64Async(byteArray, 0, byteArray.Length);

        writeValueBase64Asynctask.Wait();

        if (myStreamProvider.StreamReleased)
        {
            Console.WriteLine("Ok, stream released right after AsyncWriteValueBase64");
        }
        else
        {
            Console.WriteLine("Error, stream not released after AsyncWriteValueBase64");
            return(false);
        }
        writer.WriteEndElement();
        writer.Flush();
        return(true);
    }