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


C# Mock.GetType方法代码示例

本文整理汇总了C#中Mock.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.GetType方法的具体用法?C# Mock.GetType怎么用?C# Mock.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mock的用法示例。


在下文中一共展示了Mock.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RequiresSort_SorterType_ReturnsTrue

   public void RequiresSort_SorterType_ReturnsTrue()
   {
      NodeSorter sorter = new Mock<NodeSorter>().Object;
      
      Boolean result = NodeSorter.RequiresSort(sorter, sorter.GetType());

      Assert.IsTrue(result);
   }
开发者ID:Sugz,项目名称:Outliner-3.0,代码行数:8,代码来源:NodeSorterTests.cs

示例2: TestCreateWarrior_ShouldCreatCompleteObject

        public void TestCreateWarrior_ShouldCreatCompleteObject()
        {
            Mock moq = new Mock<IAttack>();
            Console.WriteLine(moq.GetType());

            var mock = new Mock<IList<int>>();
            var mockedObject = mock.Object;
        }
开发者ID:craghagBg,项目名称:AllProjects,代码行数:8,代码来源:TestTheSlum.cs

示例3: ItShouldBehaviorForNonDecoratedTypesOrMethod

        public void ItShouldBehaviorForNonDecoratedTypesOrMethod()
        {
            var repository = new Mock<MockeableRepository>().Object;
            var method = repository.GetType().GetMethod("GetAll");
            var behavior = repository.GetBehavior(method);

            Assert.IsNotNull(behavior);
            Assert.IsFalse(behavior.HandlesEverything);
        }
开发者ID:nuxleus,项目名称:WCFDataServicesToolkit,代码行数:9,代码来源:RepositoryBehaviorExtensionsTests.cs

