Exemplo n.º 1
0
        public static Option <OrderLineQty> AddOrderQty(OrderLineQty x, OrderLineQty y)
        {
            // replace void with correct return value
            var z = x.Value + y.Value;

            return(OrderLineQty.Create(z));
        }
Exemplo n.º 2
0
        public void Test()
        {
            var x          = OrderLineQty.Create(98).Value; // only use "Value" for testing! It is not safe!
            var y1         = OrderLineQty.Create(1).Value;
            var y2         = OrderLineQty.Create(3).Value;
            var goodResult = AddOrderQty(x, y1);
            var badResult  = AddOrderQty(x, y2);

            // write a test to check the results
            Option.Match(goodResult,
                         some => { Assert.Pass(); return(1); }, // OK
                         () => { Assert.Fail(); return(0); } // fail
                         );

            Option.Match(badResult,
                         some => { Assert.Fail(); return(0); }, // fail
                         () => { Assert.Pass(); return(1); } // OK
                         );
        }