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