public void Install_should_install_if_a_package_has_not_been_installed_yet()
        {
            // Arrange
            var fixture = new Fixture().Customize(new AutoMoqCustomization());

            var proj = fixture.Freeze<Project>();
            var pwPkg = new ProjectWidePackage("Prig", "2.0.0", proj);
            var mocks = new MockRepository(MockBehavior.Strict);
            {
                var m = mocks.Create<IVsPackageInstallerServices>();
                m.Setup(_ => _.IsPackageInstalledEx(proj, "Prig", "2.0.0")).Returns(false);
                m.Setup(_ => _.IsPackageInstalled(proj, "Prig")).Returns(false);
                fixture.Inject(m);
            }
            {
                var m = mocks.Create<IVsPackageUninstaller>();
                fixture.Inject(m);
            }
            {
                var m = mocks.Create<IVsPackageInstaller>();
                m.Setup(_ => _.InstallPackage(default(string), proj, "Prig", "2.0.0", false));
                fixture.Inject(m);
            }

            var pwInstllr = fixture.NewProjectWideInstaller();


            // Act
            pwInstllr.Install(pwPkg);


            // Assert
            mocks.VerifyAll();
        }
 public void Create(params string[] lines)
 {
     _textBuffer = EditorUtil.CreateTextBuffer(lines);
     _factory = new MockRepository(MockBehavior.Strict);
     _adapterRaw = new ResharperExternalEditAdapter();
     _adapter = _adapterRaw;
 }
        public async Task Add_BadRequest_InvalidQuantity()
        {
            var repo = new Moq.MockRepository(Moq.MockBehavior.Strict);

            var cartId = 42;

            var items = new System.Collections.Generic.Dictionary <string, int>()
            {
                { "article1", 0 }
            };
            var queryItems = new webapi.Controllers.CartItems {
                Items = items
            };
            var cartItems = new cart.grain.CartItems {
                Items = items
            };

            // initialize grain
            var cartGrain = repo.Create <ICart>();

            cartGrain.Setup(x => x.Add(It.IsAny <cart.grain.CartItems>())).Returns(Task.FromResult((CartItemsStatusCode.InvalidQuantity, cartItems)));

            // initialize grain factory
            var grainFactory = repo.Create <IGrainFactory>();

            grainFactory.Setup(x => x.GetGrain <ICart>(cartId)).Returns(cartGrain.Object);


            var controller = new webapi.Controllers.CartController(grainFactory.Object);
            var response   = await controller.Add(cartId, queryItems) as BadRequestObjectResult;

            Assert.AreEqual(400, response.StatusCode);

            repo.VerifyAll();
        }
Beispiel #4
0
        protected VimTest()
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _globalSettings = new GlobalSettings();
            _fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict);
            _bufferFactory = VimBufferFactory;
            _simpleListener = new SimpleListener();
            var creationListeners = new [] { new Lazy<IVimBufferCreationListener>(() => _simpleListener) };

            var map = new Dictionary<string, VariableValue>();
            _keyMap = new KeyMap(_globalSettings, map);
            _vimHost = _factory.Create<IVimHost>(MockBehavior.Strict);
            _vimHost.Setup(x => x.CreateHiddenTextView()).Returns(CreateTextView());
            _vimHost.Setup(x => x.AutoSynchronizeSettings).Returns(true);
            _vimRaw = new Vim(
                _vimHost.Object,
                _bufferFactory,
                CompositionContainer.GetExportedValue<IVimInterpreterFactory>(),
                creationListeners.ToFSharpList(),
                _globalSettings,
                _factory.Create<IMarkMap>().Object,
                _keyMap,
                MockObjectFactory.CreateClipboardDevice().Object,
                _factory.Create<ISearchService>().Object,
                _fileSystem.Object,
                new VimData(_globalSettings),
                _factory.Create<IBulkOperations>().Object,
                map,
                new EditorToSettingSynchronizer());
            _vim = _vimRaw;
            _vim.AutoLoadVimRc = false;
        }
