public void verify_format_updated() { SetHandleToReturn(); var docRm = new DocumentDescriptorReadModel(1L, new DocumentDescriptorId(1), new BlobId("file_1")); docRm.AddHandle(new DocumentHandle("rev_1")); docRm.Created = true; rmDocuments.Add(docRm); CreateSut(); var evt = new DocumentLinked(new DocumentHandle("rev_1"), new DocumentDescriptorId(1), new DocumentDescriptorId(2), new FileNameWithExtension("test.txt")); _sut.Handle(evt, false); //Handle is linked to document. var evtFormat = new FormatAddedToDocumentDescriptor(new DocumentFormat("blah"), new BlobId("test.1"), new PipelineId("tika")); evtFormat.AssignIdForTest(new DocumentDescriptorId(1)); _sut.Handle(evtFormat, false); //format is linked to document. var evtFormatUpdated = new DocumentFormatHasBeenUpdated(new DocumentFormat("blah"), new BlobId("test.2"), new PipelineId("tika")); evtFormatUpdated.AssignIdForTest(new DocumentDescriptorId(1)); _sut.Handle(evtFormatUpdated, false); //format is linked to document. Assert.That(rmStream, Has.Count.EqualTo(3)); Assert.That(rmStream[0].EventType, Is.EqualTo(HandleStreamEventTypes.DocumentHasNewFormat)); Assert.That(rmStream[0].Handle, Is.EqualTo("rev_1")); Assert.That(rmStream[0].FormatInfo.DocumentFormat.ToString(), Is.EqualTo("original")); Assert.That(rmStream[0].Filename.FileName, Is.EqualTo("test")); Assert.That(rmStream[0].Filename.Extension, Is.EqualTo("txt")); Assert.That(rmStream[0].FormatInfo.BlobId, Is.EqualTo(new BlobId("file_1"))); Assert.That(rmStream[0].DocumentDescriptorId, Is.EqualTo(new DocumentDescriptorId(1))); Assert.That(rmStream[1].EventType, Is.EqualTo(HandleStreamEventTypes.DocumentHasNewFormat)); Assert.That(rmStream[1].Handle, Is.EqualTo("rev_1")); Assert.That(rmStream[1].FormatInfo.DocumentFormat.ToString(), Is.EqualTo("blah")); Assert.That(rmStream[1].FormatInfo.BlobId.ToString(), Is.EqualTo("test.1")); Assert.That(rmStream[1].FormatInfo.PipelineId.ToString(), Is.EqualTo("tika")); Assert.That(rmStream[1].Filename.FileName, Is.EqualTo("test")); //expectation returns always the same handle Assert.That(rmStream[1].Filename.Extension, Is.EqualTo("txt")); Assert.That(rmStream[1].DocumentDescriptorId, Is.EqualTo(new DocumentDescriptorId(1))); Assert.That(rmStream[2].EventType, Is.EqualTo(HandleStreamEventTypes.DocumentFormatUpdated)); Assert.That(rmStream[2].Handle, Is.EqualTo("rev_1")); Assert.That(rmStream[2].FormatInfo.DocumentFormat.ToString(), Is.EqualTo("blah")); Assert.That(rmStream[2].FormatInfo.BlobId.ToString(), Is.EqualTo("test.2")); Assert.That(rmStream[2].FormatInfo.PipelineId.ToString(), Is.EqualTo("tika")); Assert.That(rmStream[2].Filename.FileName, Is.EqualTo("test")); //expectation returns always the same handle Assert.That(rmStream[2].Filename.Extension, Is.EqualTo("txt")); Assert.That(rmStream[2].DocumentDescriptorId, Is.EqualTo(new DocumentDescriptorId(1))); }
public void verify_stream_events_have_custom_handle_data() { SetHandleToReturn(); var docRm = new DocumentDescriptorReadModel(1L, new DocumentDescriptorId(1), new BlobId("file_1")); docRm.Created = true; docRm.AddHandle(new DocumentHandle("rev_1")); rmDocuments.Add(docRm); CreateSut(); var evt = new DocumentLinked(new DocumentHandle("rev_1"), new DocumentDescriptorId(1), new DocumentDescriptorId(2), new FileNameWithExtension("test.txt")); _sut.Handle(evt, false); //Handle is linked to document. Assert.That(rmStream, Has.Count.EqualTo(1)); Assert.That(rmStream[0].DocumentCustomData, Is.EqualTo(handle.CustomData)); }
public void verify_pipeline_id_is_original_when_pipeline_is_null() { SetHandleToReturn(); var docRm = new DocumentDescriptorReadModel(1L, new DocumentDescriptorId(1), new BlobId("file_1")); docRm.AddHandle(new DocumentHandle("rev_1")); docRm.Created = true; rmDocuments.Add(docRm); CreateSut(); var evt = new DocumentLinked( new DocumentHandle("rev_1"), new DocumentDescriptorId(1), new DocumentDescriptorId(2), new FileNameWithExtension("test.txt")); _sut.Handle(evt, false); //Handle is linked to document. Assert.That(rmStream, Has.Count.EqualTo(1)); Assert.That(rmStream[0].FormatInfo.PipelineId, Is.EqualTo(new PipelineId("original"))); }
public void verify_stream_events_on_attachment() { SetHandleToReturn(); var docRm = new DocumentDescriptorReadModel(1L, new DocumentDescriptorId(1), new BlobId("file_1")); var rev1 = new DocumentHandle("rev_1"); docRm.AddHandle(rev1); rmDocuments.Add(docRm); var attachHandle = new DocumentHandle("rev_2"); var docRmAttach = new DocumentDescriptorReadModel(1L, new DocumentDescriptorId(1), new BlobId("file_2")); docRmAttach.AddHandle(attachHandle); rmDocuments.Add(docRmAttach); CreateSut(); var evt = new DocumentDescriptorHasNewAttachment(attachHandle, "path.txt").AssignIdForTest(new DocumentId(1)); _sut.Handle(evt, false); //Handle is linked to document. Assert.That(rmStream, Has.Count.EqualTo(1)); Assert.That(rmStream[0].EventType, Is.EqualTo(HandleStreamEventTypes.DocumentHasNewAttachment)); Assert.That(rmStream[0].EventData[StreamReadModelEventDataKeys.ChildHandle], Is.EqualTo(attachHandle)); }
public void verify_pipeline_id_is_original_when_pipeline_is_null() { SetHandleToReturn(); var docRm = new DocumentDescriptorReadModel(1L, new DocumentDescriptorId(1), new BlobId("file_1")); docRm.AddHandle(new DocumentHandle("rev_1")); docRm.Created = true; rmDocuments.Add(docRm); CreateSut(); var evt = new DocumentLinked( new DocumentHandle("rev_1"), new DocumentDescriptorId(1), new DocumentDescriptorId(2), new FileNameWithExtension("test.txt")); _sut.Handle(evt, false); //Handle is linked to document. Assert.That(rmStream, Has.Count.EqualTo(1)); Assert.That(rmStream[0].FormatInfo.PipelineId, Is.EqualTo(new PipelineId("original"))); }
public void verify_format_updated() { SetHandleToReturn(); var docRm = new DocumentDescriptorReadModel(1L, new DocumentDescriptorId(1), new BlobId("file_1")); docRm.AddHandle(new DocumentHandle("rev_1")); docRm.Created = true; rmDocuments.Add(docRm); CreateSut(); var evt = new DocumentLinked(new DocumentHandle("rev_1"), new DocumentDescriptorId(1), new DocumentDescriptorId(2), new FileNameWithExtension("test.txt")); _sut.Handle(evt, false); //Handle is linked to document. var evtFormat = new FormatAddedToDocumentDescriptor(new DocumentFormat("blah"), new BlobId("test.1"), new PipelineId("tika")); evtFormat.AssignIdForTest(new DocumentDescriptorId(1)); _sut.Handle(evtFormat, false); //format is linked to document. var evtFormatUpdated = new DocumentFormatHasBeenUpdated(new DocumentFormat("blah"), new BlobId("test.2"), new PipelineId("tika")); evtFormatUpdated.AssignIdForTest(new DocumentDescriptorId(1)); _sut.Handle(evtFormatUpdated, false); //format is linked to document. Assert.That(rmStream, Has.Count.EqualTo(3)); Assert.That(rmStream[0].EventType, Is.EqualTo(HandleStreamEventTypes.DocumentHasNewFormat)); Assert.That(rmStream[0].Handle, Is.EqualTo("rev_1")); Assert.That(rmStream[0].FormatInfo.DocumentFormat.ToString(), Is.EqualTo("original")); Assert.That(rmStream[0].Filename.FileName, Is.EqualTo("test")); Assert.That(rmStream[0].Filename.Extension, Is.EqualTo("txt")); Assert.That(rmStream[0].FormatInfo.BlobId, Is.EqualTo(new BlobId("file_1"))); Assert.That(rmStream[0].DocumentDescriptorId, Is.EqualTo(new DocumentDescriptorId(1))); Assert.That(rmStream[1].EventType, Is.EqualTo(HandleStreamEventTypes.DocumentHasNewFormat)); Assert.That(rmStream[1].Handle, Is.EqualTo("rev_1")); Assert.That(rmStream[1].FormatInfo.DocumentFormat.ToString(), Is.EqualTo("blah")); Assert.That(rmStream[1].FormatInfo.BlobId.ToString(), Is.EqualTo("test.1")); Assert.That(rmStream[1].FormatInfo.PipelineId.ToString(), Is.EqualTo("tika")); Assert.That(rmStream[1].Filename.FileName, Is.EqualTo("test")); //expectation returns always the same handle Assert.That(rmStream[1].Filename.Extension, Is.EqualTo("txt")); Assert.That(rmStream[1].DocumentDescriptorId, Is.EqualTo(new DocumentDescriptorId(1))); Assert.That(rmStream[2].EventType, Is.EqualTo(HandleStreamEventTypes.DocumentFormatUpdated)); Assert.That(rmStream[2].Handle, Is.EqualTo("rev_1")); Assert.That(rmStream[2].FormatInfo.DocumentFormat.ToString(), Is.EqualTo("blah")); Assert.That(rmStream[2].FormatInfo.BlobId.ToString(), Is.EqualTo("test.2")); Assert.That(rmStream[2].FormatInfo.PipelineId.ToString(), Is.EqualTo("tika")); Assert.That(rmStream[2].Filename.FileName, Is.EqualTo("test")); //expectation returns always the same handle Assert.That(rmStream[2].Filename.Extension, Is.EqualTo("txt")); Assert.That(rmStream[2].DocumentDescriptorId, Is.EqualTo(new DocumentDescriptorId(1))); }
public void verify_stream_events_on_attachment() { SetHandleToReturn(); var docRm = new DocumentDescriptorReadModel(1L, new DocumentDescriptorId(1), new BlobId("file_1")); var rev1 = new DocumentHandle("rev_1"); docRm.AddHandle(rev1); rmDocuments.Add(docRm); var attachHandle = new DocumentHandle("rev_2"); var docRmAttach = new DocumentDescriptorReadModel(1L, new DocumentDescriptorId(1), new BlobId("file_2")); docRmAttach.AddHandle(attachHandle); rmDocuments.Add(docRmAttach); CreateSut(); var evt = new DocumentDescriptorHasNewAttachment(attachHandle, "path.txt").AssignIdForTest(new DocumentId(1)); _sut.Handle(evt, false); //Handle is linked to document. Assert.That(rmStream, Has.Count.EqualTo(1)); Assert.That(rmStream[0].EventType, Is.EqualTo(HandleStreamEventTypes.DocumentHasNewAttachment)); Assert.That(rmStream[0].EventData[StreamReadModelEventDataKeys.ChildHandle], Is.EqualTo(attachHandle)); }
public void verify_stream_events_have_documentId() { SetHandleToReturn(); var docRm = new DocumentDescriptorReadModel(1L, new DocumentDescriptorId(1), new BlobId("blob_test")); docRm.Created = true; docRm.AddHandle(new DocumentHandle("rev_1")); rmDocuments.Add(docRm); CreateSut(); var evt = new DocumentLinked(new DocumentHandle("rev_1"), new DocumentDescriptorId(1), new DocumentDescriptorId(2), new FileNameWithExtension("test.txt")); _sut.Handle(evt, false); //Handle is linked to document. Assert.That(rmStream, Has.Count.EqualTo(1)); Assert.That(rmStream[0].DocumentDescriptorId, Is.EqualTo(new DocumentDescriptorId(1))); }