public void SutCallsOnNextWithTransformedInput(decimal input, long output, [Frozen]Mock<IObserver<long>> mockBackend, [Frozen]Mock<ITransformingFunction<decimal, long>> mockFunction, ActivationNeuron<decimal, long> sut) { mockFunction.Setup(function => function.Evaluate(input)).Returns(output); sut.OnNext(input); mockBackend.Verify(backend => backend.OnNext(output), Times.Once()); }
public void Xor(bool val1, bool val2) { // Arrange var boolTransformer = new BoolDecimalTransformer(); var receiver = new ValueStoringNeuron<bool>(); var wrappedReceiver = new OneToManyBufferingDecorator<decimal>( new ManyInputNeuron<decimal, decimal>( new DecimalSumFunction(), new ActivationNeuron<decimal, decimal>( new DecimalThresholdFunction { Threshold = 0.5M }, new ActivationNeuron<decimal, bool>( boolTransformer, receiver))) , 3); var pivotNeuron = new OneToManyBufferingDecorator<decimal>( new ManyInputNeuron<decimal, decimal>( new DecimalSumFunction(), new ActivationNeuron<decimal, decimal>( new DecimalThresholdFunction { Threshold = 1.5M }, new DecimalWeight(wrappedReceiver, -2M))) , 2); var leftNeuron = new ActivationNeuron<bool, decimal>( boolTransformer, new CompositeObserver<decimal>( new DecimalWeight(wrappedReceiver, 1), new DecimalWeight(pivotNeuron, 1))); var rightNeuron = new ActivationNeuron<bool, decimal>( boolTransformer, new CompositeObserver<decimal>( new DecimalWeight(wrappedReceiver, 1), new DecimalWeight(pivotNeuron, 1))); // Act leftNeuron.OnNext(val1); rightNeuron.OnNext(val2); // Assert var result = receiver.LastValue; var expected = val1 ^ val2; result.Should().Be(expected); }
public void SutTransformsInputOnNext(decimal input, [Frozen]Mock<ITransformingFunction<decimal, long>> mockFunction, ActivationNeuron<decimal, long> sut) { sut.OnNext(input); mockFunction.Verify(function => function.Evaluate(input), Times.AtLeastOnce()); }
public void SutChainsOnNext(decimal input, [Frozen]Mock<IObserver<long>> mockBackend, ActivationNeuron<decimal, long> sut) { sut.OnNext(input); mockBackend.Verify(backend => backend.OnNext(It.IsAny<long>()), Times.Once()); }
public void And(bool val1, bool val2) { // Arrange var boolTransformer = new BoolDecimalTransformer(); var receiver = new ValueStoringNeuron<bool>(); var perceptron = new OneToManyBufferingDecorator<decimal>( new ManyInputNeuron<decimal, decimal>( new DecimalSumFunction(), new ActivationNeuron<decimal, decimal>( new DecimalThresholdFunction { Threshold = 2M }, new ActivationNeuron<decimal, bool>( boolTransformer, receiver))) , 2); var leftNeuron = new ActivationNeuron<bool, decimal>( boolTransformer, perceptron); var rightNeuron = new ActivationNeuron<bool, decimal>( boolTransformer, perceptron); // Act leftNeuron.OnNext(val1); rightNeuron.OnNext(val2); // Assert var result = receiver.LastValue; var expected = val1 && val2; result.Should().Be(expected); }