public async Task WithInitDialog_InitNotExecuted()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("Init executed: False")
                        .DialogDone();

            await this.Play(story);
        }
Ejemplo n.º 2
0
        public async Task SingleIntentStory_PlayStoryIsCalled_DialogFlowIsCorrect()
        {
            var story = StoryRecorder
                        .Record()
                        .User.Says("Play intent 1")
                        .Bot.Says("Intent 1")
                        .Rewind();

            await this.Play(story);
        }
Ejemplo n.º 3
0
        public async Task PartialStory_PlayStoryIsCalled_DialogFlowIsCorrect()
        {
            var story = StoryRecorder
                        .Record()
                        .User.Says("hi")
                        .Bot.Says("You said: hi")
                        .Rewind();

            await this.Play(story);
        }
        public async Task PartialStoryWithDialogDoneCheck_PlayStoryIsCalled_AssertTrueThrown()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("Hi")
                        .User.Says("Hi")
                        .Bot.Says("How are you?")
                        .DialogDone();

            await this.ThrowsTrueException(story, NotEqualDialogStatusMessagePattern);
        }
Ejemplo n.º 5
0
        public async Task LuisDialog_KnownResponse_IntentReturned(string input)
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("What would you do now?")
                        .User.Says(input)
                        .Bot.Says("Returned intent: Everything")
                        .DialogDone();

            await this.Play(story);
        }
        public async Task DialogWithChoice_UserRespondSomethingElse_BotTellsToAnswerTheQuestion()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.GivesChoice("Choose one of the options", new[] { "First", "Second", "Third" })
                        .User.Says("Fourth")
                        .Bot.GivesChoice("Choose one of the options", new[] { "First", "Second", "Third" })
                        .Rewind();

            await this.Play(story);
        }
        public async Task DialogWithChoice_UserSelectsAny_BotSaysWhatYouChose(string input)
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.GivesChoice("Choose one of the options", new[] { "First", "Second", "Third" })
                        .User.Says(input)
                        .Bot.Says("You chose " + input)
                        .Rewind();

            await this.Play(story);
        }
Ejemplo n.º 8
0
        public async Task DialogWithConfirm_UserSelectsNo_BotSaysYouSaidNo()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Confirms("Are you sure you want to continue?")
                        .User.Says("No")
                        .Bot.Says("You said no")
                        .Rewind();

            await this.Play(story);
        }
Ejemplo n.º 9
0
        public async Task LuisDialog_NegativeResponse_NoReturned(string input)
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("What would you do now?")
                        .User.Says(input)
                        .Bot.Says("Returned: No")
                        .DialogDone();

            await this.Play(story);
        }
        public async Task StoryWithNotCoveredPerformanceStep_PlayStoryIsCalled_TrueExceptionThrown()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("Hi")
                        .User.Says("Hi")
                        .Rewind();

            var stepNotCoveredPattern = string.Format(CultureInfo.InvariantCulture, PerformanceStepNotCoveredPattern, 2);

            await this.ThrowsTrueException(story, stepNotCoveredPattern);
        }
        public async Task FullStory_PlayStoryIsCalled_DialogFlowIsCorrect()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("Hi")
                        .User.Says("Hi")
                        .Bot.Says("How are you?")
                        .User.Says("I'm fine!")
                        .DialogDone();

            await this.Play(story);
        }
Ejemplo n.º 12
0
        public async Task FullStory_PlayStoryIsCalled_DialogFlowIsCorrect()
        {
            var story = StoryRecorder
                        .Record()
                        .User.Says("hi")
                        .Bot.Says("You said: hi")
                        .User.Says("hello")
                        .Bot.Says("You said: hello")
                        .DialogDone();

            await this.Play(story);
        }
        public async Task TestWithResultPredicate_PlayStoryIsCalled_AssertTrueThrown()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("Hi")
                        .User.Says("Hi")
                        .Bot.Says("How are you?")
                        .User.Says("I'm good.")
                        .DialogDoneWithResult(result => (bool)result == true);

            await this.ThrowsTrueException(story, ResultEmptyMessage);
        }
        public async Task WrongResultExpected_PlayStoryIsCalled_TrueExceptionExpected()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("Type first number:")
                        .User.Says("2")
                        .Bot.Says("Type second number:")
                        .User.Says("2")
                        .DialogDoneWithResult(result => (int)result == 5);

            await this.ThrowsTrueException(story, NotEqualDialogResultMessagePattern);
        }
        public async Task WrongTypeOfResultExpected_PlayStoryIsCalled_TrueExceptionExpected()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("Type first number:")
                        .User.Says("2")
                        .Bot.Says("Type second number:")
                        .User.Says("2")
                        .DialogDoneWithResult(result => (string)result == string.Empty);

            await this.ThrowsTrueException(story, WrongDialogResultTypeMessagePattern);
        }
        public async Task Sum40With60_PlayStoryIsCalled_IntDialogResultIsEqualTo100()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("Type first number:")
                        .User.Says("40")
                        .Bot.Says("Type second number:")
                        .User.Says("60")
                        .DialogDoneWithResult <int>(result => result >= 100);

            await this.Play(story);
        }
        public async Task Sum40WithNaN_PlayStoryIsCalled_DialogFailedWithFormatExceptionExpected()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("Type first number:")
                        .User.Says("40")
                        .Bot.Says("Type second number:")
                        .User.Says("NaN")
                        .DialogFailedWithExceptionOfType <FormatException>();

            await this.Play(story);
        }
        public async Task DialogFailedWithWronglyExpectedExceptionType_PlayStoryIsCalled_TrueExceptionExpected()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("Type first number:")
                        .User.Says("40")
                        .Bot.Says("Type second number:")
                        .User.Says("NaN")
                        .DialogFailedWithExceptionOfType <ArgumentNullException>();

            await this.ThrowsTrueException(story, WrongExceptionTypeMessagePattern);
        }