Beispiel #5
0
 public static Mock<IClipboardDevice> CreateClipboardDevice(MockRepository factory = null)
 {
     factory = factory ?? new MockRepository(MockBehavior.Strict);
     var device = factory.Create<IClipboardDevice>();
     device.SetupProperty(x => x.Text);
     return device;
 }
        public UserBusinessLogicTests()
        {
            MockFactory = new MockRepository(MockBehavior.Loose) { DefaultValue = DefaultValue.Mock };

            MockedUserBusinessLogic = MockFactory.Create<IUserBusinessLogic>();
            MockedUserRepository = MockFactory.Create<IUserRepository>();
        }
        public async Task InvokeTest()
        {
            var mr = new MockRepository(MockBehavior.Strict);
            var next = mr.Create<OwinMiddleware>(MockBehavior.Strict, (OwinMiddleware) null);
            var ctx = mr.Create<IOwinContext>();
            var logger = mr.Create<ILog>();
            var exception = new Exception();

            logger.Setup(x => x.Fatal(It.IsAny<object>(), exception)).Verifiable();
            next.Setup(x => x.Invoke(ctx.Object)).Returns(async () =>
            {
                await Task.Delay(1);
                throw exception;
            }).Verifiable();

            var mw = new ExceptionHandlerMiddleware(next.Object, logger.Object);
            try
            {
                await mw.Invoke(ctx.Object);
            }
            catch (Exception e)
            {
                Assert.AreEqual(exception, e);
            }

            mr.VerifyAll();
        }
 public void Setup()
 {
     _interview = ObjectMother.GetInterview();
     _mockRepository = new MockRepository(MockBehavior.Default);
     _interviewRepoMoq = _mockRepository.Create<IInterviewRepository>();
     _service = new InterviewService(_interviewRepoMoq.Object);
 }
 public async Task InvokeErrorTest()
 {
     var mr = new MockRepository(MockBehavior.Strict);
     var next = mr.Create<OwinMiddleware>(MockBehavior.Strict, (OwinMiddleware)null);
     var ctx = mr.Create<IOwinContext>();
     var logger = mr.Create<ILog>();
     var exception = new Exception();
     var request = mr.Create<IOwinRequest>();
     ctx.SetupGet(x => x.Request).Returns(request.Object).Verifiable();
     logger.Setup(x => x.Info(It.IsAny<string>())).Throws(exception);
     request.SetupGet(x => x.Method).Returns("fasefaes").Verifiable();
     request.SetupGet(x => x.Uri).Returns(new Uri("http://ya.ru")).Verifiable();
     request.SetupGet(x => x.RemoteIpAddress).Returns("asefasergsdrg").Verifiable();
     request.SetupGet(x => x.RemotePort).Returns(11).Verifiable();
     var mw = new LoggerMiddleware(next.Object, logger.Object);
     try
     {
         await mw.Invoke(ctx.Object);
     }
     catch (Exception e)
     {
         Assert.AreEqual(exception, e);
         return;
     }
     finally
     {
         mr.VerifyAll();
     }
     Assert.Fail();
 }
        public void ProduceOfferReturnsCorrectResult(
            string locationName,
            string currentTime)
        {
            // Arrange
            var moqRepo = new MockRepository(MockBehavior.Default);

            var sut = new DateAndLocationMortgageApplicationProcessor
            {
                LocationProvider = moqRepo.Create<ILocationProvider>().Object,
                TimeProvider = moqRepo.Create<ITimeProvider>().Object
            };

            Mock.Get(sut.LocationProvider)
                .Setup(lp => lp.GetCurrentLocationName())
                .Returns(locationName);
            Mock.Get(sut.TimeProvider)
                .Setup(tp => tp.GetCurrentTime())
                .Returns(DateTimeOffset.Parse(currentTime));

            // Act
            var dummyApplication = new MortgageApplication();
            var actual = sut.ProduceOffer(dummyApplication);

            // Assert
            var expected = new IRendering[]
            {
                new TextRendering(
                    locationName +
                    ", " +
                    DateTimeOffset.Parse(currentTime).ToString("D")),
                new LineBreakRendering()
            };
            Assert.Equal(expected, actual);
        }
