public void ThenResolverGetsDefaultService()
            {
                // Arrange
                var pmode = new SendingProcessingMode();

                // Act
                AS4.Model.Core.Service service = SendingPModeMap.ResolveService(pmode);

                // Assert
                Assert.Equal(AS4.Model.Core.Service.TestService, service);
            }
            public void ThenResolverGetService()
            {
                // Arrange
                SendingProcessingMode pmode = CreateDefaultSendingPMode();

                // Act
                AS4.Model.Core.Service actual = SendingPModeMap.ResolveService(pmode);

                // Assert
                var expected = pmode.MessagePackaging.CollaborationInfo.Service;
                Assert.Equal(expected.Value, actual.Value);
                Assert.Equal(Maybe.Just(expected.Type), actual.Type);
            }
예제 #3
0
        private static Service ResolveService(SubmitMessage submit, SendingProcessingMode sendingPMode)
        {
            var pmodeService  = sendingPMode?.MessagePackaging?.CollaborationInfo?.Service;
            var submitService = submit?.Collaboration?.Service;

            if (sendingPMode?.AllowOverride == false &&
                !String.IsNullOrEmpty(submitService?.Value) &&
                !String.IsNullOrEmpty(pmodeService?.Value) &&
                !StringComparer.OrdinalIgnoreCase.Equals(submitService.Value, pmodeService.Value))
            {
                throw new NotSupportedException(
                          $"SubmitMessage is not allowed by SendingPMode {sendingPMode.Id} to override CollaborationInfo.Service");
            }

            if (submitService?.Value != null)
            {
                return(new Service(submitService.Value, submitService.Type));
            }

            return(SendingPModeMap.ResolveService(sendingPMode));
        }