コード例 #1
0
        public void MatchesUrlAndRepositoryPath_should_be_false_if_no_match_for_tfs_repository_path()
        {
            var mocker = new RhinoAutoMocker<GitTfsRemote>();
            mocker.Inject<TextWriter>(new StringWriter());
            var helper = MockRepository.GenerateStub<ITfsHelper>();
            helper.Url = "test";
            helper.LegacyUrls = new string[0];
            mocker.Inject(helper);
            mocker.ClassUnderTest.TfsRepositoryPath = "$/Test";

            bool matches = mocker.ClassUnderTest.MatchesUrlAndRepositoryPath("test", "$/shouldnotmatch");

            Assert.Equal(false, matches);
        }
コード例 #2
0
        public void MatchesUrlAndRepositoryPath_should_be_case_insensitive_for_tfs_url()
        {
            var mocker = new RhinoAutoMocker<GitTfsRemote>();
            mocker.Inject<TextWriter>(new StringWriter());
            var helper = MockRepository.GenerateStub<ITfsHelper>();
            helper.Url = "http://testvcs:8080/tfs/test";
            helper.LegacyUrls = new string[0];
            mocker.Inject(helper);
            mocker.ClassUnderTest.TfsRepositoryPath = "test";

            bool matches = mocker.ClassUnderTest.MatchesUrlAndRepositoryPath("http://testvcs:8080/tfs/Test", "test");

            Assert.Equal(true, matches);
        }
コード例 #3
0
        protected override void Establish_context()
        {
            base.Establish_context();

            _product1 = new Product {
                ProductId = 1, Name = "one", Price = 1.11m
            };
            _product2 = new Product {
                ProductId = 2, Name = "two", Price = 2.22m
            };

            _mocker = new RhinoAutoMocker <OrderController>();

            // stub the Session
            _session = new FakeHttpSession();
            _mocker.Inject <IHttpSession>(_session);

            // available products
            _mocker.Get <IGetProductService>().Stub(s => s.GetAvailableProducts())
            .Return(new[]
            {
                _product1,
                _product2,
                new Product {
                    ProductId = 3, Name = "three", Price = 3.33m
                }
            });
        }
コード例 #4
0
ファイル: ShelveTest.cs プロジェクト: chrisortman/git-tfs
 public void Setup()
 {
     mocks = new RhinoAutoMocker<Shelve>();
     mocks.Inject<TextWriter>(new StringWriter());
     mocks.Get<Globals>().Repository = mocks.Get<IGitRepository>();
     mocks.MockObjectFactory();
 }
コード例 #5
0
ファイル: GitTfsRemoteTests.cs プロジェクト: runt18/git-tfs
 private GitTfsRemote BuildRemote(string repository, string url = "", string[] legacyUrls = null)
 {
     if (legacyUrls == null)
         legacyUrls = new string[0];
     var info = new RemoteInfo
     {
         Url = url,
         Repository = repository,
         Aliases = legacyUrls,
     };
     var mocks = new RhinoAutoMocker<GitTfsRemote>();
     mocks.Inject<TextWriter>(new StringWriter());
     mocks.Inject<RemoteInfo>(info);
     mocks.Inject<ITfsHelper>(MockRepository.GenerateStub<ITfsHelper>()); // GitTfsRemote backs the TfsUrl with this.
     return mocks.ClassUnderTest;
 }
コード例 #6
0
        public void SetUp()
        {
            _clock = new SettableClock();

            Services = new RhinoAutoMocker <T>(_mode);
            Services.Inject <ISystemTime>(_clock);
            beforeEach();
        }
コード例 #7
0
        public static RecordingLogger RecordLogging <T>(this RhinoAutoMocker <T> mocker) where T : class
        {
            var logger = new RecordingLogger();

            mocker.Inject <ILogger>(logger);

            return(logger);
        }
コード例 #8
0
        // TODO -- put this into FubuMVC.TestingSupport or whatever it's called
        public static StubUrlRegistry StubUrls <T>(this RhinoAutoMocker <T> mocker) where T : class
        {
            var urls = new StubUrlRegistry();

            mocker.Inject <IUrlRegistry>(urls);

            return(urls);
        }
コード例 #9
0
        public virtual void SetUp()
        {
            AutomapperConfiguration.Configure();
            _autoMocker = new RhinoAutoMocker <HomeController>();

            _autoMocker.Inject <IMapperFactory>(new MapperFactory(new Container(c =>
            {
                c.AddRegistry <TestRegistry>();
            })));
        }
