Пример #1
0
        public void Verify_That_WriteXmlAsync_Without_Definition_Set_Throws_SerializationException()
        {
            using var memoryStream = new MemoryStream();
            using var writer       = XmlWriter.Create(memoryStream, new XmlWriterSettings { Indent = true });
            var attributeValueString = new AttributeValueString();

            var cancellationTokenSource = new CancellationTokenSource();

            Assert.That(() => attributeValueString.WriteXmlAsync(writer, cancellationTokenSource.Token),
                        Throws.Exception.TypeOf <SerializationException>());
        }
Пример #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 attributeValueString = new AttributeValueString
            {
                Definition = new AttributeDefinitionString()
            };

            var cts = new CancellationTokenSource();

            cts.Cancel();

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