请问关于c的具体应用场景有哪些?

2026-04-28 05:321阅读0评论SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计208个文字,预计阅读时间需要1分钟。

请问关于c的具体应用场景有哪些?

可以测试使用Rhino.Mocks 3.5未调用的属性设置器。以下是一个简化的示例代码:

csharppublic class OneProperty{ virtual public int MyInt { get; set; }

[Test] public void IntWasSet() { var prop=Rhino.Mocks.MockRepository.GenerateMockOneProperty(); prop.MyInt=10; // 验证属性是否被设置 Rhino.Mocks.Assert.IsEqual(10, prop.MyInt); }}

请问关于c的具体应用场景有哪些?

是否可以测试使用Rhino Mocks 3.5未调用属性设置器? 这完全有可能:

public class OneProperty { virtual public int MyInt { get; set; } } [Test] public void IntWasSet() { var prop = Rhino.Mocks.MockRepository.GenerateMock<OneProperty>(); prop.MyInt = 5; prop.AssertWasNotCalled(x => x.MyInt = Arg<int>.Is.Anything); prop.VerifyAllExpectations(); }

在Rhino Mocks 3.5上运行此测试会导致以下错误:

Errors and Failures: 1) Test Error :
InterfacerTests.TestMatchesInterface.IntWasSet
Rhino.Mocks.Exceptions.ExpectationViolationException
: Expected that
OneProperty.set_MyInt(anything); would
not be called, but it was found on the
actual calls made on the mocked
object.

我发现了Arg< T>语法from this part of the Rhino documentation.

本文共计208个文字,预计阅读时间需要1分钟。

请问关于c的具体应用场景有哪些?

可以测试使用Rhino.Mocks 3.5未调用的属性设置器。以下是一个简化的示例代码:

csharppublic class OneProperty{ virtual public int MyInt { get; set; }

[Test] public void IntWasSet() { var prop=Rhino.Mocks.MockRepository.GenerateMockOneProperty(); prop.MyInt=10; // 验证属性是否被设置 Rhino.Mocks.Assert.IsEqual(10, prop.MyInt); }}

请问关于c的具体应用场景有哪些?

是否可以测试使用Rhino Mocks 3.5未调用属性设置器? 这完全有可能:

public class OneProperty { virtual public int MyInt { get; set; } } [Test] public void IntWasSet() { var prop = Rhino.Mocks.MockRepository.GenerateMock<OneProperty>(); prop.MyInt = 5; prop.AssertWasNotCalled(x => x.MyInt = Arg<int>.Is.Anything); prop.VerifyAllExpectations(); }

在Rhino Mocks 3.5上运行此测试会导致以下错误:

Errors and Failures: 1) Test Error :
InterfacerTests.TestMatchesInterface.IntWasSet
Rhino.Mocks.Exceptions.ExpectationViolationException
: Expected that
OneProperty.set_MyInt(anything); would
not be called, but it was found on the
actual calls made on the mocked
object.

我发现了Arg< T>语法from this part of the Rhino documentation.