Exemple #1
0
        public ContextBaseTests()
        {
            var documentTypeResolver = new DocumentTypeResolver().WithMessagingDocuments();

            ArtificialIntelligenceExtension = Substitute.For <IArtificialIntelligenceExtension>();
            ContactExtension           = Substitute.For <IContactExtension>();
            TunnelExtension            = Substitute.For <ITunnelExtension>();
            Logger                     = Substitute.For <ILogger>();
            Configuration              = Substitute.For <IConfiguration>();
            CacheOwnerCallerContactMap = new CacheOwnerCallerContactMap();
            Sender                     = Substitute.For <ISender>();
            Flow = new Flow()
            {
                Id            = "0",
                Configuration = new Dictionary <string, string>()
            };
            User        = "******";
            Application = "*****@*****.**";
            Input       = new LazyInput(
                new Message()
            {
                From    = User.ToNode(),
                To      = Application.ToNode(),
                Content = new PlainText()
                {
                    Text = "Hello world!"
                }
            },
                Flow.BuilderConfiguration,
                new DocumentSerializer(documentTypeResolver),
                new EnvelopeSerializer(documentTypeResolver),
                ArtificialIntelligenceExtension,
                CancellationToken);
            Configuration.ContactCacheExpiration.Returns(TimeSpan.FromMinutes(5));
        }
Exemple #2
0
        public ContactVariableProviderTests()
        {
            ContactExtension    = Substitute.For <IContactExtension>();
            Context             = Substitute.For <IContext>();
            Logger              = Substitute.For <ILogger>();
            Configuration       = Substitute.For <IConfiguration>();
            ApplicationSettings = Substitute.For <Application>();
            var cacheOwnerCallerContactMap = new CacheOwnerCallerContactMap();

            CacheContactExtensionDecorator = new CacheContactExtensionDecorator(ContactExtension, cacheOwnerCallerContactMap, Logger, Configuration, ApplicationSettings);
            InputContext = new Dictionary <string, object>();
            Context.InputContext.Returns(InputContext);
            Contact = new Contact()
            {
                Identity = "*****@*****.**",
                Name     = "John Doe",
                Address  = "184 Alpha Avenue"
            };
            ContactExtension.GetAsync(Contact.Identity, CancellationToken).Returns(Contact);
            Context.UserIdentity.Returns(Contact.Identity);
            Context.OwnerIdentity.Returns(new Identity("application", "domain.com"));
            Configuration.ContactCacheExpiration.Returns(TimeSpan.FromMinutes(5));
            ApplicationSettings.Identifier = "application";
            ApplicationSettings.Domain     = "domain.com";
        }
Exemple #3
0
        public FlowManagerTestsBase()
        {
            BucketExtension = Substitute.For <IBucketExtension>();
            ArtificialIntelligenceExtension = Substitute.For <IArtificialIntelligenceExtension>();
            EventTrackExtension             = Substitute.For <IEventTrackExtension>();
            BroadcastExtension = Substitute.For <IBroadcastExtension>();
            ContactExtension   = Substitute.For <IContactExtension>();
            Sender             = Substitute.For <ISender>();
            StateManager       = Substitute.For <IStateManager>();
            ContextProvider    = Substitute.For <IContextProvider>();
            Context            = Substitute.For <IContext>();
            Logger             = new LoggerConfiguration().CreateLogger();
            ContextProvider
            .CreateContext(Arg.Any <Identity>(), Arg.Any <Identity>(), Arg.Any <LazyInput>(), Arg.Any <Flow>())
            .Returns(Context);
            UserIdentity        = new Identity("user", "domain");
            ApplicationIdentity = new Identity("application", "domain");
            Application         = new Application()
            {
                Identifier = ApplicationIdentity.Name,
                Domain     = ApplicationIdentity.Domain
            };
            Message = new Message()
            {
                From = UserIdentity.ToNode(),
                To   = ApplicationIdentity.ToNode()
            };
            Context.UserIdentity.Returns(UserIdentity);
            Input = new LazyInput(
                Message,
                new BuilderConfiguration(),
                Substitute.For <IDocumentSerializer>(),
                Substitute.For <IEnvelopeSerializer>(),
                ArtificialIntelligenceExtension,
                CancellationToken);
            Context.Input.Returns(Input);

            TraceProcessor             = Substitute.For <ITraceProcessor>();
            CacheOwnerCallerContactMap = new CacheOwnerCallerContactMap();
            UserOwnerResolver          = Substitute.For <IUserOwnerResolver>();
            UserOwnerResolver
            .GetUserOwnerIdentitiesAsync(Arg.Any <Message>(), Arg.Any <BuilderConfiguration>(), Arg.Any <CancellationToken>())
            .Returns(new UserOwner(UserIdentity, ApplicationIdentity));
        }