Beispiel #1
0
        public async Task Send_command_to_parse_valid_cif_should_publish_one_RecordParsed_and_one_FileParsed_event([Frozen] FileParsedEvent expectedEvent)
        {
            try
            {
                await _harness.Start();

                var blobId = await _blobStorage.AddFileAsync("1100110.cif", Resource._1100110, "chemical/x-cif", BUCKET);

                await _harness.InputQueueSendEndpoint.Send <ParseFile>(new
                {
                    expectedEvent.Id,
                    Bucket = BUCKET,
                    BlobId = blobId,
                    expectedEvent.CorrelationId,
                    expectedEvent.UserId
                });

                _consumer.Consumed.Select <ParseFile>().Any();
                _harness.Published.Select <FileParsed>().Any();

                var allEvents = _harness.Published.ToList();

                var parsed = allEvents.Select <RecordParsed>().FirstOrDefault();
                parsed.Should().NotBeNull();
                parsed.ShouldBeEquivalentTo(new
                {
                    FileId = expectedEvent.Id,
                    Bucket = BUCKET,
                    Index  = 0L,
                    expectedEvent.UserId
                },
                                            options => options.ExcludingMissingMembers()
                                            );
                parsed.Fields.Count().Should().Be(22);
            }
            finally
            {
                await _harness.Stop();
            }
        }
Beispiel #2
0
        public async Task Send_command_to_parse_empty_cif_should_publish_one_RecordParsed_and_one_FileParsed_event([Frozen] FileParsedEvent expectedEvent)
        {
            try
            {
                await _harness.Start();

                var blobId = await _blobStorage.AddFileAsync("empty.cif", Resource.empty, "chemical/x-cif", BUCKET);

                await _harness.InputQueueSendEndpoint.Send <ParseFile>(new
                {
                    expectedEvent.Id,
                    Bucket = BUCKET,
                    BlobId = blobId,
                    expectedEvent.CorrelationId,
                    expectedEvent.UserId
                });

                var res = _consumer.Consumed.Select <ParseFile>().Any();

                await _harness.Published.Any <FileParsed>();

                var allEvents = _harness.Published.ToList();

                var parsed = allEvents.Select <FileParsed>().FirstOrDefault();
                parsed.Should().NotBeNull();
                parsed.ShouldBeEquivalentTo(expectedEvent,
                                            options => options
                                            .Excluding(p => p.TimeStamp)
                                            .Excluding(p => p.TotalRecords)
                                            .Excluding(p => p.Fields)
                                            );
            }
            finally
            {
                await _harness.Stop();
            }
        }