public void SingleAdditionNeuronInLayerUsingBuilders(decimal val1, decimal val2)
        {
            // Arrange
            var receiverBuilder = new FixedValueBuilder<IEnumerable<ValueStoringNeuron<decimal>>>
            {
                Value = new OutputLayerBuilder<decimal>
                {
                    NumberOfNeurons = 1
                }.Build()
            };
            var layerBuilder = new DelayedSimpleHiddenLayerBuilder<decimal, ValueStoringNeuron<decimal>>
            {
                NumberOfNeurons = 1,
                NextLayerBuilder = receiverBuilder,
                FunctionSource = new ByDefaultConstructorBuilder<DecimalSumFunction>()
            };
            var sut = new OnNextSplittingObserverDecorator<decimal>(new CompositeObserver<decimal>(layerBuilder.Build()));

            // Act
            sut.OnNext(new decimal[] { val1, val2 });

            // Assert
            var result = receiverBuilder.Value.Single().LastValue;
            result.Should().Be(val1 + val2);
        }
        public void ManyAdditionNeuronInLayerUsingBuilders(decimal val1, decimal val2, int neuronCount)
        {
            // Arrange
            var receiverBuilder = new FixedValueBuilder<IEnumerable<ValueStoringNeuron<decimal>>>
            {
                Value = new OutputLayerBuilder<decimal>
                {
                    NumberOfNeurons = neuronCount
                }.Build()
            };
            var layerBuilder = new DelayedWrappingHiddenLayerBuilder<decimal, ValueStoringNeuron<decimal>>
            {
                FunctionSource = new ByDefaultConstructorBuilder<DecimalSumFunction>(),
                NextLayer = receiverBuilder
            };
            var sut = new OnNextSplittingObserverDecorator<decimal>(new CompositeObserver<decimal>(layerBuilder.Build()));

            // Act
            sut.OnNext(new decimal[] { val1, val2 });

            // Assert
            receiverBuilder.Value.Select(neuron => neuron.LastValue).Should().OnlyContain(value => value == val1 + val2);

        }
        public void AlternativeTwoToManyAdditionNeuronInLayerUsingBuilders(decimal val1, decimal val2, int neuronCount)
        {
            // Arrange
            var outputLayer = new OutputLayerBuilder<decimal>
            {
                NumberOfNeurons = 1
            }.Build();
            var fixedWrappedOutputBuilder = new FixedValueBuilder<IEnumerable<IObserver<decimal>>>
            {
                Value = outputLayer
            };
            var hiddenLayerBuilder = new WrappingHiddenLayerBuilder<decimal, decimal>
            {
                FunctionSource = new ByDefaultConstructorBuilder<DecimalSumFunction>(),
                NextLayer = fixedWrappedOutputBuilder
            };
            var inputLayerBuilder = new SimpleHiddenLayerBuilder<decimal, decimal>
            {
                NumberOfNeurons = 2,
                NextLayerBuilder = hiddenLayerBuilder,
                FunctionSource = new ByDefaultConstructorBuilder<DecimalSumFunction>()
            };
            var sut = inputLayerBuilder.Build().ToList();

            // Act
            sut[0].OnNext(new decimal[]
            {
                val1
            });
            sut[1].OnNext(new decimal[]
            {
                val2
            });

            // Assert
            var result = fixedWrappedOutputBuilder.Value.Cast<ValueStoringNeuron<decimal>>().Single().LastValue;
            result.Should().Be(val1 + val2);
        }
        public void TwoToManyToTwoLayeredNetworkUsingBuilders(decimal val1, decimal val2, int hiddenNetworkSize)
        {
            // Arrange
            var receiverBuilder = new FixedValueBuilder<IEnumerable<ValueStoringNeuron<decimal>>>
            {
                Value = new OutputLayerBuilder<decimal>
                {
                    NumberOfNeurons = 2
                }.Build()
            };
            var outputWrappingBuilder = new DelayedWrappingHiddenLayerBuilder<decimal, ValueStoringNeuron<decimal>>
            {
                FunctionSource = new ByDefaultConstructorBuilder<DecimalSumFunction>(),
                NextLayer = receiverBuilder
            };
            var hiddenLayerBuilder = new DelayedSimpleHiddenLayerBuilder<decimal, IObserver<decimal>>
            {
                NumberOfNeurons = hiddenNetworkSize,
                NextLayerBuilder = outputWrappingBuilder,
                FunctionSource = new ByDefaultConstructorBuilder<DecimalSumFunction>()
            };
            var inputLayerBuilder = new InputLayerBuilder<decimal>
            {
                NextLayerBuilder = hiddenLayerBuilder,
                NumberOfNeurons = 2
            };
            var sut = inputLayerBuilder.Build().ToList();

            // Act
            sut[0].OnNext(val1);
            sut[0].OnCompleted();
            sut[1].OnNext(val2);
            sut[1].OnCompleted();

            // Assert
            var expected = (val1 + val2) * hiddenNetworkSize;
            var first = receiverBuilder.Value.Select(neuron => neuron.LastValue).First();
            first.Should().Be(expected);
        }
        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);
        }