本文整理汇总了C#中AutoMoqer.Create方法的典型用法代码示例。如果您正苦于以下问题:C# AutoMoqer.Create方法的具体用法?C# AutoMoqer.Create怎么用?C# AutoMoqer.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoMoqer
的用法示例。
在下文中一共展示了AutoMoqer.Create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: creating_the_child_twice
public void creating_the_child_twice()
{
var autoMoq = new AutoMoqer();
autoMoq.Create<Child>();
autoMoq.Create<Child>();
}
示例2: can_create_parent_object_when_setInstance_is_called_on_child
public void can_create_parent_object_when_setInstance_is_called_on_child()
{
var autoMoq = new AutoMoqer();
// the second line works... seems to be an issue calling Create twice?
var child = autoMoq.Create<Child>();
//var child = new Mock<IChild>().Object;
autoMoq.SetInstance<IChild>(child);
var parent = autoMoq.Create<Parent>();
Assert.IsNotNull(parent);
}
示例3: ReportsComicsImported
public void ReportsComicsImported()
{
var mocker = new AutoMoqer();
var lastExplosmComic = new Comic();
var newExplosmComic1 = new Comic();
var newExplosmComic2 = new Comic();
var explosm = new Mock<IComicDownloader>();
explosm.Setup(m => m.GetNewComicsSince(lastExplosmComic))
.Returns(new[] { newExplosmComic1, newExplosmComic2 });
mocker.GetMock<IComicsRepository>()
.Setup(m => m.GetLastImportedComic(ComicType.Explosm))
.Returns(lastExplosmComic)
.Verifiable();
var registry = new ComicConfigRegistry();
registry.Add(new ComicConfig(ComicType.Explosm, explosm.Object));
// ReSharper disable once RedundantTypeArgumentsOfMethod
mocker.SetInstance<ComicConfigRegistry>(registry);
var process = mocker.Create<ImportProcess>();
process.Run();
Check.That(process.ImportedComics.Count).IsEqualTo(2);
}
示例4: SetUp
public void SetUp()
{
var customer = new Customer
{
Name = CustomerName
};
var employee = new Employee
{
Name = EmployeeName
};
var product = new Product
{
Name = ProductName
};
_sale = new Sale()
{
Id = SaleId,
Date = Date,
Customer = customer,
Employee = employee,
Product = product,
UnitPrice = UnitPrice,
Quantity = Quantity,
TotalPrice = TotalPrice
};
_mocker = new AutoMoqer();
_query = _mocker.Create<GetSalesListQuery>();
}
示例5: I_can_instantiate_a_working_automoqer_with_no_dependencies
public void I_can_instantiate_a_working_automoqer_with_no_dependencies()
{
var mocker = new AutoMoqer();
var bar = mocker.Create<Bar>();
bar.Foo.ShouldBeSameAs(mocker.GetMock<IFoo>().Object);
}
示例6: UsesRegistryToGetNewComics
public void UsesRegistryToGetNewComics()
{
var mocker = new AutoMoqer();
var lastExplosmComic = new Comic();
var newExplosmComic1 = new Comic();
var newExplosmComic2 = new Comic();
var explosm = new Mock<IComicDownloader>();
explosm.Setup(m => m.GetNewComicsSince(lastExplosmComic))
.Returns(new[] { newExplosmComic1, newExplosmComic2 });
mocker.GetMock<IComicsRepository>()
.Setup(m => m.GetLastImportedComic(ComicType.Explosm))
.Returns(lastExplosmComic)
.Verifiable();
var registry = new ComicConfigRegistry();
registry.Add(new ComicConfig(ComicType.Explosm, explosm.Object));
// ReSharper disable once RedundantTypeArgumentsOfMethod
mocker.SetInstance<ComicConfigRegistry>(registry);
mocker.Create<ImportProcess>()
.Run();
mocker.GetMock<IComicsRepository>().VerifyAll();
mocker.GetMock<IComicsRepository>()
.Verify(m => m.InsertComic(newExplosmComic1), Times.Once);
mocker.GetMock<IComicsRepository>()
.Verify(m => m.InsertComic(newExplosmComic2), Times.Once);
}
示例7: ItSendsBackSomeRss
public void ItSendsBackSomeRss(ComicType type)
{
var mocker = new AutoMoqer();
mocker.GetMock<IComicsRepository>()
.Setup(m => m.GetLatestComics(type, 10))
.Returns(new[]
{
new Comic()
{
ComicNumber = 1,
ComicType = type,
ImageSrc = "http://example.com/image.png",
Permalink = "http://example.com",
ComicId = 1,
PublishedDate = DateTime.Today
}
});
var result = mocker.Create<FeedController>().Feed(type);
var s = new MemoryStream();
result.FileStream.CopyTo(s);
var xml = Encoding.UTF8.GetString(s.ToArray());
Check.That(result.ContentType).IsEqualTo("text/xml");
Check.That(xml).Contains("http://example.com/image.png");
}
示例8: Setup
public void Setup()
{
_mocker = new AutoMoqer();
var mockFileSystem = new MockFileSystem();
_mocker.SetInstance<IFileSystem>(mockFileSystem);
// GetMock of the abstract class before create to prevent automoq bugs
_mocker.GetMock<FileSystemWatcherBase>();
_instance = _mocker.Create<DirectoryWatcher>();
// Mocked files
var content = new byte[] {1, 1, 1};
_expectedFileLength = content.Length;
_expectedWriteDate = DateTime.Now.ToUniversalTime();
var nameWithPath = mockFileSystem.Path.Combine(Path, FileName);
mockFileSystem.AddFile(nameWithPath, new MockFileData(content)
{
LastWriteTime = _expectedWriteDate
});
_trackedFile = new TrackedFile();
_mocker.GetMock<ITrackedFileStore>()
.Setup(x => x.GetTrackedFileByFullPath(nameWithPath))
.Returns(_trackedFile);
}
示例9: WhenAuthorizedReturnsContentResult
public void WhenAuthorizedReturnsContentResult()
{
var mocker = new AutoMoqer();
mocker.GetMock<IImportProcess>()
.Setup(m => m.ImportedComics)
.Returns(new Comic[] {});
var result = mocker.Create<AdminController>().Refresh(authToken: ConfigurationManager.AppSettings["AdminAuthToken"]);
Check.That(result).IsInstanceOf<ContentResult>();
}
示例10: SetUp
public void SetUp()
{
_model = new EmployeeModel();
_mocker = new AutoMoqer();
_mocker.GetMock<IGetEmployeesListQuery>()
.Setup(p => p.Execute())
.Returns(new List<EmployeeModel> { _model });
_controller = _mocker.Create<EmployeesController>();
}
示例11: SetUp
public void SetUp()
{
_model = new ProductModel();
_mocker = new AutoMoqer();
_mocker.GetMock<IGetProductsListQuery>()
.Setup(p => p.Execute())
.Returns(new List<ProductModel> { _model });
_controller = _mocker.Create<ProductsController>();
}
示例12: SetUp
public void SetUp()
{
_model = new CustomerModel();
_mocker = new AutoMoqer();
_mocker.GetMock<IGetCustomersListQuery>()
.Setup(p => p.Execute())
.Returns(new List<CustomerModel> { _model });
_controller = _mocker.Create<CustomersController>();
}
示例13: ItSearchesForTheReferencedComic
public void ItSearchesForTheReferencedComic(ComicType type)
{
var mocker = new AutoMoqer();
mocker.GetMock<IComicsRepository>()
.Setup(m => m.GetLatestComics(type, It.IsAny<int>()))
.Returns(Enumerable.Empty<Comic>().ToList())
.Verifiable();
mocker.Create<FeedController>().Feed(type);
mocker.GetMock<IComicsRepository>().Verify();
}
示例14: I_can_replace_the_unity_container_with_my_own
public void I_can_replace_the_unity_container_with_my_own()
{
var container = new UnityContainer();
var foo = new Mock<IFoo>().Object;
container.RegisterInstance(foo);
var mocker = new AutoMoqer(container);
var bar = mocker.Create<Bar>();
bar.Foo.ShouldBeSameAs(foo);
}
示例15: ItRunsTheImports
public void ItRunsTheImports()
{
var mocker = new AutoMoqer();
mocker.GetMock<IImportProcess>()
.Setup(m => m.ImportedComics)
.Returns(new Comic[] {});
mocker.Create<AdminController>().Refresh(authToken: ConfigurationManager.AppSettings["AdminAuthToken"]);
mocker.GetMock<IImportProcess>()
.Verify(m => m.Run(), Times.Once);
}