public async Task GivenAConvertDataRequest_WithConfiguredTemplate_WhenValidBodySent_ThenConvertDataCalledWithCorrectParams(string loginServer, string imageName, string digest, string templateCollectionReference) { _mediator.Send(Arg.Any <ConvertDataRequest>()).Returns(Task.FromResult(GetConvertDataResponse())); var ociArtifactInfo = new OciArtifactInfo { LoginServer = loginServer, ImageName = imageName, Digest = digest, }; var artifactConfig = new ArtifactStoreConfiguration(); artifactConfig.OciArtifacts.Add(ociArtifactInfo); var localController = GetController(_convertDataJobConfig, artifactConfig); var body = GetConvertDataParams(Samples.SampleHl7v2Message, "Hl7v2", templateCollectionReference, _testHl7v2RootTemplate); await localController.ConvertData(body); await _mediator.Received().Send( Arg.Is <ConvertDataRequest>( r => r.InputData.ToString().Equals(body.Parameter.Find(p => p.Name.Equals(ConvertDataProperties.InputData)).Value.ToString()) && string.Equals(r.InputDataType.ToString(), body.Parameter.Find(p => p.Name.Equals(ConvertDataProperties.InputDataType)).Value.ToString(), StringComparison.OrdinalIgnoreCase) && r.TemplateCollectionReference == body.Parameter.Find(p => p.Name.Equals(ConvertDataProperties.TemplateCollectionReference)).Value.ToString() && r.RootTemplate == body.Parameter.Find(p => p.Name.Equals(ConvertDataProperties.RootTemplate)).Value.ToString()), Arg.Any <CancellationToken>()); _mediator.ClearReceivedCalls(); }
public ConvertDataController( IMediator mediator, IOptions <OperationsConfiguration> operationsConfig, IOptions <ArtifactStoreConfiguration> artifactStoreConfig, ILogger <ConvertDataController> logger) { EnsureArg.IsNotNull(mediator, nameof(mediator)); EnsureArg.IsNotNull(operationsConfig?.Value?.ConvertData, nameof(operationsConfig)); EnsureArg.IsNotNull(artifactStoreConfig?.Value, nameof(artifactStoreConfig)); EnsureArg.IsNotNull(logger, nameof(logger)); _mediator = mediator; _config = operationsConfig.Value.ConvertData; _artifactStoreConfig = artifactStoreConfig.Value; _logger = logger; }
public async Task GivenAConvertDataRequest_WithNotConfiguredTemplate_WhenValidBodySent_ThenTemplateNotConfiguredThrown(string loginServer, string imageName, string digest, string templateCollectionReference) { var ociArtifactInfo = new OciArtifactInfo { LoginServer = loginServer, ImageName = imageName, Digest = digest, }; var artifactConfig = new ArtifactStoreConfiguration(); artifactConfig.OciArtifacts.Add(ociArtifactInfo); var localController = GetController(_convertDataJobConfig, artifactConfig); var body = GetConvertDataParams(Samples.SampleHl7v2Message, "Hl7v2", templateCollectionReference, _testHl7v2RootTemplate); await Assert.ThrowsAsync <ContainerRegistryNotConfiguredException>(() => localController.ConvertData(body)); }
private ConvertDataController GetController( ConvertDataConfiguration convertDataConfiguration, ArtifactStoreConfiguration artifactStoreConfiguration) { var operationConfig = new OperationsConfiguration() { ConvertData = convertDataConfiguration, }; IOptions <OperationsConfiguration> optionsOperationConfiguration = Substitute.For <IOptions <OperationsConfiguration> >(); optionsOperationConfiguration.Value.Returns(operationConfig); IOptions <ArtifactStoreConfiguration> optionsArtifactStoreConfiguration = Substitute.For <IOptions <ArtifactStoreConfiguration> >(); optionsArtifactStoreConfiguration.Value.Returns(artifactStoreConfiguration); return(new ConvertDataController( _mediator, optionsOperationConfiguration, optionsArtifactStoreConfiguration, NullLogger <ConvertDataController> .Instance)); }