public void Execute_WithThenActionWithError_ShouldCallOnNext( [Frozen(Matching.ImplementedInterfaces)] TestObserver <ActionNotification> observer, [Frozen] DateTimeOffset date, [Frozen] IMeasureDuration measureDuration, ReportingActor sut, ThenAction <object, string> thenAction, Exception error, TimeSpan expectedDuration ) { //arrange Mock.Get(measureDuration).Setup(m => m.Measure(It.IsAny <Func <string> >())) .Returns((expectedDuration, null, error)); //act try { sut.Execute(thenAction); } catch (Exception) { } //assert var expected = new[] { new ActionNotification(thenAction, 1, new BeforeThenNotificationContent(date, thenAction.Question)), new ActionNotification(thenAction, 1, new AfterThenNotificationContent(expectedDuration, ThenOutcome.Error, error)) }; observer.Values.Should().BeEquivalentTo(expected, o => o.RespectingRuntimeTypes().ComparingByMembers <ActionNotification>()); }
public void Name_ShouldReturnCorrectValue( ThenAction <object> sut) { // arrange // act var actual = sut.Name; // assert actual.Should().EndWith(sut.Question.Name); }
public void Execute_WithThenActionWithAssertionError_ShouldCallOnNext( int i, [Frozen(Matching.ImplementedInterfaces)] TestObserver <ActionNotification> observer, [Frozen] DateTimeOffset date, [Frozen] IMeasureDuration measureDuration, ReportingActor sut, ThenAction <object, string> thenAction, TimeSpan expectedDuration ) { //arrange Exception expectedException = null; Mock.Get(measureDuration).Setup(m => m.Measure(It.IsAny <Func <string> >())) .Returns(() => { try { _assertions[i](); } catch (Exception ex) { expectedException = ex; return(expectedDuration, string.Empty, ex); } throw new InvalidOperationException("Should not happen as the assertions actions should throw an exception"); }); //act try { sut.Execute(thenAction); } catch (Exception) { } //assert var expected = new[] { new ActionNotification(thenAction, 1, new BeforeThenNotificationContent(date, thenAction.Question)), new ActionNotification(thenAction, 1, new AfterThenNotificationContent(expectedDuration, ThenOutcome.Failed, expectedException)) }; observer.Values.Should().BeEquivalentTo(expected, o => o.RespectingRuntimeTypes().ComparingByMembers <ActionNotification>()); }
public void Then(Ctx ctx) { ThenAction?.Invoke(ctx); }