Exemplo n.º 1
0
        public void Verify_That_WriteXmlAsync_Without_Definition_Set_Throws_SerializationException()
        {
            var cancellationTokenSource = new CancellationTokenSource();

            using var memoryStream = new MemoryStream();
            using var writer       = XmlWriter.Create(memoryStream, new XmlWriterSettings { Indent = true });
            var attributeValueDate = new AttributeValueDate();

            Assert.That(async() => await attributeValueDate.WriteXmlAsync(writer, cancellationTokenSource.Token),
                        Throws.Exception.TypeOf <SerializationException>());
        }
Exemplo n.º 2
0
        public void Verify_That_WriteXmlAsync_Throws_Exception_when_cancelled()
        {
            using var memoryStream = new MemoryStream();
            using var writer       = XmlWriter.Create(memoryStream, new XmlWriterSettings { Indent = true });

            var attributeValueDate = new AttributeValueDate
            {
                Definition = new AttributeDefinitionDate()
            };

            var cts = new CancellationTokenSource();

            cts.Cancel();

            Assert.That(
                async() => await attributeValueDate.WriteXmlAsync(writer, cts.Token),
                Throws.Exception.TypeOf <OperationCanceledException>());
        }