Beispiel #11
0
        protected HostFactoryTest()
        {
            _globalSettings = Vim.GlobalSettings;
            _protectedOperations = new TestableProtectedOperations();
            _mockFactory = new MockRepository(MockBehavior.Strict);
            _synchronizer = _mockFactory.Create<IEditorToSettingsSynchronizer>(MockBehavior.Strict);
            _vsEditorAdaptersFactoryService = _mockFactory.Create<IVsEditorAdaptersFactoryService>();
            _vimApplicationSettings = _mockFactory.Create<IVimApplicationSettings>(MockBehavior.Loose);

            var vsAdapter = _mockFactory.Create<IVsAdapter>();
            vsAdapter.SetupGet(x => x.EditorAdapter).Returns(_vsEditorAdaptersFactoryService.Object);

            _hostFactory = new HostFactory(
                Vim,
                _vsEditorAdaptersFactoryService.Object,
                _mockFactory.Create<IDisplayWindowBrokerFactoryService>(MockBehavior.Loose).Object,
                _mockFactory.Create<ITextManager>(MockBehavior.Loose).Object,
                vsAdapter.Object,
                _protectedOperations,
                new VimBufferCoordinatorFactory(Vim),
                _mockFactory.Create<IKeyUtil>(MockBehavior.Loose).Object,
                _synchronizer.Object,
                _vimApplicationSettings.Object,
                new Lazy<ICommandTargetFactory, IOrderable>[] { });
        }
    public void TestMatch()
    {
      PrecursorNeutralLossMatcher matcher = new PrecursorNeutralLossMatcher(0.5, 0.0);
      var factory = new MockRepository(MockBehavior.Strict);

      var sr = factory.Create<IIdentifiedPeptideResult>();
      sr.Setup(x => x.Peptide).Returns("K.S*R.A");

      PeakList<MatchedPeak> expPeaks = new PeakList<MatchedPeak>()
      {
        new MatchedPeak(964.96, 1,1),
        new MatchedPeak(981.99, 1,1),
        new MatchedPeak(982.97, 1,1)
      };
      expPeaks.PrecursorCharge = 1;
      expPeaks.PrecursorMZ = 1000.0;

      sr.Setup(x => x.ExperimentalPeakList).Returns(expPeaks);

      matcher.Match(sr.Object);

      Assert.AreEqual("[MH-H2O-NH3]", expPeaks[0].DisplayName);
      Assert.AreEqual("[MH-H2O]", expPeaks[1].DisplayName);
      Assert.AreEqual("[MH-NH3]", expPeaks[2].DisplayName);
    }
 public void Create(params string[] lines)
 {
     _textBuffer = CreateTextBuffer(lines);
     _factory = new MockRepository(MockBehavior.Strict);
     _reSharperUtilRaw = new ReSharperUtil(isResharperInstalled: true);
     _reSharperUtil = _reSharperUtilRaw;
 }
        public void Initalize()
        {
            _factory = new MockRepository(MockBehavior.Loose);
            _container = new AutoMockContainer(_factory);
            _coins = new List<Coin>();
            _purchaseServiceMock = _container.GetMock<IPurchaseService>();

            var product_a = new Product() { Price = 1, Title = "Apple" };
            var product_b = new Product() { Price = .75m, Title = "Banana" };

            var slot_a = new Slot() { Button = "A", Product = product_a, MaxNumberOfProduct = 5, Quantity = 4 };
            var slot_b = new Slot() { Button = "B", Product = product_b, MaxNumberOfProduct = 5, Quantity = 0 };

            _dollar = new Coin() { Title = "One Dollar", Value = 1, ShortName = "O" };
            _quarter = new Coin() { Title = "Quarter", Value = .25m, ShortName = "Q" };
            _dime = new Coin() { Title = "Dime", Value = .1m, ShortName = "d" };
            _nickle = new Coin() { Title = "Nickle", Value = .05m, ShortName = "n" };
            _penny = new Coin() { Title = "Penny", Value = .01m, ShortName = "p" };

            _slots = new List<Slot>() { slot_a, slot_b };

            _maxSlots = 5;

            _machineService = new MachineService(_maxSlots, _purchaseServiceMock.Object);
        }
