/// <summary> /// Configure the actor for Selenium reporting and returns an object that allows to retrieve the report. This is similar to using: /// - <see cref="Tranquire.ActorExtensions.WithReporting(Actor, IObserver{Reporting.ActionNotification}, ICanNotify)"/> /// - <see cref="TakeScreenshots(Actor, string, IObserver{ScreenshotInfo}, ITakeScreenshotStrategy)"/> /// </summary> /// <param name="actor">The actor</param> /// <param name="configuration">The reporting configuration</param> /// <param name="seleniumReporter">A <see cref="ISeleniumReporter"/> object that can be used to save the screenshots and retrieve the report at the end of the run</param> /// <returns></returns> public static Actor WithSeleniumReporting( this Actor actor, SeleniumReportingConfiguration configuration, out ISeleniumReporter seleniumReporter) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var xmlDocumentObserver = new XmlDocumentObserver(); var textObservers = new CompositeObserver <string>(configuration.TextOutputObservers.ToArray()); var reportingObserver = new CompositeObserver <ActionNotification>( xmlDocumentObserver, new RenderedReportingObserver(textObservers, RenderedReportingObserver.DefaultRenderer) ); var saveScreenshotObserver = new SaveScreenshotsToFileOnComplete(configuration.ScreenshotDirectory); var screenshotObserver = new CompositeObserver <ScreenshotInfo>( saveScreenshotObserver, new ScreenshotInfoToActionAttachmentObserverAdapter(xmlDocumentObserver), new RenderedScreenshotInfoObserver(textObservers) ); seleniumReporter = new SeleniumReporter(xmlDocumentObserver, saveScreenshotObserver); return(configuration.ApplyWithReporting(actor, reportingObserver) .TakeScreenshots(configuration.ScreenshotNameOrFormat, screenshotObserver, configuration.TakeScreenshotStrategy)); }
public void OnNext_ShouldCallOnNextOnAllObservers(CompositeObserver <object> sut, object value) { // act sut.OnNext(value); // assert foreach (var mock in sut.Select(Mock.Get)) { mock.Verify(o => o.OnNext(value)); } }
public void OnError_ShouldCallOnErrorOnAllObservers(CompositeObserver <object> sut, Exception exception) { // act sut.OnError(exception); // assert foreach (var mock in sut.Select(Mock.Get)) { mock.Verify(o => o.OnError(exception)); } }
public void OnCompleted_ShouldCallOnCompletedOnAllObservers(CompositeObserver <object> sut) { // act sut.OnCompleted(); // assert foreach (var mock in sut.Select(Mock.Get)) { mock.Verify(o => o.OnCompleted()); } }
public void SimpleAdditionNeuron(decimal val1, decimal val2) { // Arrange var receiver = new ValueStoringNeuron<decimal>(); var sut = new CompositeObserver<decimal>(new IObserver<decimal>[] { new DelayedActivationNeuron<decimal, decimal>(new DecimalSumFunction(), receiver) }); // Act sut.OnNext(val1); sut.OnNext(val2); sut.OnCompleted(); // Assert var result = receiver.LastValue; result.Should().Be(val1 + val2); }
public void AlternativeSingleAdditionNeuronInLayerUsingBuilders(decimal val1, decimal val2) { // Arrange var outputLayer = new OutputLayerBuilder<decimal> { NumberOfNeurons = 1 }.Build(); var fixedWrappedOutputBuilder = new FixedValueBuilder<IEnumerable<IObserver<decimal>>> { Value = outputLayer }; var layerBuilder = new WrappingHiddenLayerBuilder<decimal, decimal> { FunctionSource = new ByDefaultConstructorBuilder<DecimalSumFunction>(), NextLayer = fixedWrappedOutputBuilder }; var sut = new CompositeObserver<IEnumerable<decimal>>(layerBuilder.Build()); // Act sut.OnNext(new decimal[] { val1, val2 }); // Assert var result = fixedWrappedOutputBuilder.Value.Cast<ValueStoringNeuron<decimal>>().Single().LastValue; result.Should().Be(val1 + val2); }