コード例 #10
0
ファイル: GitTfsRemoteTests.cs プロジェクト: zidanfei/git-tfs
        private GitTfsRemote BuildRemote(string repository, string url = "", string[] legacyUrls = null, string id = "test")
        {
            if (legacyUrls == null)
            {
                legacyUrls = new string[0];
            }
            var info = new RemoteInfo
            {
                Id         = id,
                Url        = url,
                Repository = repository,
                Aliases    = legacyUrls,
            };
            var mocks = new RhinoAutoMocker <GitTfsRemote>();

            mocks.Inject(info);
            mocks.Inject(MockRepository.GenerateStub <ITfsHelper>()); // GitTfsRemote backs the TfsUrl with this.
            return(mocks.ClassUnderTest);
        }
コード例 #11
0
        public virtual void SetUp()
        {
            AutomapperConfiguration.Configure();
            _autoMocker = new RhinoAutoMocker<HomeController>();

            _autoMocker.Inject<IMapperFactory>(new MapperFactory(new Container(c =>
            {
                c.AddRegistry<TestRegistry>();
            })));
        }
コード例 #12
0
        public virtual void SetUp()
        {
            rollbarclient = MockRepository.GenerateStub<IRollbarClient>();
            autoMocker = new RhinoAutoMocker<BoardGameGeekBatchUpdateJobService>();
            autoMocker.Inject(typeof(IRollbarClient), rollbarclient);

            autoMocker.Get<IDataContext>()
                .Expect(mock => mock.GetQueryable<GameDefinition>())
                .Return(OrphanGames.AsQueryable());
        }
コード例 #13
0
        public virtual void SetUp()
        {
            rollbarclient = MockRepository.GenerateStub <IRollbarClient>();
            autoMocker    = new RhinoAutoMocker <BoardGameGeekBatchUpdateJobService>();
            autoMocker.Inject(typeof(IRollbarClient), rollbarclient);

            autoMocker.Get <IDataContext>()
            .Expect(mock => mock.GetQueryable <GameDefinition>())
            .Return(OrphanGames.AsQueryable());
        }
コード例 #14
0
                public void Before_first_test()
                {
                    _command = new CommandWithOnePrerequisite();
                    var mocker = new RhinoAutoMocker <CommandHandler>();

                    mocker.Inject(typeof(ICommand), _command);
                    mocker.Get <IPrerequisiteChecker>()
                    .Expect(x => x.Check(Arg <ICommand> .Is.Same(_command), Arg <ExecutionArguments> .Is.NotNull))
                    .Return(Notification.ErrorFor("pretend"));
                    _result = mocker.ClassUnderTest.Handle(_command, new ExecutionArguments());
                }
コード例 #15
0
ファイル: GitTfsRemoteTests.cs プロジェクト: zidanfei/git-tfs
        private GitTfsRemote BuildSubTreeOwnerRemote(IEnumerable <IGitTfsRemote> remotes)
        {
            var info = new RemoteInfo
            {
                Id         = "test",
                Url        = null,
                Repository = null,
            };
            var mocks = new RhinoAutoMocker <GitTfsRemote>();

            mocks.Inject(info);
            mocks.Inject(MockRepository.GenerateStub <ITfsHelper>()); // GitTfsRemote backs the TfsUrl with this.

            var mockGitRepository = mocks.Get <IGitRepository>();

            mockGitRepository.Stub(t => t.GetSubtrees(Arg <IGitTfsRemote> .Is.Anything)).Return(remotes);

            mocks.Inject(new Globals()
            {
                Repository = mockGitRepository
            });
            return(mocks.ClassUnderTest);
        }
コード例 #16
0
        public void SetUp()
        {
            autoMocker = new RhinoAutoMocker<UserSessionsController>();

            var dataProtector = MockRepository.GenerateMock<IDataProtector>();
            userStoreMock = MockRepository.GenerateMock<IUserStore<ApplicationUser>>();
            var dataProtectionProvider = MockRepository.GenerateMock<IDataProtectionProvider>();
            dataProtectionProvider.Expect(mock => mock.Create("ASP.N‌​ET Identity")).Return(dataProtector);
            var applicationUserManager = MockRepository.GeneratePartialMock<ApplicationUserManager>(userStoreMock, dataProtectionProvider);
            autoMocker.Inject(applicationUserManager);

            var controllerContextMock = MockRepository.GeneratePartialMock<HttpControllerContext>();
            var actionDescriptorMock = MockRepository.GenerateMock<HttpActionDescriptor>();
            autoMocker.ClassUnderTest.ActionContext = new HttpActionContext(controllerContextMock, actionDescriptorMock);
            autoMocker.ClassUnderTest.Request = new HttpRequestMessage();
            autoMocker.ClassUnderTest.Request.SetConfiguration(new HttpConfiguration());

            AutomapperConfiguration.Configure();
        }
コード例 #17
0
        public virtual void TestSetUp()
        {
            autoMocker = new RhinoAutoMocker <PlayedGameController>();

            autoMocker.Inject <IMapperFactory>(new MapperFactory(new Container(c =>
            {
                c.AddRegistry <TestRegistry>();
            })));

            currentUser = new ApplicationUser()
            {
                CurrentGamingGroupId = 1
            };
            gameDefinitionSummaries = new List <GameDefinitionSummary>();
            autoMocker.Get <IGameDefinitionRetriever>().Expect(mock => mock.GetAllGameDefinitions(currentUser.CurrentGamingGroupId))
            .Repeat.Once()
            .Return(gameDefinitionSummaries);

            autoMocker.ClassUnderTest.Url = MockRepository.GenerateMock <UrlHelper>();
        }
コード例 #18
0
		public virtual void TestSetUp()
		{
            autoMocker = new RhinoAutoMocker<PlayedGameController>();

            autoMocker.Inject<IMapperFactory>(new MapperFactory(new Container(c =>
            {
                c.AddRegistry<TestRegistry>();
            })));

            currentUser = new ApplicationUser()
			{
				CurrentGamingGroupId = 1
			};
			gameDefinitionSummaries = new List<GameDefinitionSummary>();
            autoMocker.Get<IGameDefinitionRetriever>().Expect(mock => mock.GetAllGameDefinitions(currentUser.CurrentGamingGroupId))
				.Repeat.Once()
				.Return(gameDefinitionSummaries);

		    autoMocker.ClassUnderTest.Url = MockRepository.GenerateMock<UrlHelper>();
		}
コード例 #19
0
        protected override void Establish_context()
        {
            base.Establish_context();

            _product1 = new Product { ProductId = 1, Name = "one", Price = 1.11m };
            _product2 = new Product { ProductId = 2, Name = "two", Price = 2.22m };

            _mocker = new RhinoAutoMocker<OrderController>();

            // stub the Session
            _session = new FakeHttpSession();
            _mocker.Inject<IHttpSession>(_session);

            // available products
            _mocker.Get<IGetProductService>().Stub(s => s.GetAvailableProducts())
                .Return(new[]
                            {
                                _product1,
                                _product2,
                                new Product {ProductId = 3, Name = "three", Price = 3.33m}
                            });
        }
コード例 #20
0
        public void SetUp()
        {
            autoMocker = new RhinoAutoMocker <UserSessionsController>();

            var dataProtector = MockRepository.GenerateMock <IDataProtector>();

            userStoreMock = MockRepository.GenerateMock <IUserStore <ApplicationUser> >();
            var dataProtectionProvider = MockRepository.GenerateMock <IDataProtectionProvider>();

            dataProtectionProvider.Expect(mock => mock.Create("ASP.N‌​ET Identity")).Return(dataProtector);
            var applicationUserManager = MockRepository.GeneratePartialMock <ApplicationUserManager>(userStoreMock, dataProtectionProvider);

            autoMocker.Inject(applicationUserManager);

            var controllerContextMock = MockRepository.GeneratePartialMock <HttpControllerContext>();
            var actionDescriptorMock  = MockRepository.GenerateMock <HttpActionDescriptor>();

            autoMocker.ClassUnderTest.ActionContext = new HttpActionContext(controllerContextMock, actionDescriptorMock);
            autoMocker.ClassUnderTest.Request       = new HttpRequestMessage();
            autoMocker.ClassUnderTest.Request.SetConfiguration(new HttpConfiguration());

            AutomapperConfiguration.Configure();
        }
コード例 #21
0
 public HelpTest()
 {
     outputWriter = new StringWriter();
     mocks        = new RhinoAutoMocker <Help>(MockMode.AAA);
     mocks.Inject <TextWriter>(outputWriter);
 }
コード例 #22
0
 public void SetUp()
 {
     autoMocker = new RhinoAutoMocker<NemeStatsDataContext>();
     autoMocker.Inject(MockRepository.GenerateMock<NemeStatsDbContext>());
 }
コード例 #23
0
ファイル: InitTest.cs プロジェクト: zidanfei/git-tfs
 public void Setup()
 {
     outputWriter = new StringWriter();
     mocks        = new RhinoAutoMocker <Init>(MockMode.AAA);
     mocks.Inject <TextWriter>(outputWriter);
 }
コード例 #24
0
ファイル: GitTfsRemoteTests.cs プロジェクト: pmiossec/git-tfs
        private GitTfsRemote BuildSubTreeOwnerRemote(IEnumerable<IGitTfsRemote> remotes)
        {
            var info = new RemoteInfo
            {
                Id = "test",
                Url = null,
                Repository = null,
            };
            var mocks = new RhinoAutoMocker<GitTfsRemote>();
            mocks.Inject(info);
            mocks.Inject(MockRepository.GenerateStub<ITfsHelper>()); // GitTfsRemote backs the TfsUrl with this.

            var mockGitRepository = mocks.Get<IGitRepository>();
            mockGitRepository.Stub(t => t.GetSubtrees(Arg<IGitTfsRemote>.Is.Anything)).Return(remotes);

            mocks.Inject(new Globals() { Repository = mockGitRepository });
            return mocks.ClassUnderTest;
        }
コード例 #25
0
ファイル: ShelveTest.cs プロジェクト: johnedmonds/git-tfs
 public void Setup()
 {
     mocks = new RhinoAutoMocker <Shelve>();
     mocks.Inject <TextWriter>(new StringWriter());
     mocks.Get <Globals>().Repository = mocks.Get <IGitRepository>();
 }
コード例 #26
0
ファイル: InitBranchTest.cs プロジェクト: nobitagamer/git-tfs
 public InitBranchTest()
 {
     mocks = new RhinoAutoMocker<InitBranch>();
     mocks.Inject<TextWriter>(new StringWriter());
     mocks.Get<Globals>().Repository = mocks.Get<IGitRepository>();
 }
コード例 #27
0
 public GitTfsCommandRunnerTests()
 {
     _mocks = new RhinoAutoMocker <GitTfsCommandRunner>(MockMode.AAA);
     _mocks.Inject <TextWriter>(new StringWriter());
 }
コード例 #28
0
 public void Use <SERVICE>(SERVICE instance)
 {
     _services.Inject(instance);
 }
コード例 #29
0
ファイル: ShelveTest.cs プロジェクト: XinChenBug/git-tfs
 public ShelveTest()
 {
     mocks = new RhinoAutoMocker<Shelve>();
     mocks.Inject<TextWriter>(new StringWriter());
     mocks.Get<Globals>().Repository = mocks.Get<IGitRepository>();
 }
コード例 #30
0
 public void SetUp()
 {
     autoMocker = new RhinoAutoMocker <NemeStatsDataContext>();
     autoMocker.Inject(MockRepository.GenerateMock <NemeStatsDbContext>());
 }
コード例 #31
0
ファイル: PullTest.cs プロジェクト: adamchester/git-tfs
 public void Setup()
 {
     mocks = new RhinoAutoMocker<Pull>();
     mocks.Inject<TextWriter>(new StringWriter());
 }
コード例 #32
0
ファイル: HelpTest.cs プロジェクト: patthoyts/git-tfs
 public HelpTest()
 {
     outputWriter = new StringWriter();
     mocks = new RhinoAutoMocker<Help>(MockMode.AAA);
     mocks.Inject<TextWriter>(outputWriter);
 }
コード例 #33
0
 public void Setup()
 {
     _mocks = new RhinoAutoMocker<GitTfsCommandRunner>(MockMode.AAA);
     _mocks.Inject<TextWriter>(new StringWriter());
 }
コード例 #34
0
 public InitBranchTest()
 {
     mocks = new RhinoAutoMocker <InitBranch>();
     mocks.Inject <TextWriter>(new StringWriter());
     mocks.Get <Globals>().Repository = mocks.Get <IGitRepository>();
 }
コード例 #35
0
ファイル: InitTest.cs プロジェクト: XinChenBug/git-tfs
 public void Setup()
 {
     outputWriter = new StringWriter();
     mocks = new RhinoAutoMocker<Init>(MockMode.AAA);
     mocks.Inject<TextWriter>(outputWriter);
 }