Beispiel #15
0
        protected void Create(params string[] lines)
        {
            _vimHost = (MockVimHost)Vim.VimHost;
            _textView = CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vimTextBuffer = Vim.CreateVimTextBuffer(_textBuffer);
            _localSettings = _vimTextBuffer.LocalSettings;

            var foldManager = CreateFoldManager(_textView);

            _factory = new MockRepository(MockBehavior.Loose);
            _statusUtil = _factory.Create<IStatusUtil>();
            _bulkOperations = new TestableBulkOperations();

            var vimBufferData = CreateVimBufferData(
                _vimTextBuffer,
                _textView,
                statusUtil: _statusUtil.Object);
            _jumpList = vimBufferData.JumpList;
            _windowSettings = vimBufferData.WindowSettings;

            _vimData = Vim.VimData;
            _macroRecorder = Vim.MacroRecorder;
            _globalSettings = Vim.GlobalSettings;

            var operations = CreateCommonOperations(vimBufferData);
            _motionUtil = new MotionUtil(vimBufferData, operations);
            _commandUtil = new CommandUtil(
                vimBufferData,
                _motionUtil,
                operations,
                foldManager,
                new InsertUtil(vimBufferData, operations),
                _bulkOperations);
        }
 public AutoMockingBuilderStrategy(IEnumerable<Type> registeredTypes, IUnityContainer container)
 {
     var autoMoqer = container.Resolve<AutoMoqer>();
     _mockFactory = new MockRepository(autoMoqer.DefaultBehavior);
     _registeredTypes = registeredTypes;
     _container = container;
 }
        public async Task InvokeTest()
        {
            var mr = new MockRepository(MockBehavior.Strict);
            var next = mr.Create<OwinMiddleware>(MockBehavior.Strict, (OwinMiddleware)null);
            var ctx = mr.Create<IOwinContext>();
            var cidStore = mr.Create<ICorrelationIdStore>();
            var response = mr.Create<IOwinResponse>();
            var hDict = new HeaderDictionary(new Dictionary<string, string[]>());
            var correlationId = new CorrelationId();

            next.Setup(x => x.Invoke(ctx.Object)).Returns(Task.CompletedTask).Verifiable();
            ctx.SetupGet(x => x.Response).Returns(response.Object).Verifiable();
            response.SetupGet(x => x.Headers).Returns(hDict).Verifiable();
            cidStore.Setup(x => x.Read()).Returns(correlationId).Verifiable();

            Assert.AreEqual(0, hDict.Count);

            var midleware = new SetCorrelationIdHeaderMiddleware(next.Object, cidStore.Object);
            await midleware.Invoke(ctx.Object);

            Assert.AreEqual(1, hDict.Count);
            var actual = hDict["X-CORRELATIONID"];
            Assert.AreEqual(correlationId.ToString(), actual);
            mr.VerifyAll();
        }
            public void WhenDataReaderGetNameReturnsNull_ThenTheColumnIndexIsUsedAsColumnName()
            {
                List<string> columns = new List<string>();

                MockRepository mockRepository = new MockRepository(MockBehavior.Strict);

                Mock<IDataReader> dataReaderMock = mockRepository.Create<IDataReader>();
                dataReaderMock.SetupSequence(x => x.Read()).Returns(true).Returns(false);
                dataReaderMock.SetupGet(x => x.FieldCount).Returns(2);
                dataReaderMock.Setup(x => x.IsDBNull(It.IsInRange<int>(0, 1, Range.Inclusive))).Returns(false);
                dataReaderMock.Setup(x => x.GetValue(It.IsInRange<int>(0, 1, Range.Inclusive))).Returns<int>(n => n);
                dataReaderMock.Setup(x => x.GetName(It.IsInRange<int>(0, 1, Range.Inclusive))).Returns((string)null);

                Mock<IDataRow> rowMock = mockRepository.Create<IDataRow>();
                rowMock.SetupSet(x => x[0] = 0);
                rowMock.SetupSet(x => x[1] = 1);

                Mock<ISimpleDataTable> dataTableMock = mockRepository.Create<ISimpleDataTable>();
                dataTableMock.SetupGet(x => x.ColumnNames).Returns(columns);
                dataTableMock.Setup(x => x.NewRow()).Returns(rowMock.Object);

                DataReaderAdapter target = new DataReaderAdapter();

                target.Fill(dataTableMock.Object, dataReaderMock.Object);

                dataTableMock.Verify(x => x.NewRow(), Times.Once());
                dataReaderMock.Verify(x => x.GetName(It.IsAny<int>()), Times.Exactly(2));

                Assert.Equal(2, columns.Count);
                Assert.Equal("0", columns[0]);
                Assert.Equal("1", columns[1]);
            }
            public void WhenDataReaderIsDBNullReturnsTrue_ThenTheFieldIsNotSetInTheRow()
            {
                List<string> columns = new List<string>();

                MockRepository mockRepository = new MockRepository(MockBehavior.Strict);

                Mock<IDataReader> dataReaderMock = mockRepository.Create<IDataReader>();
                dataReaderMock.SetupSequence(x => x.Read()).Returns(true).Returns(false);
                dataReaderMock.SetupGet(x => x.FieldCount).Returns(2);
                dataReaderMock.Setup(x => x.IsDBNull(0)).Returns(false);
                dataReaderMock.Setup(x => x.IsDBNull(1)).Returns(true);
                dataReaderMock.Setup(x => x.GetValue(0)).Returns(0);
                dataReaderMock.Setup(x => x.GetName(It.IsInRange<int>(0, 1, Range.Inclusive))).Returns<int>(n => "Col" + n);

                Mock<IDataRow> rowMock = mockRepository.Create<IDataRow>();
                rowMock.SetupSet(x => x[0] = 0);

                Mock<ISimpleDataTable> dataTableMock = mockRepository.Create<ISimpleDataTable>();
                dataTableMock.SetupGet(x => x.ColumnNames).Returns(columns);
                dataTableMock.Setup(x => x.NewRow()).Returns(rowMock.Object);

                DataReaderAdapter target = new DataReaderAdapter();

                target.Fill(dataTableMock.Object, dataReaderMock.Object);

                dataTableMock.Verify(x => x.NewRow(), Times.Once());
                dataReaderMock.Verify(x => x.GetValue(0), Times.Once());
                dataReaderMock.Verify(x => x.GetValue(1), Times.Never());
                rowMock.VerifySet(x => x[0] = It.IsAny<int>(), Times.Once());
                rowMock.VerifySet(x => x[1] = It.IsAny<int>(), Times.Never());
            }
Beispiel #20
0
        public void Init()
        {
            _mockRepository = new MockRepository(MockBehavior.Strict);

            _fdResolver = _mockRepository.Create<IFirstDayOfWeekResolver>();
            _weekPadding = _mockRepository.Create<IWeekPaddingCalculator>();
        }
 public void Setup()
 {
     _candidate = ObjectMother.GetCandidate();
     _mockRepository = new MockRepository(MockBehavior.Default);
     _candidateRepoMock = _mockRepository.Create<ICandidateRepository>();
     _service = new CandidateService(_candidateRepoMock.Object);
 }
Beispiel #22
0
 public static Mock<IMacroRecorder> CreateMacroRecorder(MockRepository factory = null)
 {
     factory = factory ?? new MockRepository(MockBehavior.Strict);
     var recorder = factory.Create<IMacroRecorder>(MockBehavior.Loose);
     recorder.SetupGet(x => x.IsRecording).Returns(false);
     return recorder;
 }
 public void Setup()
 {
     _address = ObjectMother.GetAddress();
     _mockRepository = new MockRepository(MockBehavior.Default);
     _addressRepoMoq = _mockRepository.Create<IAddressRepository>();
     _service = new AddressService(_addressRepoMoq.Object);
 }
Beispiel #24
0
 public static Mock<IVsTextLineMarker> CreateVsTextLineMarker(
     TextSpan span,
     MARKERTYPE type,
     MockRepository factory = null)
 {
     return CreateVsTextLineMarker(span, (int)type, factory);
 }
