Example #1
0
        public void Multiply_RegisteredType_InvokesOperation()
        {
            // Arrange
            var              mockDelegate = new Mock <IOperationFunction>();
            IUnit            unit         = new Mock <IUnit>().Object;
            ArithmeticsStore store        = CreateStore();

            store.RegisterMultiplyOperation <float, float>(mockDelegate.Object.Operation);
            // Act/assert
            Assert.DoesNotThrow(() => store.Multiply(new Quantity <float>(0.0f, unit), new Quantity <float>(0.0f, unit)));
            mockDelegate.Verify(x => x.Operation(It.IsAny <QuantityBase>(), It.IsAny <QuantityBase>()), Times.Once());
        }
Example #2
0
        public void Multiply_RegisteredTypeButNotMatchingDimension_InvokesOperation()
        {
            // Arrange
            var mockDelegate = new Mock <IOperationFunction>();
            var stubUnit1    = new Mock <IUnit>();

            stubUnit1.Setup(x => x.Dimension).Returns(new Mock <IDimension>().Object);
            var stubUnit2 = new Mock <IUnit>();

            stubUnit2.Setup(x => x.Dimension).Returns(new Mock <IDimension>().Object);
            ArithmeticsStore store = CreateStore();

            store.RegisterMultiplyOperation <float, float>(mockDelegate.Object.Operation);
            // Act/assert
            Assert.DoesNotThrow(() => store.Multiply(new Quantity <float>(0.0f, stubUnit1.Object),
                                                     new Quantity <float>(0.0f, stubUnit2.Object)));
            mockDelegate.Verify(x => x.Operation(It.IsAny <QuantityBase>(), It.IsAny <QuantityBase>()), Times.Once());
        }