示例4: GetSpatialDataReader_throws_on_non_SqlDataReader

        public void GetSpatialDataReader_throws_on_non_SqlDataReader()
        {
            var executionStrategyMock = new Mock<IDbExecutionStrategy>();
            executionStrategyMock.Setup(m => m.Execute(It.IsAny<Action>())).Callback<Action>(a => a());

            var connection = new SqlConnection(SimpleConnectionString(("master")));
            var mockReader = new Mock<DbDataReader>().Object;
            Assert.Throws<ProviderIncompatibleException>(
                () => DbProviderServices.GetProviderServices(connection).GetSpatialDataReader(
                    mockReader, "2008")).ValidateMessage(EntityFrameworkSqlServerAssembly,
                        "SqlProvider_NeedSqlDataReader", "System.Data.Entity.SqlServer.Properties.Resources.SqlServer", mockReader.GetType());
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:12,代码来源:SqlProviderServicesTests.cs

示例5: Generate_throws_when_operation_unknown

        public void Generate_throws_when_operation_unknown()
        {
            var migrationSqlGenerator = new SqlCeMigrationSqlGenerator();
            var unknownOperation = new Mock<MigrationOperation>(null).Object;

            var ex = Assert.Throws<InvalidOperationException>(
                () => migrationSqlGenerator.Generate(new[] { unknownOperation }, "4.0"));

            Assert.Equal(
                Strings.SqlServerMigrationSqlGenerator_UnknownOperation(typeof(SqlCeMigrationSqlGenerator).Name, unknownOperation.GetType().FullName),
                ex.Message);
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:12,代码来源:SqlCeMigrationSqlGeneratorTests.cs

示例6: ShouldUseCustomFactoryWhenSet

        public void ShouldUseCustomFactoryWhenSet()
        {
            ResetViewModelLocationProvider();

            Mock view = new Mock();
            Assert.IsNull(view.DataContext);

            string viewModel = "Test String";
            ViewModelLocationProvider.Register(view.GetType().ToString(), () => viewModel);
            
            ViewModelLocator.SetAutoWireViewModel(view, true);
            Assert.IsNotNull(view.DataContext);
            ReferenceEquals(view.DataContext, viewModel);
        }
开发者ID:Citringo,项目名称:Prism,代码行数:14,代码来源:ViewModelLocatorFixture.cs

示例7: ExecuteBootstrapperTasks_should_execute_bootstrapper_tasks

        public void ExecuteBootstrapperTasks_should_execute_bootstrapper_tasks()
        {
            var task = new Mock<BootstrapperTask>();
            task.Setup(t => t.Execute()).Verifiable();

            var config = new KeyValuePair<Type, Action<object>>(task.GetType(), null);

            bootstrapperTasksRegistry.Setup(r => r.TaskConfigurations).Returns(new[] { config });
            adapter.Setup(a => a.GetService(It.IsAny<Type>())).Returns(task.Object).Verifiable();

            bootstrapper.ExecuteBootstrapperTasks();

            task.VerifyAll();
            adapter.VerifyAll();
        }
开发者ID:rootzhou,项目名称:Core,代码行数:15,代码来源:BootstrapperTests.cs

示例8: EnsureLoadedForContext_throws_if_configuration_was_set_but_is_not_found_in_context_assembly

            public void EnsureLoadedForContext_throws_if_configuration_was_set_but_is_not_found_in_context_assembly()
            {
                var configuration = new Mock<DbConfiguration>().Object;
                var mockFinder = new Mock<DbConfigurationFinder>();
                var manager = CreateManager(null, mockFinder);

                manager.SetConfiguration(configuration);

                Assert.Equal(
                    Strings.SetConfigurationNotDiscovered(configuration.GetType().Name, typeof(FakeContext).Name),
                    Assert.Throws<InvalidOperationException>(
                        () => manager.EnsureLoadedForContext(typeof(FakeContext))).Message);
            }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:13,代码来源:DbConfigurationManagerTests.cs

示例9: EnsureLoadedForContext_throws_if_configuration_is_found_but_default_was_previously_used

            public void EnsureLoadedForContext_throws_if_configuration_is_found_but_default_was_previously_used()
            {
                var configuration = new Mock<DbConfiguration>().Object;
                var mockFinder = new Mock<DbConfigurationFinder>();
                mockFinder.Setup(m => m.TryFindConfigurationType(It.IsAny<IEnumerable<Type>>())).Returns(configuration.GetType());
                var manager = CreateManager(null, mockFinder);

                manager.GetConfiguration();

                Assert.Equal(
                    Strings.ConfigurationNotDiscovered(configuration.GetType().Name),
                    Assert.Throws<InvalidOperationException>(
                        () => manager.EnsureLoadedForContext(typeof(FakeContext))).Message);
            }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:14,代码来源:DbConfigurationManagerTests.cs

示例10: ShouldLogAsDebugWhenPluginSourceIsRemoved

 public void ShouldLogAsDebugWhenPluginSourceIsRemoved()
 {
     PluginRepository tested = new PluginRepository();
       MockLog log = new MockLog(tested);
       var pluginSource = new Mock<IPluginSource>().Object;
       tested.AddPluginSource(pluginSource);
       tested.RemovePluginSource(pluginSource);
       Assert.IsTrue(log.Any(x => x.Level == MockLog.Level.Debug && x.Message.Contains("removed") && x.Message.Contains(pluginSource.GetType().FullName)));
 }
开发者ID:ErikRydgren,项目名称:PluginFramework,代码行数:9,代码来源:UnitTest_PluginRepository.cs

示例11: Contains_Type_ReturnsFiltersOfType

      public void Contains_Type_ReturnsFiltersOfType()
      {
         FilterCollection<int> filters = new FilterCollection<int>();
         Filter<int> filterInt = new Mock<Filter<int>>().Object;
         Filter<double> filterDouble = new Mock<Filter<double>>().Object;
         filters.Add(filterInt);

         Assert.IsTrue(filters.Contains(filterInt.GetType()));
         Assert.IsFalse(filters.Contains(filterDouble.GetType()));
      }
开发者ID:Sugz,项目名称:Outliner-3.0,代码行数:10,代码来源:FilterCollectionTests.cs

示例12: Remove_ByType

      public void Remove_ByType()
      {
         FilterCollection<int> filters = new FilterCollection<int>();
         Filter<int> filter = new Mock<Filter<int>>().Object;
         filters.Add(filter);

         filters.Remove(filter.GetType());

         Assert.IsFalse(filters.Contains(filter));
      }
开发者ID:Sugz,项目名称:Outliner-3.0,代码行数:10,代码来源:FilterCollectionTests.cs

示例13: ShouldUseCustomFactoryWhenSet

        public void ShouldUseCustomFactoryWhenSet()
        {
            ResetViewModelLocationProvider();

            var view = new Mock();

            string viewModel = "Test String";
            ViewModelLocationProvider.Register(view.GetType().ToString(), () => viewModel);

            ViewModelLocationProvider.AutoWireViewModelChanged(view, (v, vm) =>
                {
                    Assert.IsNotNull(v);
                    Assert.IsNotNull(vm);
                    Assert.AreEqual(viewModel, vm);
                });
        }
开发者ID:ValdimarThor,项目名称:Prism,代码行数:16,代码来源:ViewModelLocationProviderFixture.cs

示例14: ContainerControllerFactory_GetTypesFor_ReturnsAllControllerTypesInContainer

        public void ContainerControllerFactory_GetTypesFor_ReturnsAllControllerTypesInContainer()
        {
            Func<IEnumerable<Type>, string> typeToString = _types => _types.OrderBy(x => x.Name).Select(x => x.Name).ConcatAll(",");

            var container = new Container();
            var mockController = new Mock<IController>().Object;
            container.Inject<IController>(new ProperController());
            container.Inject<IController>(mockController);

            var types = ContainerControllerFactory.GetControllersFor(container);

            Assert.Equal(typeToString(new[] { typeof(ProperController), mockController.GetType() }),
                         typeToString(types));
        }
开发者ID:shibbard,项目名称:Multi-tenancy-Sample,代码行数:14,代码来源:ContainerControllerFactoryTests.cs

示例15: ShouldUseCustomTypeWhenSet

        public void ShouldUseCustomTypeWhenSet()
        {
            ResetViewModelLocationProvider();

            var view = new Mock();

            ViewModelLocationProvider.Register(view.GetType().ToString(), typeof(ViewModelLocationProviderFixture));

            ViewModelLocationProvider.AutoWireViewModelChanged(view, (v, vm) =>
            {
                Assert.NotNull(v);
                Assert.NotNull(vm);
                Assert.IsType<ViewModelLocationProviderFixture>(vm);
            });
        }
开发者ID:Citringo,项目名称:Prism,代码行数:15,代码来源:ViewModelLocationProviderFixture.cs


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