public void Intialize() { _addin = new Mock <AddIn>(); _view = new Mock <IToDoExplorerWindow>(); _window = RdMockFacotry.CreateWindowMock(); _windows = new MockWindowsCollection(_window.Object); _loader = new ConfigurationLoader(); _markers = _loader.GetDefaultTodoMarkers(); _gridViewSorter = new GridViewSort <ToDoItem>("Priority", false); }
public void InitializeMocks() { _window = Mocks.MockFactory.CreateWindowMock(); _windows = new MockWindowsCollection(new List <Window> { _window.Object }); _vbe = Mocks.MockFactory.CreateVbeMock(_windows); var mockHost = new Mock <IHostApplication>(); mockHost.SetupAllProperties(); _configService = new Mock <IConfigProvider <SourceControlSettings> >(); _configService.Setup(c => c.Create()).Returns(GetDummyConfig()); _folderBrowser = new Mock <IFolderBrowser>(); _folderBrowserFactory = new Mock <IFolderBrowserFactory>(); _folderBrowserFactory.Setup(f => f.CreateFolderBrowser(It.IsAny <string>())).Returns(_folderBrowser.Object); _folderBrowserFactory.Setup(f => f.CreateFolderBrowser(It.IsAny <string>(), false)).Returns(_folderBrowser.Object); var masterRemote = new Mock <LibGit2Sharp.Branch>(); masterRemote.SetupGet(git => git.Tip).Returns(new Mock <LibGit2Sharp.Commit>().Object); masterRemote.SetupGet(git => git.FriendlyName).Returns("master"); var initialBranch = new Branch("master", "refs/Heads/master", false, true, masterRemote.Object); _provider = new Mock <ISourceControlProvider>(); _provider.SetupGet(git => git.CurrentBranch).Returns(initialBranch); _provider.SetupGet(git => git.UnsyncedLocalCommits).Returns(new List <ICommit>()); _provider.SetupGet(git => git.UnsyncedRemoteCommits).Returns(new List <ICommit>()); _provider.Setup(git => git.InitVBAProject(It.IsAny <string>())).Returns(GetDummyRepo()); _provider.Setup(git => git.Clone(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <SecureCredentials>())).Returns(GetDummyRepo()); _provider.Setup(git => git.CurrentRepository).Returns(GetDummyRepo()); _providerFactory = new Mock <ISourceControlProviderFactory>(); _providerFactory.Setup(f => f.CreateProvider(It.IsAny <VBProject>())) .Returns(_provider.Object); _providerFactory.Setup(f => f.CreateProvider(It.IsAny <VBProject>(), It.IsAny <IRepository>(), It.IsAny <ICodePaneWrapperFactory>())) .Returns(_provider.Object); _providerFactory.Setup(f => f.CreateProvider(It.IsAny <VBProject>(), It.IsAny <IRepository>(), It.IsAny <SecureCredentials>(), It.IsAny <ICodePaneWrapperFactory>())) .Returns(_provider.Object); _changesVM = new ChangesViewViewModel(); _branchesVM = new BranchesViewViewModel(); _unsyncedVM = new UnsyncedCommitsViewViewModel(); _settingsVM = new SettingsViewViewModel(_configService.Object, _folderBrowserFactory.Object, new Rubberduck.UI.OpenFileDialog()); }
/// <summary> /// Creates a new <see cref="Mock{VBE}"/> that returns the <see cref="Windows"/> collection argument out of the Windows property. /// </summary> /// <param name="windows"> /// A <see cref="MockWindowsCollection"/> is expected. /// Other objects implementing the<see cref="Windows"/> interface could cause issues. /// </param> /// <returns></returns> internal static Mock<VBE> CreateVbeMock(MockWindowsCollection windows) { var vbe = new Mock<VBE>(); windows.VBE = vbe.Object; vbe.Setup(m => m.Windows).Returns(windows); vbe.SetupProperty(m => m.ActiveCodePane); vbe.SetupProperty(m => m.ActiveVBProject); vbe.SetupGet(m => m.SelectedVBComponent).Returns(() => vbe.Object.ActiveCodePane.CodeModule.Parent); vbe.SetupGet(m => m.ActiveWindow).Returns(() => vbe.Object.ActiveCodePane.Window); //setting up a main window lets the native window functions fun var mainWindow = new Mock<Window>(); mainWindow.Setup(m => m.HWnd).Returns(0); vbe.SetupGet(m => m.MainWindow).Returns(mainWindow.Object); return vbe; }
private Mock<VBE> CreateVbeMock() { var vbe = new Mock<VBE>(); var windows = new MockWindowsCollection {VBE = vbe.Object}; vbe.Setup(m => m.Windows).Returns(() => windows); vbe.SetupProperty(m => m.ActiveCodePane); vbe.SetupProperty(m => m.ActiveVBProject); vbe.SetupGet(m => m.SelectedVBComponent).Returns(() => vbe.Object.ActiveCodePane.CodeModule.Parent); vbe.SetupGet(m => m.ActiveWindow).Returns(() => vbe.Object.ActiveCodePane.Window); var mainWindow = new Mock<Window>(); mainWindow.Setup(m => m.HWnd).Returns(0); vbe.SetupGet(m => m.MainWindow).Returns(() => mainWindow.Object); _vbProjects = CreateProjectsMock(); vbe.SetupGet(m => m.VBProjects).Returns(() => _vbProjects.Object); _vbCodePanes = CreateCodePanesMock(); vbe.SetupGet(m => m.CodePanes).Returns(() => _vbCodePanes.Object); return vbe; }