Exemplo n.º 1
0
        public async Task Serialize(bool async)
        {
            byte[] buff = new byte[TestBufferSize];
            rand.NextBytes(buff);
            var expectedStream = new MemoryStream(buff);
            var actualStream   = new MemoryStream();

            var cache = new TokenCache(buff);

            if (async)
            {
                await TokenCacheSerializer.SerializeAsync(cache, actualStream);
            }
            else
            {
                TokenCacheSerializer.Serialize(cache, actualStream);
            }

            expectedStream.Position = 0;
            actualStream.Position   = 0;

            Assert.That(expectedStream.Length, Is.EqualTo(actualStream.Length));
            Assert.That(expectedStream.ToArray(), Is.EquivalentTo(actualStream.ToArray()));
        }
Exemplo n.º 2
0
 public void SerializeInputChecks(TokenCache cache, Stream stream)
 {
     Assert.Throws <ArgumentNullException>(() => TokenCacheSerializer.Serialize(cache, stream));
     Assert.ThrowsAsync <ArgumentNullException>(async() => await TokenCacheSerializer.SerializeAsync(cache, stream));
 }