Beispiel #25
0
 protected ReportDesignerUtilTest()
 {
     _factory = new MockRepository(MockBehavior.Strict);
     _vsEditorAdaptersFactoryService = _factory.Create<IVsEditorAdaptersFactoryService>();
     _reportDesignerUtilRaw = new ReportDesignerUtil(_vsEditorAdaptersFactoryService.Object);
     _reportDesignerUtil = _reportDesignerUtilRaw;
 }
        protected CommandMarginControllerTest()
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _marginControl = new CommandMarginControl();
            _marginControl.CommandLineTextBox.Text = String.Empty;

            _search = _factory.Create<IIncrementalSearch>();
            _search.SetupGet(x => x.InSearch).Returns(false);
            _search.SetupGet(x => x.InPasteWait).Returns(false);
            _vimBuffer = new MockVimBuffer();
            _vimBuffer.IncrementalSearchImpl = _search.Object;
            _vimBuffer.VimImpl = MockObjectFactory.CreateVim(factory: _factory).Object;
            _vimBuffer.CommandModeImpl = _factory.Create<ICommandMode>(MockBehavior.Loose).Object;
            var textBuffer = CreateTextBuffer(new []{""});
            _vimBuffer.TextViewImpl = TextEditorFactoryService.CreateTextView(textBuffer);

            Mock<IVimGlobalSettings> globalSettings = new Mock<IVimGlobalSettings>();
            _vimBuffer.GlobalSettingsImpl = globalSettings.Object;

            var editorFormatMap = _factory.Create<IEditorFormatMap>(MockBehavior.Loose);
            editorFormatMap.Setup(x => x.GetProperties(It.IsAny<string>())).Returns(new ResourceDictionary());

            var parentVisualElement = _factory.Create<FrameworkElement>();

            _controller = new CommandMarginController(
                _vimBuffer,
                parentVisualElement.Object,
                _marginControl,
                VimEditorHost.EditorFormatMapService.GetEditorFormatMap(_vimBuffer.TextView),
                VimEditorHost.ClassificationFormatMapService.GetClassificationFormatMap(_vimBuffer.TextView));
        }
 public UserServiceTest()
 {
     this.mockRepository = new MockRepository(MockBehavior.Strict);
     this.mockErrorState = this.mockRepository.Create<IErrorState>();
     this.mockUserRepository = this.mockRepository.Create<IUserRepository>();
     this.userService = new UserService(this.mockErrorState.Object, this.mockUserRepository.Object);
 }
        public VsCommandTargetTest()
        {
            _textView = CreateTextView("");
            _buffer = Vim.CreateVimBuffer(_textView);
            _bufferCoordinator = new VimBufferCoordinator(_buffer);
            _vim = _buffer.Vim;
            _factory = new MockRepository(MockBehavior.Strict);

            // By default Resharper isn't loaded
            _resharperUtil = _factory.Create<IResharperUtil>();
            _resharperUtil.SetupGet(x => x.IsInstalled).Returns(false);

            _nextTarget = _factory.Create<IOleCommandTarget>(MockBehavior.Strict);
            _vsAdapter = _factory.Create<IVsAdapter>();
            _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(InputManager.Current.PrimaryKeyboardDevice);
            _vsAdapter.Setup(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.Setup(x => x.InDebugMode).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny<ITextView>())).Returns(false);

            _broker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Loose);

            var oldCommandFilter = _nextTarget.Object;
            var vsTextView = _factory.Create<IVsTextView>(MockBehavior.Loose);
            vsTextView.Setup(x => x.AddCommandFilter(It.IsAny<IOleCommandTarget>(), out oldCommandFilter)).Returns(0);
            var result = VsCommandTarget.Create(
                _bufferCoordinator,
                vsTextView.Object,
                _vsAdapter.Object,
                _broker.Object,
                _resharperUtil.Object,
                KeyUtil);
            Assert.True(result.IsSuccess);
            _targetRaw = result.Value;
            _target = _targetRaw;
        }
Beispiel #29
0
 public void Create(params string[] lines)
 {
     _textBuffer = CreateTextBuffer(lines);
     _factory = new MockRepository(MockBehavior.Strict);
     _adapterRaw = new ReSharperUtil(true);
     _adapter = _adapterRaw;
 }
