public void CanOpenThisRepo() { var st = new StackTrace(0, true); var filename = st.GetFrame(0).GetFileName(); var fixture = new CommitHintViewModel(filename, Substitute.For<IVisualStudioOps>()); Assert.True(fixture.Open.CanExecute(null)); }
public void CantOpenWhenThereIsNoGitRepo() { var ops = Substitute.For<IGitRepoOps>(); var filename = @"C:\Foo\Bar\Baz.txt"; ops.FindGitRepo(filename).Returns(default(string)); var watch = Substitute.For<IFilesystemWatchCache>(); watch.Register(null).ReturnsForAnyArgs(Observable.Never<IList<string>>()); var fixture = new CommitHintViewModel(filename, Substitute.For<IVisualStudioOps>(), null, ops, watch); this.Log().Info("Protocol URL: {0}", fixture.ProtocolUrl); Assert.False(fixture.Open.CanExecute(null)); }
public void MakeSureWeDisposeFileSystemWatcher() { var ops = Substitute.For<IGitRepoOps>(); var filename = @"C:\Foo\Bar\Baz.txt"; ops.FindGitRepo(filename).Returns(@"C:\Foo"); ops.ProtocolUrlForRepoPath(@"C:\Foo").Returns(default(string)); var subscriptionCount = 0; var countingObs = Observable.Create<IList<string>>(subj => { subscriptionCount++; return Disposable.Create(() => subscriptionCount--); }); var watch = Substitute.For<IFilesystemWatchCache>(); watch.Register(null).ReturnsForAnyArgs(countingObs); Assert.Equal(0, subscriptionCount); var fixture = new CommitHintViewModel(filename, Substitute.For<IVisualStudioOps>(), null, ops, watch); Assert.NotEqual(0, subscriptionCount); fixture.Dispose(); Assert.Equal(0, subscriptionCount); }
public void SavesWhenYouClickTheButton() { var ops = Substitute.For<IGitRepoOps>(); var filename = @"C:\Foo\Bar\Baz.txt"; ops.FindGitRepo(filename).Returns(@"C:\Foo"); ops.ProtocolUrlForRepoPath(@"C:\Foo").Returns("https://github.com/reactiveui/reactiveui.git"); var watch = Substitute.For<IFilesystemWatchCache>(); watch.Register(null).ReturnsForAnyArgs(Observable.Never<IList<string>>()); var vs = Substitute.For<IVisualStudioOps>(); var fixture = new CommitHintViewModel(filename, vs, null, ops, watch); Assert.True(fixture.Open.CanExecute(null)); fixture.Open.Execute(null); vs.Received(1).SaveAll(); }