当前位置: 首页>>代码示例>>C#>>正文


C# MockContext.Assert方法代码示例

本文整理汇总了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);
 }
开发者ID:gazzyt,项目名称:LightMock,代码行数:7,代码来源:MockContextTests.cs

示例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);
 }
开发者ID:gazzyt,项目名称:LightMock,代码行数:7,代码来源:MockContextTests.cs

示例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"));
 }
开发者ID:gazzyt,项目名称:LightMock,代码行数:7,代码来源:MockContextTests.cs

示例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);
 }
开发者ID:gazzyt,项目名称:LightMock,代码行数:8,代码来源:MockContextTests.cs

示例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);
        }
开发者ID:neil-119,项目名称:GAE-NET,代码行数:11,代码来源:AuthTests.cs

示例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);
        }
开发者ID:neil-119,项目名称:GAE-NET,代码行数:12,代码来源:AuthTests.cs

示例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);
        }
开发者ID:mgolois,项目名称:DivineChMS,代码行数:18,代码来源:MembersControllerTests.cs

示例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));
        }
开发者ID:gazzyt,项目名称:LightMock,代码行数:9,代码来源:MockContextTests.cs

示例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));
 }
开发者ID:gazzyt,项目名称:LightMock,代码行数:10,代码来源:MockContextTests.cs

示例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);
 }
开发者ID:gazzyt,项目名称:LightMock,代码行数:7,代码来源:MockContextTests.cs

示例11: Assert_Never_IsVerified

 public void Assert_Never_IsVerified()
 {
     var mockContext = new MockContext<IFoo>();
     mockContext.Assert(f => f.Execute("SomeValue"), Invoked.Never);
 }
开发者ID:gazzyt,项目名称:LightMock,代码行数:5,代码来源:MockContextTests.cs

示例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));
 }
开发者ID:gazzyt,项目名称:LightMock,代码行数:10,代码来源:MockContextTests.cs

示例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));
 }
开发者ID:neil-119,项目名称:GAE-NET,代码行数:7,代码来源:DatastoreTests.cs

示例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);

        }
开发者ID:mgolois,项目名称:DivineChMS,代码行数:19,代码来源:MembersControllerTests.cs

示例15: Assert_WithoutInvocation_ThrowsException

 public void Assert_WithoutInvocation_ThrowsException()
 {
     var mockContext = new MockContext<IFoo>();
     mockContext.Assert(f => f.Execute("SomeValue"));
 }
开发者ID:gazzyt,项目名称:LightMock,代码行数:5,代码来源:MockContextTests.cs


注:本文中的MockContext.Assert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。