當前位置: 首頁>>代碼示例>>C#>>正文


C# AutoMoqer.Create方法代碼示例

本文整理匯總了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>();
        }
開發者ID:darrencauthon,項目名稱:AutoMoq,代碼行數:7,代碼來源:CallingCreateTwice.cs

示例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);
        }
開發者ID:darrencauthon,項目名稱:AutoMoq,代碼行數:12,代碼來源:CallingCreateTwice.cs

示例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);
        }
開發者ID:akatakritos,項目名稱:Comics,代碼行數:28,代碼來源:ImportProcessTests.cs

示例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>();
        }
開發者ID:boriphuth,項目名稱:clean-architecture-demo,代碼行數:33,代碼來源:GetSalesListQueryTests.cs

示例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);
        }
開發者ID:darrencauthon,項目名稱:AutoMoq,代碼行數:7,代碼來源:ConstructorTests.cs

示例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);
        }
開發者ID:akatakritos,項目名稱:Comics,代碼行數:32,代碼來源:ImportProcessTests.cs

示例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");
        }
開發者ID:akatakritos,項目名稱:Comics,代碼行數:27,代碼來源:FeedControllerTests.cs

示例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);
        }
開發者ID:KallDrexx,項目名稱:Backplan,代碼行數:28,代碼來源:DirectoryWatcherTests.cs

示例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>();
        }
開發者ID:akatakritos,項目名稱:Comics,代碼行數:11,代碼來源:AdminControllerTests.cs

示例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>();
        }
開發者ID:boriphuth,項目名稱:clean-architecture-demo,代碼行數:12,代碼來源:EmployeesControllerTests.cs

示例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>();
        }
開發者ID:boriphuth,項目名稱:clean-architecture-demo,代碼行數:12,代碼來源:ProductsControllerTests.cs

示例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>();
        }
開發者ID:boriphuth,項目名稱:clean-architecture-demo,代碼行數:12,代碼來源:CustomersControllerTests.cs

示例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();
        }
開發者ID:akatakritos,項目名稱:Comics,代碼行數:12,代碼來源:FeedControllerTests.cs

示例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);
        }
開發者ID:darrencauthon,項目名稱:AutoMoq,代碼行數:12,代碼來源:ConstructorTests.cs

示例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);
        }
開發者ID:akatakritos,項目名稱:Comics,代碼行數:12,代碼來源:AdminControllerTests.cs


注:本文中的AutoMoqer.Create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。