public void AddOpForward() { var nodeMockA = new Mock <Op <double> >(); var volA = new VolumeMock(1.0, new Shape(1)); nodeMockA.Setup(o => o.Evaluate(It.IsAny <Session <double> >())).Returns(volA); var nodeMockb = new Mock <Op <double> >(); var volB = new VolumeMock(2.0, new Shape(1)); nodeMockb.Setup(o => o.Evaluate(It.IsAny <Session <double> >())).Returns(volB); var op = new Add <double>(nodeMockA.Object, nodeMockb.Object); using (var session = new Session <double>()) { var eval = op.Evaluate(session); Assert.IsNotNull(eval); var s = session; nodeMockA.Verify(o => o.Evaluate(s)); nodeMockb.Verify(o => o.Evaluate(s)); Assert.AreEqual(1, volA.DoAddCount); } }
public void MultOpForward() { var cns = new ConvNetSharp <double>(); var nodeMockA = new Mock <Op <double> >(cns); var volA = new VolumeMock(1.0, new Shape(1)); nodeMockA.Setup(o => o.Evaluate(It.IsAny <Session <double> >())).Returns(volA); var nodeMockb = new Mock <Op <double> >(cns); var volB = new VolumeMock(2.0, new Shape(1)); nodeMockb.Setup(o => o.Evaluate(It.IsAny <Session <double> >())).Returns(volB); var op = nodeMockA.Object * nodeMockb.Object; using var session = new Session <double>(); var eval = op.Evaluate(session); Assert.IsNotNull(eval); var s = session; nodeMockA.Verify(o => o.Evaluate(s)); nodeMockb.Verify(o => o.Evaluate(s)); Assert.AreEqual(1, volA.DoMultiplyCount); }