Пример #1
0
        public async Task CheckProductCodeExists_InvalidValidProductCode_False()
        {
            var validateResult =
                await Validate.CheckProductCodeExists(MockProductCode)(ProductCodeHelper.ToProductCode("G123KC").Data);

            Assert.AreEqual(true, validateResult.Failure);
        }
Пример #2
0
        public async Task CheckProductCodeExists_ValidProductCode_True()
        {
            var validateResult =
                await Validate.CheckProductCodeExists(MockProductCode)(ProductCodeHelper.ToProductCode("G124KC").Data);

            Assert.AreEqual(true, validateResult.Success);
            Assert.AreEqual(true, validateResult.Data);
        }
Пример #3
0
        public void CheckQuantityValid_InvalidQuantityNumberNegativeForGizmoCode_False()
        {
            var validationResult = Validate.CheckQuantityValid(
                ProductCodeHelper.ToProductCode("G124KC").Data,
                -10m);

            Assert.AreEqual(true, validationResult.Failure);
        }
Пример #4
0
        public void CheckQuantityValid_InvalidQuantityNumberGreaterThan1000ForWidgetCode_False()
        {
            var validationResult = Validate.CheckQuantityValid(
                ProductCodeHelper.ToProductCode("W1234DKC").Data,
                10000m);

            Assert.AreEqual(true, validationResult.Failure);
        }
Пример #5
0
        public async Task CheckOrderLineValid_ValidGizmoOrderLine_True()
        {
            var validationResult = await Validate.CheckOrderLineValid(
                Validate.CheckProductCodeExists(MockProductCode),
                Validate.CheckQuantityValid)(
                new UnvalidatedOrderLine
            {
                Amount      = 100.22m,
                ProductCode = "G124KC"
            });

            Assert.AreEqual(true, validationResult.Success);
            Assert.AreEqual(ProductCodeHelper.ToProductCode("G124KC").Data, validationResult.Data.ProductCode);
            Assert.AreEqual(100.22m, validationResult.Data.OrderQuantity.Value);
            Assert.AreEqual(1, validationResult.Data.OrderQuantity.EnumValue);
            Assert.AreEqual("Kilogram", validationResult.Data.OrderQuantity.DisplayName);
        }
Пример #6
0
 public async Task CheckProductCodeExists_InvalidValidProductCode_Exception()
 {
     await Assert.ThrowsExceptionAsync <InvalidOperationException>(() =>
                                                                   Validate.CheckProductCodeExists(MockProductCode)(ProductCodeHelper.ToProductCode("122C").Data));
 }