本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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)));
}
示例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()));
}
示例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));
}
示例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);
});
}
示例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));
}
示例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);
});
}