Beispiel #1
0
        public async Task Send_command_to_standardize_invalid_mol_should_publish_one_StandardizationFailed_event([Frozen] ValidatedEvent expectedEvent)
        {
            try
            {
                await _fixture.Harness.Start();

                var blobId = await _fixture.BlobStorage.AddFileAsync("1oir_canon_trash_modified.mol", Resource._1oir_canon_trash_modified, "chemical/x-mdl-molfile", BUCKET);

                await _fixture.Harness.Bus.Publish <Standardize>(new
                {
                    Id            = expectedEvent.Id,
                    Bucket        = BUCKET,
                    BlobId        = blobId,
                    CorrelationId = expectedEvent.CorrelationId,
                    UserId        = expectedEvent.UserId
                });

                await _fixture.Harness.Published.Any <StandardizationFailed>();

                var allEvents = _fixture.Harness.Published.ToList();

                var failed = allEvents.Select <StandardizationFailed>().FirstOrDefault();
                failed.Should().NotBeNull();
                failed.ShouldBeEquivalentTo(expectedEvent,
                                            options => options
                                            .Excluding(p => p.TimeStamp)
                                            .Excluding(p => p.Message)
                                            );
                failed.Message.Should().StartWith($"Blob with id {blobId} from bucket {BUCKET} can not be standardized or not found. Error:");
            }
            finally
            {
                await _fixture.Harness.Stop();
            }
        }
Beispiel #2
0
        public async Task Send_command_to_standardize_nonexistent_mol_should_publish_one_StandardizationFailed_event([Frozen] ValidatedEvent expectedEvent)
        {
            try
            {
                await _fixture.Harness.Start();

                var blobId = NewId.NextGuid();

                await _fixture.Harness.Bus.Publish <Standardize>(new
                {
                    Id            = expectedEvent.Id,
                    Bucket        = BUCKET,
                    BlobId        = blobId,
                    CorrelationId = expectedEvent.CorrelationId,
                    UserId        = expectedEvent.UserId
                });

                await _fixture.Harness.Published.Any <StandardizationFailed>();

                var allEvents = _fixture.Harness.Published.ToList();

                var failed = allEvents.Select <StandardizationFailed>().FirstOrDefault();
                failed.Should().NotBeNull();
                failed.ShouldBeEquivalentTo(expectedEvent,
                                            options => options
                                            .Excluding(p => p.TimeStamp)
                                            .Excluding(p => p.Message)
                                            );
                failed.Message.Should().StartWith($"Blob with id {blobId} from bucket {BUCKET} can not be standardized or not found. Error:");
            }
            finally
            {
                await _fixture.Harness.Stop();
            }
        }
Beispiel #3
0
        public async Task Send_command_to_standardize_valid_mol_should_publish_one_Standardized_event([Frozen] ValidatedEvent expectedEvent)
        {
            try
            {
                await _fixture.Harness.Start();

                var blobId = await _fixture.BlobStorage.AddFileAsync("1oir_canon.mol", Resource._1oir_canon, "chemical/x-mdl-molfile", BUCKET);

                await _fixture.Harness.Bus.Publish <Standardize>(new
                {
                    Id            = expectedEvent.Id,
                    Bucket        = BUCKET,
                    BlobId        = blobId,
                    CorrelationId = expectedEvent.CorrelationId,
                    UserId        = expectedEvent.UserId
                });

                await _fixture.Harness.Published.Any <Standardized>();

                var allEvents = _fixture.Harness.Published.ToList();

                var standardized = allEvents.Select <Standardized>().FirstOrDefault();
                standardized.Should().NotBeNull();
                standardized.ShouldBeEquivalentTo(expectedEvent,
                                                  options => options
                                                  .Excluding(p => p.TimeStamp)
                                                  .Excluding(p => p.Record)
                                                  );
                standardized.Record.Issues.Count().Should().Be(0);
            }
            finally
            {
                await _fixture.Harness.Stop();
            }
        }
Beispiel #4
0
        public async Task Send_command_to_validate_trash_mol_should_publish_one_Validated_event([Frozen] ValidatedEvent expectedEvent)
        {
            try
            {
                await _fixture.Harness.Start();

                var blobId = await _fixture.BlobStorage.AddFileAsync("1oir_canon_trash_modified.mol", Resource._1oir_canon_trash_modified, "chemical/x-mdl-molfile", BUCKET);

                await _fixture.Harness.Bus.Publish <Validate>(new
                {
                    Id            = expectedEvent.Id,
                    Bucket        = BUCKET,
                    BlobId        = blobId,
                    CorrelationId = expectedEvent.CorrelationId,
                    UserId        = expectedEvent.UserId
                });

                await _fixture.Harness.Published.Any <Validated>();

                var allEvents = _fixture.Harness.Published.ToList();

                var validated = allEvents.Select <Validated>().FirstOrDefault();
                validated.Should().NotBeNull();
                validated.ShouldBeEquivalentTo(expectedEvent,
                                               options => options
                                               .Excluding(p => p.TimeStamp)
                                               .Excluding(p => p.Record)
                                               );
                validated.Record.Issues.Count().Should().Be(2);
                validated.Record.Issues.Where(i => i.Severity == Domain.Models.Severity.Error).Count().Should().Be(1);
            }
            finally
            {
                await _fixture.Harness.Stop();
            }
        }