Beispiel #30
0
        public UnitTest1()
        {
            var mock = new Moq.MockRepository(MockBehavior.Default);

            logMocking = mock.Create <ILogFile>();
            var dac = mock.Create <IAccountDAC>();

            sut = new ATMController(logMocking.Object, dac.Object);
            var accounts = new List <Account>()
            {
                new Account()
                {
                    Username = "******", Balance = 500
                },
                new Account()
                {
                    Username = "******", Balance = 50
                },
            };

            dac.Setup(dac => dac.GetAllAccounts())
            .Returns(accounts);

            //  this.sut = sut;
        }
 public void Create(params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
     _textBuffer = _textView.TextBuffer;
     _factory = new MockRepository(MockBehavior.Strict);
     _editOpts = _factory.Create<IEditorOperations>();
     _vimHost = _factory.Create<IVimHost>();
     _vimHost.Setup(x => x.IsDirty(It.IsAny<ITextBuffer>())).Returns(false);
     _operations = _factory.Create<ICommonOperations>();
     _operations.SetupGet(x => x.EditorOperations).Returns(_editOpts.Object);
     _statusUtil = _factory.Create<IStatusUtil>();
     _fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict);
     _foldManager = _factory.Create<IFoldManager>(MockBehavior.Strict);
     _vimData = new VimData();
     _vim = MockObjectFactory.CreateVim(RegisterMap, host: _vimHost.Object, vimData: _vimData, factory: _factory);
     var localSettings = new LocalSettings(Vim.GlobalSettings);
     var vimTextBuffer = MockObjectFactory.CreateVimTextBuffer(
         _textBuffer,
         vim: _vim.Object,
         localSettings: localSettings,
         factory: _factory);
     var vimBufferData = CreateVimBufferData(
         vimTextBuffer.Object,
         _textView,
         statusUtil: _statusUtil.Object);
     var vimBuffer = CreateVimBuffer(vimBufferData);
     _interpreter = new Interpreter.VimInterpreter(
         vimBuffer,
         _operations.Object,
         _foldManager.Object,
         _fileSystem.Object,
         _factory.Create<IBufferTrackingService>().Object);
 }
Beispiel #32
0
 public void ClassInit()
 {
     mockRepository = new MockRepository(MockBehavior.Strict)
     {
         DefaultValue = DefaultValue.Mock
     };
     mockDeliverableServiceV2 = mockRepository.Create <IDeliverableServiceV2>();
     mockIntegrationService   = mockRepository.Create <IIntergrationService>();
 }
Beispiel #33
0
 public void ClassInit()
 {
     mockRepository = new MockRepository(MockBehavior.Loose)
     {
         DefaultValue = DefaultValue.Mock
     };
     mockBudgetPlanTowService = mockRepository.Create <IBudgetPlanTowService>();
     mockBudgetService        = mockRepository.Create <IBudgetService>();
     mockMappingEngine        = mockRepository.Create <IMappingEngine>();
 }
Beispiel #34
0
 public void ClassInit()
 {
     mockRepository = new MockRepository(MockBehavior.Strict)
     {
         DefaultValue = DefaultValue.Mock
     };
     mockuserRepository               = mockRepository.Create <IUserRepository>();
     mockuserchannelRepository        = mockRepository.Create <IUserChannelRepository>();
     mockuserrolemoduleRepository     = mockRepository.Create <IUserRoleModuleRepository>();
     mockuserdepartmenttypeRepository = mockRepository.Create <IMRMUserDepartmentTypeRepository>();
     mockunitofwork = mockRepository.Create <IUnitOfWork>();
 }
 public void ClassInit()
 {
     mockRepository = new MockRepository(MockBehavior.Strict)
     {
         DefaultValue = DefaultValue.Mock
     };
     mockfinanceservice           = mockRepository.Create <IFinanceService>();
     mockApInvoiceBatchRepository = mockRepository.Create <IApInvoiceBatchRepository>();
     mockInvoiceHeaderRepository  = mockRepository.Create <IInvoiceHeaderRepository>();
     mockIUnitOfWork                = mockRepository.Create <IUnitOfWork>();
     mockIInvoiceLineRepository     = mockRepository.Create <IInvoiceLineRepository>();
     mockFinanceService             = mockRepository.Create <IFinanceService>();
     mockWBS_DeliverablesRepository = mockRepository.Create <IWBS_DeliverablesRepository>();
 }
Beispiel #36
0
 public void ClassInit()
 {
     mockRepository = new MockRepository(MockBehavior.Strict)
     {
         DefaultValue = DefaultValue.Mock
     };
     mockcontractrequestService                = mockRepository.Create <IContractRequestService>();
     mockcontractprojectservice                = mockRepository.Create <IProjectService>();
     mockbudgetService                         = mockRepository.Create <IBudgetService>();
     mockdeliverablerepository                 = mockRepository.Create <IDeliverableRepository>();
     mockVendorViewRepository                  = mockRepository.Create <IMasterVendorViewRepository>();
     mockDeliverableVendorRepository           = mockRepository.Create <IDeliverable_VendorRepository>();
     mockVendorRepository                      = mockRepository.Create <IVendorRepository>();
     mockDeliverableUserTitleMrmUserRepository = mockRepository.Create <IDeliverableUserTitleMrmUserRepository>();
     mockUserRepository                        = mockRepository.Create <IUserRepository>();
 }
