public void ReadBytesAsync_in_write_only_mode()
        {
            using (JsonStreamMock jsonStream = new JsonStreamMock(new MemoryStream(), Modes.WriteOnly))
            {
                ForbiddenOperationException exception = Assert.ThrowsException <ForbiddenOperationException>(() =>
                {
                    jsonStream.ReadBytesAsync().GetAwaiter().GetResult();
                });

                Assert.AreEqual("Can't read in WriteOnly mode.", exception.Message);
            }
        }
        public void ReadBytesAsync_using_optimized_constructor()
        {
            using (JsonStreamMock jsonStream = new JsonStreamMock(Modes.ReadAndWrite, GetTestFileName()))
            {
                ForbiddenOperationException exception = Assert.ThrowsException <ForbiddenOperationException>(() =>
                {
                    jsonStream.ReadBytesAsync().GetAwaiter().GetResult();
                });

                Assert.AreEqual("Do not call any async method when using optimized constructor.", exception.Message);
            }
        }