Esempio n. 1
0
    public async Task OnEnterAsyncShouldRaiseEvent(MoodType moodType, string personName, string protagonist)
    {
        var isProtagonist = personName == protagonist;

        var context = A.Dummy <INavigationContext>();

        context.State.PersonName      = personName;
        context.State.ProtagonistName = protagonist;
        context.State.MoodType        = null;

        var invoker = new TestInvoker(context);

        var sut = new MoodNode(moodType);

        var ret = await sut.EnterAsync(context);

        ret.Should().BeNull();

        invoker.ShouldContainSingle <IMoodChangeEvent>(
            i => i.Should().BeEquivalentTo(new
        {
            MoodType      = moodType,
            PersonName    = personName,
            IsProtagonist = isProtagonist
        })
            );
    }
Esempio n. 2
0
    public async Task OnEnterShouldUpdateState(MoodType moodType)
    {
        var context = A.Dummy <INavigationContext>();

        context.State.MoodType = null;

        var sut = new MoodNode(moodType);

        await sut.EnterAsync(context);

        context.State.MoodType.Should().Be(moodType);
    }
Esempio n. 3
0
    public async Task ShouldNotRaiseEventForNomalMoodWhenContextMoodIsNull()
    {
        var context = A.Dummy <INavigationContext>();

        context.State.MoodType = null;

        var invoker = new TestInvoker(context);

        var sut = new MoodNode(MoodType.Normal);

        var ret = await sut.EnterAsync(context);

        ret.Should().BeNull();

        invoker.Count.Should().Be(0);
    }
Esempio n. 4
0
    public async Task OnEnterShouldNotRaiseEventIfMoodWasNotChanged()
    {
        var context = A.Dummy <INavigationContext>();

        context.State.MoodType = MoodType.Happy;

        var invoker = new TestInvoker(context);

        var sut = new MoodNode(MoodType.Happy);

        var ret = await sut.EnterAsync(context);

        ret.Should().Be(MoodType.Happy);

        invoker.Count.Should().Be(0);
    }
Esempio n. 5
0
    public async Task OnEnterShouldReturnPreviousMood()
    {
        var context = A.Dummy <INavigationContext>();

        context.State.MoodType   = MoodType.Surprised;
        context.State.PersonName = "abc";

        var invoker = new TestInvoker(context);

        var sut = new MoodNode(MoodType.Happy);
        var ret = await sut.EnterAsync(context);

        ret.Should().Be(MoodType.Surprised);

        invoker.ShouldContainSingle <IMoodChangeEvent>(
            i => i.Should().BeEquivalentTo(new
        {
            MoodType      = MoodType.Happy,
            PersonName    = "abc",
            IsProtagonist = false
        })
            );
    }
Esempio n. 6
0
    public async Task ShouldRaiseEventWithStateArg(MoodType moodType)
    {
        var context = A.Dummy <INavigationContext>();

        context.State.PersonName      = "alpha";
        context.State.ProtagonistName = "alpha";
        context.State.MoodType        = MoodType.Happy;

        var invoker = new TestInvoker(context);

        var sut = new MoodNode(MoodType.Happy);

        await sut.EnterAsync(context, moodType);

        invoker.ShouldContainSingle <IMoodChangeEvent>(
            i => i.Should().BeEquivalentTo(new
        {
            MoodType      = moodType,
            PersonName    = "alpha",
            IsProtagonist = true
        })
            );
    }