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 }) ); }
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); }
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); }
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); }
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 }) ); }
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 }) ); }