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 AttributeValueBoolean(); var cts = new CancellationTokenSource(); Assert.That( async() => await attributeValueReal.WriteXmlAsync(writer, cts.Token), Throws.Exception.TypeOf <SerializationException>() .With.Message.Contains("The Definition property of an AttributeValueBoolean may not be null")); }
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 AttributeValueBoolean { Definition = new AttributeDefinitionBoolean() }; var cts = new CancellationTokenSource(); cts.Cancel(); Assert.That( async() => await attributeValueReal.WriteXmlAsync(writer, cts.Token), Throws.Exception.TypeOf <OperationCanceledException>()); }