예제 #1
0
        private static async Task <StepResult> ExerciseDynamicDiscovery(SendingProcessingMode pmode)
        {
            var step = new DynamicDiscoveryStep();

            return(await step.ExecuteAsync(
                       new MessagingContext(new SubmitMessage()) { SendingPMode = pmode }));
        }
예제 #2
0
        public Property Resolve_Only_ToParty_From_AS4Message_If_UserMessage(
            MessagingContextMode contextMode,
            Maybe <SignalMessage> signalM)
        {
            return(Prop.ForAll(
                       GenAS4Party().ToArbitrary(),
                       receiver =>
            {
                var user = new UserMessage(
                    $"user-{Guid.NewGuid()}",
                    AS4Party.DefaultFrom,
                    receiver);

                AS4Message message =
                    signalM.Select(s => AS4Message.Create(new MessageUnit[] { s, user }))
                    .GetOrElse(AS4Message.Create(user));

                var context = new MessagingContext(message, contextMode)
                {
                    SendingPMode = new SendingProcessingMode
                    {
                        DynamicDiscovery = new DynamicDiscoveryConfiguration()
                    }
                };

                var act = new Lazy <bool>(() =>
                {
                    var spy = new SpyToPartyDynamicDiscoveryProfile();
                    var sut = new DynamicDiscoveryStep(_ => spy);
                    sut.ExecuteAsync(context)
                    .GetAwaiter()
                    .GetResult();

                    return spy.ToParty
                    .Equals(receiver)
                    .Equals(contextMode == MessagingContextMode.Forward &&
                            context.AS4Message.IsUserMessage);
                });

                return Prop.throws <InvalidOperationException, bool>(act)
                .Label($"Throws {nameof(InvalidOperationException)}")
                .Or(() => act.Value)
                .Label("Resolved ToParty is UserMessge.ToParty");
            }));
        }
예제 #3
0
        private static (bool, AS4Party) ExerciseDynamicDiscovery(
            SubmitParty submitParty,
            PModeParty pmodeParty,
            bool allowOverride)
        {
            var context = new MessagingContext(
                new SubmitMessage
            {
                PartyInfo = { ToParty = submitParty }
            })
            {
                SendingPMode = new SendingProcessingMode
                {
                    AllowOverride    = allowOverride,
                    DynamicDiscovery = new DynamicDiscoveryConfiguration(),
                    MessagePackaging = { PartyInfo   = new PartyInfo {
                                             ToParty = pmodeParty
                                         } }
                }
            };

            try
            {
                var spy = new SpyToPartyDynamicDiscoveryProfile();
                var sut = new DynamicDiscoveryStep(_ => spy);
                sut.ExecuteAsync(context)
                .GetAwaiter()
                .GetResult();

                return(true, spy.ToParty);
            }
            catch
            {
                return(false, null);
            }
        }