• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MockContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MockContext的典型用法代码示例。如果您正苦于以下问题:C# MockContext类的具体用法?C# MockContext怎么用?C# MockContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MockContext类属于命名空间,在下文中一共展示了MockContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Assert_WithValidMatchPredicate_IsVerified

 public void Assert_WithValidMatchPredicate_IsVerified()
 {
     var mockContext = new MockContext<IFoo>();
     var fooMock = new FooMock(mockContext);
     fooMock.Execute("SomeValue");
     mockContext.Assert(f => f.Execute(The<string>.Is(s => s.StartsWith("Some"))), Invoked.Once);
 }
开发者ID:gazzyt,项目名称:LightMock,代码行数:7,代码来源:MockContextTests.cs


示例2: _BeforeTest

        public void _BeforeTest()
        {
            MockContext = new MockContext();

            Settings =
            SettingKeys.DefaultValues.ToDictionary( kvp => kvp.Key, kvp => new Config { Id = kvp.Key, Value = kvp.Value } );

            MockContext.SettingsRepoMock.Setup( x => x.Set( It.IsAny<string>(), It.IsAny<string>() ) ).Callback<string, string>( ( key, value ) =>
            {
                Settings[key] = new Config { Id = key, Value = value };
            } );
            MockContext.SettingsRepoMock.Setup( x => x.GetById( It.IsAny<string>() ) ).Returns<string>( cfg => Settings[cfg] );

            MockContext.AppThemesMock.SetupGet( x => x.Accents ).Returns( new[]
            {
                new ColorItem {Name = "Red"},
                new ColorItem {Name = "Blue"},
                new ColorItem {Name = "Green"}
            } );
            MockContext.AppThemesMock.SetupGet( x => x.Themes ).Returns( new[]
            {
                new ColorItem {Name = "BaseDark"},
                new ColorItem {Name = "None"},
                new ColorItem {Name = "BaseLight"}
            } );
        }
开发者ID:TheSylence,项目名称:GSD,代码行数:26,代码来源:SettingsViewModelTests.cs


示例3: 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


示例4: CurrentProjectIsFirstIfNotSetInSettings

        public void CurrentProjectIsFirstIfNotSetInSettings()
        {
            // Arrange
            var context = new MockContext();
            context.SettingsRepoMock.Setup( s => s.GetById( SettingKeys.LastProject ) ).Returns( new Config { Value = "-1" } );

            var projects = new[]
            {
                new Project {Name = "One", Id = 1},
                new Project {Name = "Two", Id = 2},
                new Project {Name = "Three", Id = 3}
            };

            context.ProjectRepoMock.Setup( p => p.GetAll() ).Returns( projects );

            // Act
            var vm = new ProjectListViewModel( context.ViewServiceRepo, context.SettingsRepo, context.ProjectRepo );

            // Assert
            Assert.IsNotNull( vm.CurrentProject );
            Assert.AreSame( projects[0], vm.CurrentProject.Model );

            context.SettingsRepoMock.VerifyAll();
            context.ProjectRepoMock.VerifyAll();
        }
开发者ID:TheSylence,项目名称:GSD,代码行数:25,代码来源:ProjectListViewModelTests.cs


示例5: InitializeContext

 protected void InitializeContext()
 {
     var contextMappings = new EntityMappingStore();
     var rmp = new ReflectionMappingProvider();
     rmp.AddMappingsForAssembly(contextMappings, typeof(LinqToSparqlTests).Assembly);
     Context = new MockContext(contextMappings);
 }
开发者ID:rharrisxtheta,项目名称:BrightstarDB,代码行数:7,代码来源:LinqToSparqlTestBase.cs


