Beispiel #1
0
        public void Subtract_UnregisteredType_ThrowsInvalidOperationException()
        {
            // Arrange
            IUnit            unit  = new Mock <IUnit>().Object;
            ArithmeticsStore store = CreateStore();

            // Act/assert
            Assert.Throws <InvalidOperationException>(() => store.Subtract(new Quantity <float>(0.0f, unit), new Quantity <float>(0.0f, unit)));
        }
Beispiel #2
0
        public void Subtract_RegisteredType_InvokesOperation()
        {
            // Arrange
            var              mockDelegate = new Mock <IOperationFunction>();
            IUnit            unit         = new Mock <IUnit>().Object;
            ArithmeticsStore store        = CreateStore();

            store.RegisterSubtractOperation <float>(mockDelegate.Object.Operation);
            // Act/assert
            Assert.DoesNotThrow(() => store.Subtract(new Quantity <float>(0.0f, unit), new Quantity <float>(0.0f, unit)));
        }
Beispiel #3
0
        public void Subtract_RegisteredButTypeNotMatchingUnits_ThrowsArgumentException()
        {
            // Arrange
            var              mockDelegate = new Mock <IOperationFunction>();
            IUnit            unit1        = new Mock <IUnit>().Object;
            IUnit            unit2        = new Mock <IUnit>().Object;
            ArithmeticsStore store        = CreateStore();

            store.RegisterSubtractOperation <float>(mockDelegate.Object.Operation);
            // Act/assert
            Assert.Throws <ArgumentException>(() => store.Subtract(new Quantity <float>(0.0f, unit1), new Quantity <float>(0.0f, unit2)));
        }