public async Task DeleteUnreferencedTagsInInaccessibleWorkspace() { var accessibleWorkspace = new MockWorkspace(1000); var inaccessibleWorkspace = new MockWorkspace(2000, isInaccessible: true); var tag1 = new MockTag(1001, accessibleWorkspace); var tag2 = new MockTag(1002, accessibleWorkspace, SyncStatus.SyncFailed); var tag3 = new MockTag(1003, accessibleWorkspace, SyncStatus.RefetchingNeeded); var tag4 = new MockTag(2001, inaccessibleWorkspace); var tag5 = new MockTag(2002, inaccessibleWorkspace, SyncStatus.SyncNeeded); var tag6 = new MockTag(2003, inaccessibleWorkspace, SyncStatus.RefetchingNeeded); var tag7 = new MockTag(2004, inaccessibleWorkspace); var tag8 = new MockTag(2005, inaccessibleWorkspace); var te1 = new MockTimeEntry(10001, accessibleWorkspace, tags: new[] { tag1 }); var te2 = new MockTimeEntry(10002, accessibleWorkspace, tags: new[] { tag2 }); var te3 = new MockTimeEntry(20001, inaccessibleWorkspace, tags: new[] { tag4 }); var te4 = new MockTimeEntry(20002, inaccessibleWorkspace, tags: new[] { tag5 }); var tags = new[] { tag1, tag2, tag3, tag4, tag5, tag6, tag7, tag8 }; var timeEntries = new[] { te1, te2, te3, te4 }; var unreferencedTags = new[] { tag7, tag8 }; var neededTags = tags.Where(tag => !unreferencedTags.Contains(tag)); configureDataSource(tags, timeEntries); await state.Start().SingleAsync(); tagsDataSource.Received().DeleteAll(Arg.Is <IEnumerable <IThreadSafeTag> >(arg => arg.All(tag => unreferencedTags.Contains(tag)) && arg.None(tag => neededTags.Contains(tag)))); }
public void TestRenderInvalidType() { PdfBuilder builder = new PdfBuilder(new Document(), PdfOptions.Default); ITag tag = new MockTag(p => { }); ITagRenderer renderer = new Renderer(); Assert.Throws <InvalidCastException>(() => renderer.Render(tag, builder)); }
public async Task DeleteInaccessibleWorkspacesNotReferencedByTags() { var accessibleReferenced = new MockWorkspace(1, false, SyncStatus.InSync); var accessibleUnreferenced = new MockWorkspace(2, false, SyncStatus.InSync); var inaccessibleReferenced = new MockWorkspace(3, true, SyncStatus.InSync); var inaccessibleUnreferenced = new MockWorkspace(4, true, SyncStatus.InSync); var tag1 = new MockTag(11, accessibleReferenced, syncStatus: SyncStatus.InSync); var tag2 = new MockTag(22, inaccessibleReferenced, syncStatus: SyncStatus.InSync); var workspaces = new[] { accessibleReferenced, accessibleUnreferenced, inaccessibleReferenced, inaccessibleUnreferenced }; var tags = new[] { tag1, tag2 }; configureDataSources(workspaces, tags: tags); await state.Start().SingleAsync(); workspacesDataSource.Received().DeleteAll(Arg.Is <IEnumerable <IThreadSafeWorkspace> >( arg => arg.All(ws => ws == inaccessibleUnreferenced))); }
public void DoesNotCreateTheTagIfItAlreadyExists(NonEmptyString name, NonZeroInt workspaceId) { var mockTag = new MockTag { Name = name.Get, WorkspaceId = workspaceId.Get }; DataSource.Tags .GetAll(Arg.Any <Func <IDatabaseTag, bool> >()) .Returns(Observable.Return <IEnumerable <IThreadSafeTag> >(new[] { mockTag })); var createdTag = createTagInteractor(name.Get, workspaceId.Get).Execute().Wait(); DataSource.Tags.DidNotReceive().Create( Arg.Is <IThreadSafeTag>(tag => tag.SyncStatus == SyncStatus.SyncNeeded) ).Wait(); createdTag.Should().BeNull(); }
public void TagsByDate_HonorChainedAnnotatedTags() { var c = new MockCommit(); var col = new MockTagCollection(); var first = new MockTag { NameEx = "first", TargetEx = c, AnnotationEx = new MockTagAnnotation { TaggerEx = new Signature("a", "", 5.Seconds().Ago()), TargetEx = c, } }; col.Add(first); col.Add(new MockTag { NameEx = "second", TargetEx = first.Annotation, AnnotationEx = new MockTagAnnotation { TaggerEx = new Signature("a", "", 2.Seconds().Ago()), TargetEx = c, } }); var repo = new MockRepository { Tags = col }; var tags = repo.TagsByDate(c); Assert.AreEqual("second", tags.First().Name); }