示例6: ResolverReturnsProperNamedObject

        public void ResolverReturnsProperNamedObject()
        {
            string expected = "We want this one";
            string notExpected = "Not this one";

            var expectedKey = NamedTypeBuildKey.Make<string>("expected");
            var notExpectedKey = NamedTypeBuildKey.Make<string>();

            var mainContext = new MockContext();
            mainContext.NewBuildupCallback = (k) =>
            {
                if (k == expectedKey)
                {
                    return expected;
                }
                if (k == notExpectedKey)
                {
                    return notExpected;
                }
                return null;
            };

            var resolver = new OptionalDependencyResolverPolicy(typeof(string), "expected");

            object result = resolver.Resolve(mainContext);

            Assert.Same(expected, result);
        }
开发者ID:CFMITL,项目名称:unity,代码行数:28,代码来源:OptionalDependencyResolverPolicyFixture.cs


示例7: 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


示例8: ListChangedEventIsAlwaysOnTheThreadThatCreatedTheList

        public void ListChangedEventIsAlwaysOnTheThreadThatCreatedTheList()
        {
            try
            {
                //convince the threadsafebindinglist we are using a synchronization context  
                //by providing a synchronization context
                var context = new MockContext();
                SynchronizationContext.SetSynchronizationContext(context);

                var list = new ThreadsafeBindingList<int>(context);

                //create a new thread adding something to the list
                //use an anonymous lambda expression delegate :)
                var addFiveThread = new Thread(() =>
                {
                    list.Add(5);
                });
                //action! run the thread adding 5
                addFiveThread.Start();
                //wait for the other thread to finish
                while (addFiveThread.IsAlive)
                    Thread.Sleep(10);

                //assert the list used the context.
                Assert.AreEqual(1, context.SendWasCalled, "The list did not use the send method the current context!");

            }
            finally
            {
                //always reset the synchronizationcontext
                SynchronizationContext.SetSynchronizationContext(null);
            }
            
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:34,代码来源:ThreadsafeBindingListTest.cs


示例9: Arrange_CallBackFourArguments_InvokesCallback

        public void Arrange_CallBackFourArguments_InvokesCallback()
        {
            var mockContext = new MockContext<IFoo>();
            var fooMock = new FooMock(mockContext);
            int firstResult = 0;
            int secondResult = 0;
            int thirdResult = 0;
            int fourthResult = 0;
            mockContext.Arrange(
                f => f.Execute(The<int>.IsAnyValue, The<int>.IsAnyValue, The<int>.IsAnyValue, The<int>.IsAnyValue))
                .Callback<int, int, int, int>(
                    (i1, i2, i3, i4) =>
                    {
                        firstResult = i1;
                        secondResult = i2;
                        thirdResult = i3;
                        fourthResult = i4;
                    });

            fooMock.Execute(1, 2, 3, 4);

            Assert.AreEqual(1, firstResult);
            Assert.AreEqual(2, secondResult);
            Assert.AreEqual(3, thirdResult);
            Assert.AreEqual(4, fourthResult);
        }
开发者ID:gazzyt,项目名称:LightMock,代码行数:26,代码来源:ArrangementTests.cs


示例10: 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


示例11: Setup

		public void Setup()
		{
			context = new MockContext();
			var contextProvider = MockRepository.GenerateStub<IDataContextProvider>();
			contextProvider.Expect(x => x.DataContext).Return(context);
			filter = new UnitOfWorkFilter(contextProvider);
		}
开发者ID:bertusmagnus,项目名称:Sutekishop,代码行数:7,代码来源:UnitOfWorkFilterTester.cs


示例12: InitTestContext

 public void InitTestContext()
 {
     ruleT1 = new TestRuleT1();
     ruleDependent = new OtherRuleT1();
     transformation = new MockTransformation(ruleT1, ruleDependent);
     transformation.Initialize();
     context = new MockContext(transformation);
 }
开发者ID:FrederikP,项目名称:NMF,代码行数:8,代码来源:GeneralTransformationRuleTest.cs


示例13: 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


示例14: GetContainerMock

 private MockContext<IServiceContainer> GetContainerMock(Func<ILifetime> lifetimeFactory, Func<Type, Type, bool> shouldRegister)
 {
     var mockContext = new MockContext<IServiceContainer>();
     var containerMock = new ContainerMock(mockContext);            
     var assemblyScanner = new AssemblyScanner(new ConcreteTypeExtractor(), new CompositionRootTypeExtractor(), new CompositionRootExecutor(containerMock));
     assemblyScanner.Scan(typeof(IFoo).Assembly, containerMock, lifetimeFactory, shouldRegister);
     return mockContext;
 }
开发者ID:vitamink,项目名称:LightInject,代码行数:8,代码来源:AssemblyScannerTests.cs


示例15: CreateService

        /// <summary>
        /// Create a Splunk <see cref="Service" /> and login using the settings
        /// provided in .splunkrc.
        /// </summary>
        /// <param name="ns">
        /// </param>
        /// <returns>
        /// The service created.
        /// </returns>
        public static async Task<Service> CreateService(Namespace ns = null)
        {
            var context = new MockContext(Splunk.Scheme, Splunk.Host, Splunk.Port);
            var service = new Service(context, ns);
            
            await service.LogOnAsync(Splunk.Username, Splunk.Password);

            return service;
        }
开发者ID:nagyist,项目名称:splunk-sdk-csharp-pcl,代码行数:18,代码来源:SdkHelper.cs


示例16: Setup

        public void Setup()
        {
            _sendEmailServiceMock = new MockContext<ISendEmailService> ();

            _stringResource = new StringResourceMock();
            _sendEmailService = new SendEmailServiceMock (_sendEmailServiceMock);

            _service = new EvaluationService (_stringResource, _sendEmailService);
        }
开发者ID:bernardo-bruning,项目名称:AnalysiSkill,代码行数:9,代码来源:EvaluationServiceTest.cs


示例17: Arrange_CallBackOneArgument_InvokesCallback

 public void Arrange_CallBackOneArgument_InvokesCallback()
 {
     var mockContext = new MockContext<IFoo>();
     var fooMock = new FooMock(mockContext);
     int callBackResult = 0;
     mockContext.Arrange(f => f.Execute(The<int>.IsAnyValue)).Callback<int>(s => callBackResult = s);
     fooMock.Execute(1);
     Assert.AreEqual(1, callBackResult);
 }
开发者ID:gazzyt,项目名称:LightMock,代码行数:9,代码来源:ArrangementTests.cs


示例18: Arrange_CallBackNoArguments_InvokesCallback

 public void Arrange_CallBackNoArguments_InvokesCallback()
 {
     var mockContext = new MockContext<IFoo>();
     var fooMock = new FooMock(mockContext);
     bool isCalled = false;
     mockContext.Arrange(f => f.Execute()).Callback(() => isCalled = true);
     fooMock.Execute();
     Assert.IsTrue(isCalled);
 }
开发者ID:gazzyt,项目名称:LightMock,代码行数:9,代码来源:ArrangementTests.cs


示例19: SetupManagementClients

 private void SetupManagementClients(MockContext context)
 {
     RedisManagementClient = GetRedisManagementClient(context);
     InsightsManagementClient = GetInsightsManagementClient();
     ResourceManagementClient = GetResourceManagementClient();
     helper.SetupManagementClients(ResourceManagementClient,
         InsightsManagementClient,
         RedisManagementClient
         );
 }
开发者ID:Azure,项目名称:azure-powershell,代码行数:10,代码来源:RedisCacheController.cs


示例20: Move_Line_RelativeVerticalLine

        public void Move_Line_RelativeVerticalLine()
        {
            StreamGeometry geometry = new StreamGeometry();
            MockContext context = new MockContext();
            PathMarkupParser target = new PathMarkupParser(geometry, context);

            target.Parse("M3,4 L5,6 v7");

            Assert.AreEqual("M3,4 L5,6 L5,13 ", context.Trace);
        }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:10,代码来源:PathMarkupParserTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MockEngine类代码示例发布时间:2022-05-24
下一篇:
C# MockContent类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap