예제 #1
0
		public void ShouldCreateMocksWithFactoryBehavior()
		{
			var repository = new MockRepository(MockBehavior.Loose);

			var mock = repository.Create<IFormatProvider>();

			Assert.Equal(MockBehavior.Loose, mock.Behavior);
		}
예제 #2
0
		public void ShouldCreateMockWithConstructorArgs()
		{
			var repository = new MockRepository(MockBehavior.Loose);

			var mock = repository.Create<BaseClass>("foo");

			Assert.Equal("foo", mock.Object.Value);
		}
        public void ShouldAssignNullCallSequenceToCreatedMocksByDefault()
        {
            var repository = new MockRepository(MockBehavior.Default);

            var mock = repository.Create<IFoo>();

            Assert.Throws<NoSequenceAssignedException>(
                () => mock.CallSequence.Verify(
                    mock.CallTo(m => m.Do()),
                    mock.CallTo(m => m.Undo())
                )
            );
        }
예제 #4
0
		public void ShouldAggregateFailures()
		{
			try
			{
				var repository = new MockRepository(MockBehavior.Loose);
				var foo = repository.Create<IFoo>();
				var bar = repository.Create<IBar>();

				foo.Setup(f => f.Do());
				bar.Setup(b => b.Redo());

				repository.VerifyAll();
			}
			catch (MockException mex)
			{
				Expression<Action<IFoo>> fooExpect = f => f.Do();
				Assert.True(mex.Message.Contains(fooExpect.ToString()));

				Expression<Action<IBar>> barExpect = b => b.Redo();
				Assert.True(mex.Message.Contains(barExpect.ToString()));
			}
		}
예제 #5
0
		public void ShouldVerifyAll()
		{
			try
			{
				var repository = new MockRepository(MockBehavior.Default);
				var mock = repository.Create<IFoo>();

				mock.Setup(foo => foo.Do());

				repository.VerifyAll();
			}
			catch (MockException mex)
			{
				Assert.Equal(MockException.ExceptionReason.VerificationFailed, mex.Reason);
			}
		}
예제 #6
0
        public void ShouldCreateMocksWithFactoryCallBase()
        {
            var repository = new MockRepository(MockBehavior.Loose);

            var mock = repository.Create<BaseClass>();

            mock.Object.BaseMethod();

            Assert.False(mock.Object.BaseCalled);

            repository.CallBase = true;

            mock = repository.Create<BaseClass>();

            mock.Object.BaseMethod();

            Assert.True(mock.Object.BaseCalled);
        }
예제 #7
0
		public void ShouldVerifyVerifiables()
		{
			try
			{
				var repository = new MockRepository(MockBehavior.Default);
				var mock = repository.Create<IFoo>();

				mock.Setup(foo => foo.Do());
				mock.Setup(foo => foo.Undo()).Verifiable();

				repository.Verify();
			}
			catch (MockException mex)
			{
				Assert.Equal(MockException.ExceptionReason.VerificationFailed, mex.Reason);
				Expression<Action<IFoo>> doExpr = foo => foo.Do();
				Assert.False(mex.Message.Contains(doExpr.ToString()));
			}
		}
예제 #8
0
파일: VsSimulation.cs 프로젝트: d8q8/VsVim
        internal VsSimulation(IVimBufferCoordinator bufferCoordinator, bool simulateResharper, bool simulateStandardKeyMappings, IEditorOperationsFactoryService editorOperationsFactoryService, IKeyUtil keyUtil)
        {
            _keyUtil     = keyUtil;
            _wpfTextView = (IWpfTextView)bufferCoordinator.VimBuffer.TextView;
            _factory     = new MockRepository(MockBehavior.Strict);
            _vsKeyboardInputSimulation      = new VsKeyboardInputSimulation(this, _wpfTextView);
            _testableSynchronizationContext = new TestableSynchronizationContext();
            _simulateStandardKeyMappings    = simulateStandardKeyMappings;

            // Create the IVsAdapter and pick reasonable defaults here.  Consumers can modify
            // this via an exposed property
            _vsAdapter = _factory.Create <IVsAdapter>();
            _vsAdapter.SetupGet(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(_vsKeyboardInputSimulation.KeyBoardDevice);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextBuffer>())).Returns(false);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextView>())).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(_wpfTextView)).Returns(false);

            _reportDesignerUtil = _factory.Create <IReportDesignerUtil>();
            _reportDesignerUtil.Setup(x => x.IsExpressionView(_wpfTextView)).Returns(false);

            _displayWindowBroker = _factory.Create <IDisplayWindowBroker>();
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsQuickInfoActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);

            _vimApplicationSettings = _factory.Create <IVimApplicationSettings>();
            _vimApplicationSettings.SetupGet(x => x.UseEditorDefaults).Returns(true);
            _vimApplicationSettings.SetupGet(x => x.UseEditorIndent).Returns(true);
            _vimApplicationSettings.SetupGet(x => x.UseEditorTabAndBackspace).Returns(true);

            _vsSimulationCommandTarget = new SimulationCommandTarget(
                bufferCoordinator.VimBuffer.TextView,
                editorOperationsFactoryService.GetEditorOperations(bufferCoordinator.VimBuffer.TextView));

            var textManager    = _factory.Create <ITextManager>();
            var commandTargets = new List <ICommandTarget>();

            if (simulateResharper)
            {
                commandTargets.Add(ReSharperKeyUtil.GetOrCreate(bufferCoordinator));
            }
            commandTargets.Add(new StandardCommandTarget(bufferCoordinator, textManager.Object, _displayWindowBroker.Object, _vsSimulationCommandTarget));

            // Create the VsCommandTarget.  It's next is the final and default Visual Studio
            // command target
            _vsCommandTarget = new VsCommandTarget(
                bufferCoordinator,
                textManager.Object,
                _vsAdapter.Object,
                _displayWindowBroker.Object,
                _keyUtil,
                _vimApplicationSettings.Object,
                _vsSimulationCommandTarget,
                commandTargets.ToReadOnlyCollectionShallow());

            // Time to setup the start command target.  If we are simulating R# then put them ahead of VsVim
            // on the IOleCommandTarget chain.  VsVim doesn't try to fight R# and prefers instead to be
            // behind them
            if (simulateResharper)
            {
                _reSharperCommandTarget = new ReSharperCommandTargetSimulation(_wpfTextView, _vsCommandTarget);
                _commandTarget          = _reSharperCommandTarget;
            }
            else
            {
                _commandTarget = _vsCommandTarget;
            }

            // Visual Studio hides the default IOleCommandTarget inside of the IWpfTextView property
            // bag.  The default KeyProcessor implementation looks here for IOleCommandTarget to
            // process text input.
            //
            // This should always point to the head of the IOleCommandTarget chain.  In the implementation
            // it actually points to the IVsTextView implementation which then immediately routes to the
            // IOleCommandTarget head
            _wpfTextView.Properties[typeof(IOleCommandTarget)] = _commandTarget;

            // Create the input controller.  Make sure that the VsVim one is ahead in the list
            // from the default Visual Studio one.  We can guarantee this is true due to MEF
            // ordering of the components
            if (simulateResharper)
            {
                _vsKeyboardInputSimulation.KeyProcessors.Add(ReSharperKeyUtil.GetOrCreate(bufferCoordinator));
            }
            _vsKeyboardInputSimulation.KeyProcessors.Add(new VsVimKeyProcessor(_vsAdapter.Object, bufferCoordinator, _keyUtil, _reportDesignerUtil.Object));
            _vsKeyboardInputSimulation.KeyProcessors.Add((KeyProcessor)bufferCoordinator);
            _vsKeyboardInputSimulation.KeyProcessors.Add(new SimulationKeyProcessor(bufferCoordinator.VimBuffer.TextView));
        }
 public Fixture()
 {
     timeProviderMock = mockRepository.Create<ITimeProvider>();
 }
        public void ShouldAssignTheSameCallSequenceToCreatedMocksThatWasAssignedToIt()
        {
            var callSequence = new CallSequence(MockBehavior.Strict);
            var repository = new MockRepository(MockBehavior.Default)
            {
                CallSequence = callSequence
            };

            var mock = repository.Create<IFoo>();

            Assert.Equal(callSequence, mock.CallSequence);
        }
예제 #11
0
 public VendingSessionTests()
 {
     coinRecognizer = repository.Create<ICoinRecognizer>();
     logger = repository.Create<ILogger<CoinRecognizer>>(MockBehavior.Loose);
 }
예제 #12
0
 public void SetUp()
 {
     MockRepository     = new MockRepository(MockBehavior.Strict);
     MockLogger         = MockRepository.Create <ILogger <MaterialsGeneratorService> >(MockBehavior.Loose);
     MaterialGenService = new MaterialsGeneratorService(MockLogger.Object);
 }
예제 #13
0
 protected Mock <TMock> CreateMock <TMock>() where TMock : class
 {
     return(MockRepository.Create <TMock>());
 }
예제 #14
0
        public SagaProfileAnalyzerFactoryTests()
        {
            _mockRepository = new MockRepository(MockBehavior.Strict);

            _mockSagaProfileVersionAnalyzerFactory = _mockRepository.Create <ISagaProfileVersionAnalyzerFactory>();
        }
 public SendEventLogStateRepositoryTests()
 {
     mockRepository         = new MockRepository(MockBehavior.Default);
     mockLoggerService      = mockRepository.Create <ILoggerService>();
     mockPreferencesService = mockRepository.Create <IPreferencesService>();
 }
예제 #16
0
 protected override Wpf.VimKeyProcessor  CreateKeyProcessor()
 {
     _factory       = new MockRepository(MockBehavior.Strict);
     _mockVimBuffer = _factory.Create <IVimBuffer>();
     return(new VimKeyProcessor(_mockVimBuffer.Object, KeyUtil));
 }
예제 #17
0
 public virtual void TestFixtureSetUp()
 {
     MockRepository     = new MockRepository(MockBehavior.Default);
     MockHostController = MockRepository.Create <IHostController>();
 }
예제 #18
0
        protected void Create(bool insertMode, params string[] lines)
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _factory.DefaultValue = DefaultValue.Mock;
            _textView             = CreateTextView(lines);
            _textBuffer           = _textView.TextBuffer;
            _vim               = _factory.Create <IVim>(MockBehavior.Loose);
            _editorOptions     = _factory.Create <IEditorOptions>(MockBehavior.Loose);
            _textChangeTracker = _factory.Create <ITextChangeTracker>(MockBehavior.Loose);
            _textChangeTracker.SetupGet(x => x.CurrentChange).Returns(FSharpOption <TextChange> .None);
            _undoRedoOperations = new UndoRedoOperations(new StatusUtil(), FSharpOption <ITextUndoHistory> .None, null);
            _wordCompletionSessionFactoryService = _factory.Create <IWordCompletionSessionFactoryService>();

            var localSettings = new LocalSettings(Vim.GlobalSettings);

            _vimBuffer      = Vim.CreateVimBuffer(_textView);
            _globalSettings = _vimBuffer.GlobalSettings;
            var vimTextBuffer = Vim.GetOrCreateVimTextBuffer(_textView.TextBuffer);
            var vimBufferData = CreateVimBufferData(vimTextBuffer, _textView);

            _operations = CommonOperationsFactory.GetCommonOperations(vimBufferData);
            _broker     = _factory.Create <IDisplayWindowBroker>();
            _broker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _broker.SetupGet(x => x.IsQuickInfoActive).Returns(false);
            _broker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _broker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);
            _insertUtil  = _factory.Create <IInsertUtil>();
            _motionUtil  = _factory.Create <IMotionUtil>();
            _commandUtil = _factory.Create <ICommandUtil>();
            _capture     = _factory.Create <IMotionCapture>();

            // Setup the mouse.  By default we say it has no buttons down as that's the normal state
            _mouseDevice = _factory.Create <IMouseDevice>();
            _mouseDevice.SetupGet(x => x.IsLeftButtonPressed).Returns(false);

            // Setup the keyboard.  By default we don't say that any button is pressed.  Insert mode is usually
            // only concerned with arrow keys and we will set those up as appropriate for the typing tests
            _keyboardDevice = _factory.Create <IKeyboardDevice>();
            _keyboardDevice.Setup(x => x.IsArrowKeyDown).Returns(false);

            _modeRaw = new global::Vim.Modes.Insert.InsertMode(
                _vimBuffer,
                _operations,
                _broker.Object,
                _editorOptions.Object,
                _undoRedoOperations,
                _textChangeTracker.Object,
                _insertUtil.Object,
                _motionUtil.Object,
                _commandUtil.Object,
                _capture.Object,
                !insertMode,
                _keyboardDevice.Object,
                _mouseDevice.Object,
                WordUtil,
                _wordCompletionSessionFactoryService.Object);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
            _mode.CommandRan += (sender, e) => { _lastCommandRan = e.CommandRunData; };
        }
        public void ShouldGetCustomersByNameFilterResults()
        {
            var mockRepository             = new MockRepository(MockBehavior.Default);
            var customersRepositoryMock    = mockRepository.Create <ICustomersRepository>();
            var customerNameValidationMock = mockRepository.Create <ICustomerNameValidation>();
            var customerValidationMock     = mockRepository.Create <ICustomerValidation>();

            var searchString  = "wind";
            var mockCustomers = new List <Customer>
            {
                new Customer
                {
                    CustomerId   = 1,
                    CustomerName = "Northwind",
                    Address      = "Bangalore",
                    CreditLimit  = 23000,
                    ActiveStatus = true,
                    Remarks      = "Simple Customer Record"
                },
                new Customer
                {
                    CustomerId   = 2,
                    CustomerName = "Southwind",
                    Address      = "Bangalore",
                    CreditLimit  = 23000,
                    ActiveStatus = true,
                    Remarks      = "Simple Customer Record"
                },
                new Customer
                {
                    CustomerId   = 3,
                    CustomerName = "Eastwind",
                    Address      = "Bangalore",
                    CreditLimit  = 23000,
                    ActiveStatus = false,
                    Remarks      = "Simple Customer Record"
                }
            };

            customersRepositoryMock
            .Setup(repository => repository.GetCustomersByName(searchString))
            .Returns(mockCustomers);

            customerNameValidationMock
            .Setup(validation => validation.Validate(searchString))
            .Returns(true);

            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterInstance <ICustomersRepository>(customersRepositoryMock.Object);
            containerBuilder.RegisterInstance <ICustomerNameValidation>(customerNameValidationMock.Object);
            containerBuilder.RegisterInstance <ICustomerValidation>(customerValidationMock.Object);

            containerBuilder.RegisterType <CustomersBusinessComponent>()
            .As <ICustomersBusinessComponent>();

            var container = containerBuilder.Build();

            using (var scope = container.BeginLifetimeScope())
            {
                var businessComponent         = scope.Resolve <ICustomersBusinessComponent>();
                var filteredCustomers         = businessComponent.GetCustomers(searchString);
                var expectedNoOfCustomers     = 3;
                var actualNoOfCustomers       = filteredCustomers.Count();
                var expectedFirstCustomerName = "Northwind";
                var actualFirstCustomerName   = filteredCustomers.FirstOrDefault().CustomerName;

                Assert.NotNull(filteredCustomers);
                Assert.Equal <int>(expectedNoOfCustomers, actualNoOfCustomers);
                Assert.Equal(expectedFirstCustomerName, actualFirstCustomerName);
            }
        }
 public void SetUp()
 {
     serverClient = mocks.Create <CruiseServerClientBase>().Object;
     manager      = new HttpCruiseProjectManager(serverClient, "yyy");
 }
예제 #21
0
        public void SplitView1()
        {
            var view = _factory.Create <IWpfTextView>();

            Assert.IsFalse(_manager.SplitView(view.Object));
        }
예제 #22
0
        public void Initialize()
        {
            InitializeAutoMapper.Initialize();
            mockRepository = new MockRepository(MockBehavior.Default);
            IUnitOfWork mockUnitOfWork = mockRepository.Create <IUnitOfWork>().Object;

            mockContactRepository    = mockRepository.Create <IContactRepository>();
            mockTagRepository        = mockRepository.Create <ITagRepository>();
            mockUrlService           = mockRepository.Create <IUrlService>();
            imageService             = mockRepository.Create <IImageService>();
            customFieldService       = mockRepository.Create <ICustomFieldService>();
            mockIndexingService      = mockRepository.Create <IIndexingService>();
            mockSearchService        = mockRepository.Create <ISearchService <Contact> >();
            cachingService           = mockRepository.Create <ICachingService>();
            dropdownRepository       = mockRepository.Create <IDropdownRepository>();
            accountService           = mockRepository.Create <IAccountService>();
            mockUserRepository       = mockRepository.Create <IUserRepository>();
            mockMessageService       = mockRepository.Create <IMessageService>();
            mockFormRepository       = mockRepository.Create <IFormRepository>();
            mailGunService           = mockRepository.Create <IMailGunService>();
            tagService               = mockRepository.Create <ITagService>();
            advancedSearchRepository = mockRepository.Create <IAdvancedSearchRepository>();
            communicationService     = mockRepository.Create <ICommunicationService>();
            userService              = mockRepository.Create <IUserService>();
            serviceProvider          = mockRepository.Create <IServiceProviderRepository>();
            formSubmissionRepository = mockRepository.Create <IFormSubmissionRepository>(); //NEXG-3014
            findSpamService          = mockRepository.Create <IFindSpamService>();          //NEXG-3014
            contactService           = new ContactService(mockContactRepository.Object,
                                                          mockTagRepository.Object, mockUnitOfWork, mockUrlService.Object,
                                                          customFieldService.Object, cachingService.Object,
                                                          dropdownRepository.Object,
                                                          mockIndexingService.Object, mockSearchService.Object,
                                                          accountService.Object, mockUserRepository.Object,
                                                          mockMessageService.Object, imageService.Object, mockFormRepository.Object, mailGunService.Object, advancedSearchRepository.Object, communicationService.Object, userService.Object, serviceProvider.Object
                                                          , formSubmissionRepository.Object //NEXG-3014
                                                          , findSpamService.Object          //NEXG-3014
                                                          );
        }
예제 #23
0
 public void SetUp()
 {
     _mockRepository  = new(MockBehavior.Default);
     _mockPageService = _mockRepository.Create <IBlogPageService>();
 }
예제 #24
0
 public void SetUp()
 {
     _mockRepository = new(MockBehavior.Strict);
     _mockBlogConfig = _mockRepository.Create <IBlogConfig>();
 }
예제 #25
0
 public void Init()
 {
     _mockFactory     = new MockRepository(MockBehavior.Strict);
     _valueAppender   = _mockFactory.Create <IBsonDocumentValueAppender>();
     _structConverter = _mockFactory.Create <IBsonStructConverter>();
 }
예제 #26
0
 public void SetUp()
 {
     _mockRepository = new(MockBehavior.Strict);
     _mockMediator   = _mockRepository.Create <IMediator>();
 }
 public void Constructor_ThrowsArgumentNullExceptionIfFlexiQuoteBlockParserIsNull()
 {
     // Act and assert
     Assert.Throws <ArgumentNullException>(() => new FlexiQuoteBlocksExtension(null, _mockRepository.Create <BlockRenderer <FlexiQuoteBlock> >().Object));
 }
예제 #28
0
        public void TestInitialize()
        {
            _MockRepository = new MockRepository(MockBehavior.Strict);

            _MockCustomFilterConverterCollection = _MockRepository.Create <ICustomFilterConverterCollection <IUser> >();
        }
예제 #29
0
		public void ShouldOverrideDefaultBehavior()
		{
			var repository = new MockRepository(MockBehavior.Loose);
			var mock = repository.Create<IFoo>(MockBehavior.Strict);

			Assert.Equal(MockBehavior.Strict, mock.Behavior);
		}
예제 #30
0
        public void TestElasticSearchPipelineSingleThreaded()
        {
            var sql = @"SELECT
                      CustomerNM
                      ,CustomerID
                      ,	AliasPatientID
                      ,	GenderNormDSC
                      ,RaceNormDSC
                      ,MaritalStatusNormDSC  
                      FROM CAFEEDW.SharedClinicalUnion.ElasticsearchInputPatient where CustomerID = 4";

            var job = new Job
            {
                Config = new QueryConfig
                {
                    ConnectionString  = "foo",
                    LocalSaveFolder   = Path.GetTempPath(),
                    TopLevelKeyColumn = "AliasPatientID",
                    Url = "http://foo",
                    UploadToElasticSearch = false,
                    EntitiesPerUploadFile = 1
                },
                Data = new JobData
                {
                    MyDataSources = new List <DataSource>
                    {
                        new DataSource
                        {
                            Sql = sql
                        }
                    }
                }
            };

            var mockRepository       = new MockRepository(MockBehavior.Strict);
            var mockDatabusSqlReader = mockRepository.Create <IDatabusSqlReader>();

            mockDatabusSqlReader.Setup(
                service => service.ReadDataFromQueryAsync(
                    It.IsAny <IDataSource>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <ILogger>(),
                    It.IsAny <string>())).ReturnsAsync(
                new ReadSqlDataResult
            {
                ColumnList = new List <ColumnInfo>
                {
                    new ColumnInfo {
                        Name = "CustomerNM", ElasticSearchType = ElasticSearchTypes.keyword.ToString()
                    },
                    new ColumnInfo {
                        Name = "CustomerID", ElasticSearchType = ElasticSearchTypes.integer.ToString()
                    },
                    new ColumnInfo {
                        Name = "AliasPatientID", ElasticSearchType = ElasticSearchTypes.integer.ToString()
                    },
                    new ColumnInfo {
                        Name = "GenderNormDSC", ElasticSearchType = ElasticSearchTypes.keyword.ToString()
                    },
                    new ColumnInfo {
                        Name = "RaceNormDSC", ElasticSearchType = ElasticSearchTypes.keyword.ToString()
                    },
                    new ColumnInfo {
                        Name = "MaritalStatusNormDSC", ElasticSearchType = ElasticSearchTypes.keyword.ToString()
                    }
                },
                Data = new Dictionary <string, List <object[]> >
                {
                    {
                        "ElasticsearchInputPatient",
                        new List <object[]> {
                            new object[] { "name", 1, 2, "M", "White", "Married" }
                        }
                    }
                }
            });

            var mockFileUploaderFactory = mockRepository.Create <IElasticSearchUploaderFactory>();
            var mockFileUploader        = mockRepository.Create <IElasticSearchUploader>();

            mockFileUploaderFactory
            .Setup(service => service.Create(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <List <string> >(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(mockFileUploader.Object);

            mockFileUploader.Setup(
                service => service.SendStreamToHosts(
                    It.IsAny <string>(),
                    It.IsAny <int>(),
                    It.IsAny <Stream>(),
                    It.IsAny <bool>(),
                    It.IsAny <bool>())).Returns(Task.CompletedTask);

            mockFileUploader
            .Setup(service => service.StartUploadAsync())
            .Returns(Task.CompletedTask);

            ILogger logger = new LoggerConfiguration()
                             .MinimumLevel.Verbose()
                             .WriteTo.Debug()
                             .CreateLogger();

            using (var progressMonitor = new ProgressMonitor(new TestConsoleProgressLogger()))
            {
                using (var cancellationTokenSource = new CancellationTokenSource())
                {
                    var container = new UnityContainer();
                    container.RegisterInstance <IProgressMonitor>(progressMonitor);
                    container.RegisterInstance(mockDatabusSqlReader.Object);
                    container.RegisterInstance(mockFileUploaderFactory.Object);
                    container.RegisterInstance(logger);
                    container.RegisterType <IPipelineExecutorFactory, SingleThreadedPipelineExecutorFactory>();

                    var pipelineRunner = new PipelineRunner(container, cancellationTokenSource.Token);
                    try
                    {
                        pipelineRunner.RunElasticSearchPipeline(job);
                    }
                    catch (OperationCanceledException e)
                    {
                        Console.WriteLine(e.ToString());
                        throw;
                    }
                    catch (AggregateException e)
                    {
                        Console.WriteLine(e.Flatten().ToString());
                        throw;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        throw;
                    }
                }
            }
        }
예제 #31
0
		public void ShouldCreateMocksWithFactoryDefaultValue()
		{
			var repository = new MockRepository(MockBehavior.Loose) { DefaultValue = DefaultValue.Mock };

			var mock = repository.Create<IFoo>();

			Assert.NotNull(mock.Object.Bar());
		}
예제 #32
0
    public void SetUp()
    {
        _mockRepository = new(MockBehavior.Default);

        _mockThemeRepository = _mockRepository.Create <IRepository <BlogThemeEntity> >();
    }
예제 #33
0
 public void Setup()
 {
     _mockRepository     = new(MockBehavior.Default);
     _mockFriendlinkRepo = _mockRepository.Create <IRepository <FriendLinkEntity> >();
 }
예제 #34
0
		public void ShouldOverrideDefaultBehaviorWithCtorArgs()
		{
			var repository = new MockRepository(MockBehavior.Loose);
			var mock = repository.Create<BaseClass>(MockBehavior.Strict, "Foo");

			Assert.Equal(MockBehavior.Strict, mock.Behavior);
			Assert.Equal("Foo", mock.Object.Value);
		}
 public void SetUp()
 {
     _mockRepository    = new(MockBehavior.Default);
     _mockSearchService = _mockRepository.Create <ISearchService>();
 }
 public AlbumServiceTests()
 {
     _mockRepository         = new MockRepository(MockBehavior.Strict);
     _mockHttpRequestFactory = _mockRepository.Create <IHttpRequestFactory>();
 }
예제 #37
0
        public void CalculateIRR()
        {
            var mockRepository = new MockRepository(MockBehavior.Strict);

            var dateRange = new DateRange(new Date(2000, 01, 01), new Date(2010, 01, 01));

            var holding1 = mockRepository.Create <IReadOnlyHolding>();

            holding1.Setup(x => x.Value(dateRange.FromDate)).Returns(1000.00m);

            var holding2 = mockRepository.Create <IReadOnlyHolding>();

            holding2.Setup(x => x.Value(dateRange.FromDate)).Returns(2000.00m);
            holding2.Setup(x => x.Value(dateRange.ToDate)).Returns(3000.00m);

            var holding3 = mockRepository.Create <IReadOnlyHolding>();

            holding3.Setup(x => x.Value(dateRange.ToDate)).Returns(4000.00m);

            var initialHoldings = new IReadOnlyHolding[] { holding1.Object, holding2.Object };

            var finalHoldings = new IReadOnlyHolding[] { holding2.Object, holding3.Object };

            var holdings = mockRepository.Create <IHoldingCollection>();

            holdings.Setup(x => x.All(dateRange.FromDate)).Returns(initialHoldings);
            holdings.Setup(x => x.All(dateRange.ToDate)).Returns(finalHoldings);

            var transactions = new List <CashAccountTransaction>();

            transactions.Add(new CashAccountTransaction(Guid.NewGuid(), new Date(2001, 01, 01), "", 200.00m, BankAccountTransactionType.Deposit, 300.00m));
            transactions.Add(new CashAccountTransaction(Guid.NewGuid(), new Date(2002, 01, 01), "", -100.00m, BankAccountTransactionType.Withdrawl, 200.00m));
            transactions.Add(new CashAccountTransaction(Guid.NewGuid(), new Date(2004, 01, 01), "", 200.00m, BankAccountTransactionType.Deposit, 500.00m));
            transactions.Add(new CashAccountTransaction(Guid.NewGuid(), new Date(2005, 01, 01), "", -450.00m, BankAccountTransactionType.Withdrawl, 50.00m));

            var transactionRange = mockRepository.Create <ITransactionRange <CashAccountTransaction> >();

            transactionRange.Setup(x => x.GetEnumerator()).Returns(transactions.GetEnumerator());

            var transactionList = mockRepository.Create <ITransactionList <CashAccountTransaction> >();

            transactionList.Setup(x => x.InDateRange(new DateRange(dateRange.FromDate.AddDays(1), dateRange.ToDate))).Returns(transactionRange.Object);


            var cashAccount = mockRepository.Create <IReadOnlyCashAccount>();

            cashAccount.Setup(x => x.Balance(dateRange.FromDate)).Returns(100.00m);
            cashAccount.Setup(x => x.Balance(dateRange.ToDate)).Returns(50.00m);
            cashAccount.Setup(x => x.Transactions).Returns(transactionList.Object);

            var portfolio = mockRepository.Create <IPortfolio>();

            portfolio.Setup(x => x.Holdings).Returns(holdings.Object);
            portfolio.Setup(x => x.CashAccount).Returns(cashAccount.Object);

            var irr = portfolio.Object.CalculateIRR(dateRange);

            irr.Should().Be(0.08745m);

            mockRepository.Verify();
        }
예제 #38
0
 public void Init()
 {
     _mockRepo          = new MockRepository(MockBehavior.Default);
     _datasourceFactory = _mockRepo.Create <IDataSourceFactory>();
 }
예제 #39
0
        public void Initialize()
        {
            mockRepository = new MockRepository(MockBehavior.Strict);

            mockStreamFactory = mockRepository.Create <IZapStreamFactory>();
        }
예제 #40
0
        private void Create()
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _adapter = _factory.Create <IVsAdapter>();
            _adapter.Setup(x => x.IsWatchWindowView(It.IsAny <ITextView>())).Returns(false);
            _adapter.Setup(x => x.IsTextEditorView(It.IsAny <ITextView>())).Returns(true);
            _undoManagerProvider            = _factory.Create <ITextBufferUndoManagerProvider>();
            _editorAdaptersFactoryService   = _factory.Create <IVsEditorAdaptersFactoryService>();
            _editorOperationsFactoryService = _factory.Create <IEditorOperationsFactoryService>();
            _statusBar = _factory.Create <StatusBar>();
            _uiVSShell = _factory.Create <IVsUIShell>(MockBehavior.Strict);
            _vsShell   = _factory.Create <IVsShell>(MockBehavior.Loose);
            _dte       = _factory.Create <_DTE>();
            _dte.SetupGet(x => x.StatusBar).Returns(_statusBar.Object);
            _textManager = _factory.Create <ITextManager>();
            _textManager.Setup(x => x.GetDocumentTextViews(DocumentLoad.RespectLazy)).Returns(new List <ITextView>());
            _vimApplicationSettings = _factory.Create <IVimApplicationSettings>(MockBehavior.Loose);
            _extensionAdapterBroker = _factory.Create <IExtensionAdapterBroker>(MockBehavior.Loose);
            _commandDispatcher      = _factory.Create <ICommandDispatcher>();
            _clipboardDevice        = _factory.Create <IClipboardDevice>(MockBehavior.Loose);

            var  vsMonitorSelection = _factory.Create <IVsMonitorSelection>();
            uint selectionCookie    = 42;

            vsMonitorSelection.Setup(x => x.AdviseSelectionEvents(It.IsAny <IVsSelectionEvents>(), out selectionCookie)).Returns(VSConstants.S_OK);

            var  vsRunningDocumentTable     = _factory.Create <IVsRunningDocumentTable>();
            uint runningDocumentTableCookie = 86;

            vsRunningDocumentTable.Setup(x => x.AdviseRunningDocTableEvents(It.IsAny <IVsRunningDocTableEvents3>(), out runningDocumentTableCookie)).Returns(VSConstants.S_OK);


            var sp = _factory.Create <SVsServiceProvider>();

            sp.Setup(x => x.GetService(typeof(_DTE))).Returns(_dte.Object);
            sp.Setup(x => x.GetService(typeof(SVsUIShell))).Returns(_uiVSShell.Object);
            sp.Setup(x => x.GetService(typeof(SVsShell))).Returns(_vsShell.Object);
            sp.Setup(x => x.GetService(typeof(IVsExtensibility))).Returns(_factory.Create <IVsExtensibility>().Object);
            sp.Setup(x => x.GetService(typeof(SVsShellMonitorSelection))).Returns(vsMonitorSelection.Object);
            sp.Setup(x => x.GetService(typeof(SVsRunningDocumentTable))).Returns(vsRunningDocumentTable.Object);
            _hostRaw = new VsVimHost(
                _adapter.Object,
                _factory.Create <ITextBufferFactoryService>().Object,
                _factory.Create <ITextEditorFactoryService>().Object,
                _factory.Create <ITextDocumentFactoryService>().Object,
                _undoManagerProvider.Object,
                _editorAdaptersFactoryService.Object,
                _editorOperationsFactoryService.Object,
                _factory.Create <ISmartIndentationService>().Object,
                _textManager.Object,
                _factory.Create <ISharedServiceFactory>(MockBehavior.Loose).Object,
                _vimApplicationSettings.Object,
                _extensionAdapterBroker.Object,
                ProtectedOperations,
                _factory.Create <IMarkDisplayUtil>(MockBehavior.Loose).Object,
                _factory.Create <IControlCharUtil>(MockBehavior.Loose).Object,
                _commandDispatcher.Object,
                sp.Object,
                _clipboardDevice.Object);
            _host = _hostRaw;
        }
예제 #41
0
 public void SetUp()
 {
     _mockRepository     = new(MockBehavior.Default);
     _mockPostEntityRepo = _mockRepository.Create <IRepository <PostEntity> >();
 }