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 attributeValueXhtml = new AttributeValueXHTML(); var cancellationTokenSource = new CancellationTokenSource(); Assert.That(() => attributeValueXhtml.WriteXmlAsync(writer, cancellationTokenSource.Token), Throws.Exception.TypeOf <SerializationException>()); }
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 attributeValueXhtml = new AttributeValueXHTML { Definition = new AttributeDefinitionXHTML() }; var cts = new CancellationTokenSource(); cts.Cancel(); Assert.That( async() => await attributeValueXhtml.WriteXmlAsync(writer, cts.Token), Throws.Exception.TypeOf <OperationCanceledException>()); }