Beispiel #37
0
 public void ClassInit()
 {
     mockRepository = new MockRepository(MockBehavior.Strict)
     {
         DefaultValue = DefaultValue.Mock
     };
     mockuserRepository               = mockRepository.Create <IUserRepository>();
     mockuserService                  = mockRepository.Create <IUserService>();
     mockchannelRepository            = mockRepository.Create <IChannelRepository>();
     mockmoduleRepository             = mockRepository.Create <IModuleRepository>();
     mockuserdepartmenttypeRepository = mockRepository.Create <IMRMUserDepartmentTypeRepository>();
     mockdepartmentRepository         = mockRepository.Create <IDepartmentRepository>();
     mockunitofwork          = mockRepository.Create <IUnitOfWork>();
     mockroleRepository      = mockRepository.Create <IRoleRepository>();
     mockusertitleRepository = mockRepository.Create <IUserTitleRepository>();
 }
 public void ClassInit()
 {
     mockRepository = new MockRepository(MockBehavior.Loose)
     {
         DefaultValue = DefaultValue.Mock
     };
     mockProjectService             = mockRepository.Create <IProjectService>();
     mockContractRequestService     = mockRepository.Create <IContractRequestService>();
     mockBudgetService              = mockRepository.Create <IBudgetService>();
     mockApprovalService            = mockRepository.Create <IApprovalService>();
     mockInternationalService       = mockRepository.Create <IInternationalService>();
     mockDeliverableService         = mockRepository.Create <IDeliverableService>();
     mockDeliverableServiceV2       = mockRepository.Create <IDeliverableServiceV2>();
     mockFinanceService             = mockRepository.Create <IFinanceService>();
     mockWBS_DeliverablesRepository = mockRepository.Create <IWBS_DeliverablesRepository>();
     mockUserService = mockRepository.Create <IUserService>();
 }
 public void ClassInit()
 {
     mockRepository = new MockRepository(MockBehavior.Loose)
     {
         DefaultValue = DefaultValue.Mock
     };
     mockBudgetService         = mockRepository.Create <IBudgetService>();
     mockdeliverableService    = mockRepository.Create <IDeliverableService>();
     mockImageService          = mockRepository.Create <IImageService>();
     mockproductService        = mockRepository.Create <IProductService>();
     mockpropertyService       = mockRepository.Create <IPropertyService>();
     mockIntergrationService   = mockRepository.Create <IIntergrationService>();
     mockTrackApprovalService  = mockRepository.Create <ITrackApprovalService>();
     mockApprovalService       = mockRepository.Create <IApprovalService>();
     mockInternationalService  = mockRepository.Create <IInternationalService>();
     mockDeliverableRepository = mockRepository.Create <IDeliverableRepository>();
 }
 public void ClassInit()
 {
     mockRepository = new MockRepository(MockBehavior.Strict)
     {
         DefaultValue = DefaultValue.Mock
     };
     mockDocumentRepository           = mockRepository.Create <IDocumentRepository>();
     mockDocumentService              = mockRepository.Create <IDocumentsService>();
     mockDocumentAccessTypeRepository = mockRepository.Create <IDocumentAccessTypeRepository>();
     mockMRMUserRepository            = mockRepository.Create <IDocument_MRMUserRepository>();
     mockUserRepository = mockRepository.Create <IUserRepository>();
     mockDeliverableDocumentRepository = mockRepository.Create <IDeliverableDocumentRepository>();
     mockUnitOfWork          = mockRepository.Create <IUnitOfWork>();
     mockUserService         = mockRepository.Create <IUserService>();
     mockDropDownListService = mockRepository.Create <IDropDownListService>();
     mockContractRequestMasterVendorDocumentRepository = mockRepository.Create <IContractRequest_MasterVendor_DocumentRepository>();
 }
 public void ClassInit()
 {
     mockRepository = new MockRepository(MockBehavior.Strict)
     {
         DefaultValue = DefaultValue.Mock
     };
     mockIntergrationService           = mockRepository.Create <IIntergrationService>();
     mockWorkOrderRepository           = mockRepository.Create <IWorkOrderRepository>();
     mockDeliverableRepository         = mockRepository.Create <IDeliverableRepository>();
     mockCalendarRepository            = mockRepository.Create <ICalendarRepository>();
     mockDeliverableBudgetRepository   = mockRepository.Create <IDeliverableBudgetRepository>();
     mockWorkOrderTransactionRepositry = mockRepository.Create <IWorkOrderTransactionRepositry>();
     mockInvoiceLineRepository         = mockRepository.Create <IInvoiceLineRepository>();
     mockUnitOfWork                      = mockRepository.Create <IUnitOfWork>();
     mockTypeOfWorkRepository            = mockRepository.Create <ITypeOfWorkRepository>();
     mockWBSFiscalYear_ChannelRepository = mockRepository.Create <IWBSFiscalYear_ChannelRepository>();
     mockUserRepository                  = mockRepository.Create <IUserRepository>();
 }
 public void ClassInit()
 {
     mockRepository = new MockRepository(MockBehavior.Strict)
     {
         DefaultValue = DefaultValue.Mock
     };
     mockbudgetService                    = mockRepository.Create <IBudgetService>();
     mockunitOfWork                       = mockRepository.Create <IUnitOfWork>();
     mockdeliverableService               = mockRepository.Create <IDeliverableService>();
     mockdeliverableServiceV2             = mockRepository.Create <IDeliverableServiceV2>();
     mockproductService                   = mockRepository.Create <IProductService>();
     mockpropertyService                  = mockRepository.Create <IPropertyService>();
     mocktypeOfWorkRepository             = mockRepository.Create <ITypeOfWorkRepository>();
     mockBudgetByCategoryRollupRepository = mockRepository.Create <IBudgetByCategoryRollupRepository>();
     mockBudgetByCategoryRepository       = mockRepository.Create <IBudgetByCategoryRepository>();
     mockUserChannelRepository            = mockRepository.Create <IUserChannelRepository>();
     mockProductFamilyRepository          = mockRepository.Create <IProductFamilyRepository>();
     mockdeliverableCategoryRepository    = mockRepository.Create <IDeliverableCategoryRepository>();
     mockForecastSnapshotRepository       = mockRepository.Create <IForecastSnapshotBatchRepository>();
     mockWBSElementRepository             = mockRepository.Create <IWBSElementRepository>();
 }
        public async Task Remove_Ok()
        {
            var repo = new Moq.MockRepository(Moq.MockBehavior.Strict);

            var cartId = 42;

            var items = new System.Collections.Generic.Dictionary <string, int>()
            {
                { "article1", 3 }
            };
            var queryItems = new webapi.Controllers.CartItems {
                Items = items
            };
            var cartItems = new cart.grain.CartItems {
                Items = items
            };
            var emptyCartItems = new cart.grain.CartItems();

            // initialize grain
            var cartGrain = repo.Create <ICart>();

            cartGrain.Setup(x => x.Remove(It.Is <cart.grain.CartItems>(o => o.Items["article1"] == 3))).Returns(Task.FromResult((CartItemsStatusCode.Ok, emptyCartItems)));

            // initialize grain factory
            var grainFactory = repo.Create <IGrainFactory>();

            grainFactory.Setup(x => x.GetGrain <ICart>(cartId)).Returns(cartGrain.Object);


            var controller = new webapi.Controllers.CartController(grainFactory.Object);
            var response   = await controller.Remove(cartId, queryItems) as OkObjectResult;

            Assert.AreEqual(200, response.StatusCode);
            var result = (webapi.Controllers.CartItems)response.Value;

            Assert.AreEqual(0, result.Items.Count);

            repo.VerifyAll();
        }
        public async Task Clear_Ok()
        {
            var repo = new Moq.MockRepository(Moq.MockBehavior.Strict);

            var cartId = 42;

            // initialize grain
            var cartGrain = repo.Create <ICart>();

            cartGrain.Setup(x => x.Clear()).Returns(Task.CompletedTask);

            // initialize grain factory
            var grainFactory = repo.Create <IGrainFactory>();

            grainFactory.Setup(x => x.GetGrain <ICart>(cartId)).Returns(cartGrain.Object);


            var controller = new webapi.Controllers.CartController(grainFactory.Object);
            var response   = await controller.Clear(cartId) as OkResult;

            Assert.AreEqual(200, response.StatusCode);

            repo.VerifyAll();
        }