Ejemplo n.º 19
0
        public async Task StoryWithWrongInitialActor_PlayStoryIsCalled_EqualExceptionThrown()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("hi")
                        .User.Says("hi")
                        .Rewind();

            await Assert.ThrowsAsync <TrueException>(async() =>
            {
                await this.Play(story);
            });
        }
        public async Task SingleFruitStory_PlayStoryIsCalled_DialogFlowIsCorrect()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("Which fruit you take?")
                        .Bot.ListsOptionsIncluding("Banana", "Apple", "Orange")
                        .User.Says("Apple")
                        .Bot.Says("Your choice: Apple")
                        .Bot.Says("Which fruit you take now?")
                        .Rewind();

            await this.Play(story);
        }
Ejemplo n.º 21
0
        public async Task LuisDialog_UnexpectedResponseOnce_AcceptsSecondResponse()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("What would you do now?")
                        .User.Says("I don't know")
                        .Bot.Says("I didn't understand. Say something in reply.\r\nWhat would you do now?")
                        .User.Says("Yes")
                        .Bot.Says("Returned: Yes")
                        .DialogDone();

            await this.Play(story);
        }
        public async Task StoryWithWrongInitialActor_PlayStoryIsCalled_TrueExceptionThrown()
        {
            var story = StoryRecorder
                        .Record()
                        .User.Says("Hi")
                        .Bot.Says("Hi")
                        .Bot.Says("How are you?")
                        .Rewind();

            var notMatchingActorsPattern = string.Format(CultureInfo.InvariantCulture, NotMatchingActorsPattern, 0);

            await this.ThrowsTrueException(story, notMatchingActorsPattern);
        }
Ejemplo n.º 23
0
        public async Task LuisDialog_UnexpectedResponseTwice_TooManyAttemptsReturned()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("What would you do now?")
                        .User.Says("I don't know")
                        .Bot.Says("I didn't understand. Say something in reply.\r\nWhat would you do now?")
                        .User.Says("I don't know")
                        .Bot.Says("I have no idea what you meant")
                        .Bot.Says("Returned: TooManyAttempts")
                        .DialogDone();

            await this.Play(story);
        }
        public async Task ExpectStringDialogResult_PlayStoryIsCalled_FormatExceptionThrown()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("Type first number:")
                        .User.Says("40")
                        .Bot.Says("Type second number:")
                        .User.Says("60")
                        .DialogDoneWithResult <string>(string.IsNullOrEmpty);

            await Assert.ThrowsAsync <FormatException>(async() =>
            {
                await this.Play(story);
            });
        }
        public async Task WithInitDialog_InitExecuted()
        {
            var story = StoryRecorder
                        .Record()
                        .Bot.Says("Init executed: True")
                        .DialogDone();

            this.RegisterDialog(x =>
            {
                var dialog = new WithInitDialog();
                dialog.Init();
                return(dialog);
            });

            await this.Play(story);
        }
        private List <StoryStep <IMessageActivity> > GetStorySteps(IStory <IMessageActivity> testStory)
        {
            var wrapperStory = StoryRecorder.Record()
                               .User.Says(Constants.WrapperStartMessage)
                               .Bot.Says(Constants.WrapperStartMessage)
                               .Rewind();

            var wrappedStory = testStory.Concat(wrapperStory);

            return(wrappedStory.StoryFrames.Select((storyFrame, stepIndex) =>
                                                   new StoryStep <IMessageActivity>(storyFrame, isDialogResultCheckupStep: storyFrame is DialogStoryFrame <IMessageActivity>)
            {
                Status = StoryPlayerStepStatus.NotDone,
                StepIndex = stepIndex,
            })
                   .ToList());
        }
Ejemplo n.º 27
0
        private List <StoryStep> GetStorySteps(IStory testStory)
        {
            var wrapperStory = StoryRecorder.Record()
                               .User.Says(Consts.WrapperStartMessage)
                               .Bot.Says(Consts.WrapperStartMessage)
                               .Rewind();

            var wrappedStory = testStory.Concat(wrapperStory);

            return(wrappedStory.StoryFrames.Select((storyFrame, stepIndex) =>
                                                   new StoryStep(storyFrame)
            {
                Status = StoryPlayerStepStatus.NotDone,
                StepIndex = stepIndex
            })
                   .ToList());
        }
Ejemplo n.º 28
0
        public async void Test0()
        {
            var story = StoryRecorder.Record()
                        .User.Says("Hello")
                        .Bot.Says("Hi what's your name?")
                        .User.Says("Adrian")
                        .Bot.Says("Hi Adrian")
                        .Bot.Says("How old are you Adrian?")
                        .User.Says("123")
                        .Bot.Says("You are 123 years old.")
                        .Bot.Says("Are you a .NET Developer?")
                        .User.Says("Yes")
                        .Bot.Says("You are.NET Developer")
                        .Rewind();

            await this.Play(story);
        }