本文整理汇总了C#中MockContext.Assert方法的典型用法代码示例。如果您正苦于以下问题:C# MockContext.Assert方法的具体用法?C# MockContext.Assert怎么用?C# MockContext.Assert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MockContext
的用法示例。
在下文中一共展示了MockContext.Assert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Assert_InvokedOnceExpectedOnce_IsVerified
public void Assert_InvokedOnceExpectedOnce_IsVerified()
{
var mockContext = new MockContext<IFoo>();
var fooMock = new FooMock(mockContext);
fooMock.Execute("SomeValue");
mockContext.Assert(f => f.Execute("SomeValue"), Invoked.Once);
}
示例2: Assert_NeverWhenInvoked_ThrowsException
public void Assert_NeverWhenInvoked_ThrowsException()
{
var mockContext = new MockContext<IFoo>();
var fooMock = new FooMock(mockContext);
fooMock.Execute("SomeValue");
mockContext.Assert(f => f.Execute("SomeValue"), Invoked.Never);
}
示例3: Assert_Once_IsVerified
public void Assert_Once_IsVerified()
{
var mockContext = new MockContext<IFoo>();
var fooMock = new FooMock(mockContext);
fooMock.Execute("SomeValue");
mockContext.Assert(f => f.Execute("SomeValue"));
}
示例4: Assert_InvokedTwiceWithExpectedOnce_ThrowsException
public void Assert_InvokedTwiceWithExpectedOnce_ThrowsException()
{
var mockContext = new MockContext<IFoo>();
var fooMock = new FooMock(mockContext);
fooMock.Execute("SomeValue");
fooMock.Execute("SomeValue");
mockContext.Assert(f => f.Execute("SomeValue"), Invoked.Once);
}
示例5: Cloud_auth_object_returns_project_id
public void Cloud_auth_object_returns_project_id()
{
var mockContext = new MockContext<CloudAuthenticator>();
mockContext.Arrange(f => f.GetProjectId()).Returns("ProjectId");
var cloudAuthMock = new CloudAuthenticatorMock(mockContext);
var result = cloudAuthMock.GetProjectId();
mockContext.Assert(f => f.GetProjectId(), Invoked.Once);
Assert.Equal("ProjectId", result);
}
示例6: Cloud_auth_object_returns_initializer
public void Cloud_auth_object_returns_initializer()
{
var initializer = new BaseClientService.Initializer();
var mockContext = new MockContext<CloudAuthenticator>();
mockContext.Arrange(f => f.GetInitializer()).Returns(initializer);
var cloudAuthMock = new CloudAuthenticatorMock(mockContext);
var result = cloudAuthMock.GetInitializer();
mockContext.Assert(f => f.GetInitializer(), Invoked.Once);
Assert.Equal(initializer, result);
}
示例7: GetMemberById_WithInvalidPoisitiveId_ReturnsError
public async Task GetMemberById_WithInvalidPoisitiveId_ReturnsError()
{
//Arrange
var mockContext = new MockContext<IRepository<Member>>();
membersRepo = new FakeMemberRepository(mockContext);
var controller = new MembersController(new DivineRepositories(null, lookupRepo, membersRepo, null), logger, null, null);
mockContext.Arrange(m => m.GetByIdAsync(The<int>.IsAnyValue)).Returns(Task.FromResult(default(Member)));
var id = 10000000;
//Act
var result = await controller.Get(id);
//Assert
mockContext.Assert(m => m.GetByIdAsync(id), Invoked.Once);
Assert.NotNull(result);
Assert.Equal(result.StatusCode, (int)HttpStatusCode.BadRequest);
Assert.IsType<string>(result.Value);
Assert.Contains("error", result.Value.ToString(), StringComparison.OrdinalIgnoreCase);
}
示例8: Assert_Null_IsVerified
public void Assert_Null_IsVerified()
{
var mockContext = new MockContext<IFoo>();
var fooMock = new FooMock(mockContext);
fooMock.Execute((string)null);
mockContext.Assert(f => f.Execute((string)null));
}
示例9: Assert_ExpectedExactly3TimesAnd4TimesInvoked_ThrowsException
public void Assert_ExpectedExactly3TimesAnd4TimesInvoked_ThrowsException()
{
var mockContext = new MockContext<IFoo>();
var fooMock = new FooMock(mockContext);
fooMock.Execute("SomeValue");
fooMock.Execute("SomeValue");
fooMock.Execute("SomeValue");
fooMock.Execute("SomeValue");
mockContext.Assert(f => f.Execute("SomeValue"), Invoked.Exactly(3));
}
示例10: Assert_IsAnyValue_IsVerified
public void Assert_IsAnyValue_IsVerified()
{
var mockContext = new MockContext<IFoo>();
var fooMock = new FooMock(mockContext);
fooMock.Execute("SomeValue");
mockContext.Assert(f => f.Execute(The<string>.IsAnyValue), Invoked.Once);
}
示例11: Assert_Never_IsVerified
public void Assert_Never_IsVerified()
{
var mockContext = new MockContext<IFoo>();
mockContext.Assert(f => f.Execute("SomeValue"), Invoked.Never);
}
示例12: Assert_ExpectedAtLeast3TimesAnd4TimesInvoked_IsVerified
public void Assert_ExpectedAtLeast3TimesAnd4TimesInvoked_IsVerified()
{
var mockContext = new MockContext<IFoo>();
var fooMock = new FooMock(mockContext);
fooMock.Execute("SomeValue");
fooMock.Execute("SomeValue");
fooMock.Execute("SomeValue");
fooMock.Execute("SomeValue");
mockContext.Assert(f => f.Execute("SomeValue"), Invoked.AtLeast(3));
}
示例13: Datastore_service_delete_accepts_entity_object
public void Datastore_service_delete_accepts_entity_object()
{
var mockContext = new MockContext<IDatastoreService>();
var datastoreMock = new DatastoreServiceMock(mockContext);
datastoreMock.Delete(new TestModel());
mockContext.Assert(f => f.Delete(The<TestModel>.IsAnyValue));
}
示例14: SearchMember_WithNullParameter_ReturnsError
public async Task SearchMember_WithNullParameter_ReturnsError()
{
//Arrange
var mockContext = new MockContext<IRepository<Member>>();
membersRepo = new FakeMemberRepository(mockContext);
var controller = new MembersController(new DivineRepositories(null, lookupRepo, membersRepo, null), logger, null, null);
var searchData = default(SearchMember); //null
//Act
var result = await controller.SearchMembers(searchData);
//Assert
mockContext.Assert(m => m.GetAllAsync(), Invoked.Never);
Assert.NotNull(result);
Assert.Equal(result.StatusCode, (int)HttpStatusCode.BadRequest);
Assert.IsType<string>(result.Value);
Assert.Contains("error", result.Value.ToString(), StringComparison.OrdinalIgnoreCase);
}
示例15: Assert_WithoutInvocation_ThrowsException
public void Assert_WithoutInvocation_ThrowsException()
{
var mockContext = new MockContext<IFoo>();
mockContext.Assert(f => f.Execute("SomeValue"));
}