示例#1
0
        public async Task SendAddsAutomationActions()
        {
            using var http   = new HttpClient();
            using var jtc    = new JoinableTaskContext();
            using var events = new EventGridStream(
                      Mock.Of <IServiceProvider>(),
                      environment,
                      new Serializer(),
                      jtc.Factory);

            var people       = new TestPersonRepository();
            var phoneSystems = new TestEntityRepository <PhoneSystem>();
            var phoneThreads = new TestEntityRepository <PhoneThread>();
            var slackHandler = new SlackMessageSentHandler(environment, phoneThreads, http);

            await phoneSystems.PutAsync(new PhoneSystem(Constants.Donee.PhoneNumber, Constants.System.PhoneNumber)
            {
                AutomationPaused = true
            });

            var handler = new SlackEventHandler(environment, people, phoneSystems, events,
                                                Mock.Of <ILanguageUnderstanding>(x => x.PredictAsync(It.IsAny <string>()) ==
                                                                                 Task.FromResult(new Prediction(Intents.Help, new Dictionary <string, Intent>
            {
                { Intents.Help, new Intent {
                      Score = 0.55
                  } },
                { Intents.Donate, new Intent {
                      Score = 0.25
                  } },
            }, new Dictionary <string, object>(), default, default))));
示例#2
0
        public async Task WhenHandlingDonorRegistered_ThenNoOp()
        {
            var repo    = new TestEntityRepository <TaxStatusValidation>();
            var handler = new TaxStatusValidationHandler(
                Mock.Of <ITaxIdRecognizer>(),
                new Mock <IPersonRepository>(MockBehavior.Strict).Object,
                repo);

            await handler.HandleAsync(Constants.Donor.Create().Events.OfType <PersonRegistered>().First());
        }
示例#3
0
        public async Task WhenHandlingDoneeRegistered_ThenCreatesValidation()
        {
            var donee   = Constants.Donee.Create();
            var repo    = new TestEntityRepository <TaxStatusValidation>();
            var handler = new TaxStatusValidationHandler(
                Mock.Of <ITaxIdRecognizer>(),
                Mock.Of <IPersonRepository>(x =>
                                            x.GetAsync <Donee>(donee.PersonId, false) == Task.FromResult(donee)),
                repo);

            await handler.HandleAsync(Constants.Donee.Create().Events.OfType <PersonRegistered>().First());

            Assert.NotNull(await repo.GetAsync(Constants.Donee.Id));
        }