gpt4 book ai didi

fluent-assertions - 如何比较两个 MemoryStream 与 FluentAssertions

转载 作者:行者123 更新时间:2023-12-05 01:21:04 26 4
gpt4 key购买 nike

使用 FluentAssertion 3.1.229 , 你如何比较两个不同的 MemoryStream内容

编写 actualStream.Should().Be(expectedStream); 会产生以下错误:

System.IO.MemoryStream
{
CanRead = True
CanSeek = True
CanTimeout = False
CanWrite = True
Capacity = 8
Length = 8
Position = 0
ReadTimeout = "[Property 'ReadTimeout' threw an exception: 'Exception has been thrown by the target of an invocation.']"
WriteTimeout = "[Property 'WriteTimeout' threw an exception: 'Exception has been thrown by the target of an invocation.']"
}, but found

System.IO.MemoryStream
{
CanRead = True
CanSeek = True
CanTimeout = False
CanWrite = True
Capacity = 8
Length = 8
Position = 0
ReadTimeout = "[Property 'ReadTimeout' threw an exception: 'Exception has been thrown by the target of an invocation.']"
WriteTimeout = "[Property 'WriteTimeout' threw an exception: 'Exception has been thrown by the target of an invocation.']"
}.

是的,我可以使用 NUnit Assert.That(actualStream, Is.EqualTo(expectedStream)); 但是 FluentAssertions 可以吗?

谢谢。

最佳答案

也许这对你有用?

actualStream.ToArray().Should().Be(expectedStream.ToArray());

关于fluent-assertions - 如何比较两个 MemoryStream 与 FluentAssertions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25631552/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com