Beispiel #45
0
        public void DemoMock01()
        {
            var mock       = new Moq.MockRepository(Moq.MockBehavior.Default);
            var logMocking = mock.Create <ILogFile>();
            //  var log = logMocking.Object;
            //log.WriteWithdraw("sakul123", 199);

            var expectedDate = DateTime.Now;

            logMocking.Setup(it => it.GetCurrentDate(It.IsAny <int>()))
            .Returns <int>(number =>
            {
                if (number == 1)
                {
                    return(expectedDate);
                }
                else if (number == 2)
                {
                    return(expectedDate.AddDays(1));
                }
                else
                {
                    return(DateTime.Now);
                }
            }
                           );
            var log = logMocking.Object;

            var currentTime = log.GetCurrentDate(1);

            // logMocking.Verify(it => it.WriteWithdraw(
            //    It.Is<string>(acut => acut == "sakul"),
            //    It.Is<double>(acut => acut == 199)));

            Assert.Equal(expectedDate, currentTime);
        }
Beispiel #46
0
 public TopicTrendFeedReaderTests()
 {
     _mockRepository = new Moq.MockRepository(MockBehavior.Strict);
     _mockXmlReader  = _mockRepository.Create <IXmlReader>();
 }
Beispiel #47
-1
        public VimTest()
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _globalSettings = new GlobalSettings();
            _markMap = _factory.Create<IMarkMap>(MockBehavior.Strict);
            _fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict);
            _bufferFactory = VimBufferFactory;

            var map = new Dictionary<string, VariableValue>();
            _keyMap = new KeyMap(_globalSettings, map);
            _vimHost = _factory.Create<IVimHost>(MockBehavior.Strict);
            _searchInfo = _factory.Create<ISearchService>(MockBehavior.Strict);
            _vimRaw = new Vim(
                _vimHost.Object,
                _bufferFactory,
                FSharpList<Lazy<IVimBufferCreationListener>>.Empty,
                _globalSettings,
                _markMap.Object,
                _keyMap,
                MockObjectFactory.CreateClipboardDevice().Object,
                _searchInfo.Object,
                _fileSystem.Object,
                new VimData(),
                _factory.Create<IBulkOperations>().Object,
                map);
            _vim = _vimRaw;
            _vim.AutoLoadVimRc = false;
        }