Exemplo n.º 1
0
        public async Task CheckProductCodeExists_InvalidValidProductCode_False()
        {
            var validateResult =
                await Validate.CheckProductCodeExists(MockProductCode)(ProductCodeHelper.ToProductCode("G123KC").Data);

            Assert.AreEqual(true, validateResult.Failure);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        public void CheckQuantityValid_InvalidQuantityNumberNegativeForGizmoCode_False()
        {
            var validationResult = Validate.CheckQuantityValid(
                ProductCodeHelper.ToProductCode("G124KC").Data,
                -10m);

            Assert.AreEqual(true, validationResult.Failure);
        }
Exemplo n.º 4
0
        public void CheckQuantityValid_InvalidQuantityNumberGreaterThan1000ForWidgetCode_False()
        {
            var validationResult = Validate.CheckQuantityValid(
                ProductCodeHelper.ToProductCode("W1234DKC").Data,
                10000m);

            Assert.AreEqual(true, validationResult.Failure);
        }
Exemplo n.º 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);
        }
Exemplo n.º 6
0
 public async Task CheckProductCodeExists_InvalidValidProductCode_Exception()
 {
     await Assert.ThrowsExceptionAsync <InvalidOperationException>(() =>
                                                                   Validate.CheckProductCodeExists(MockProductCode)(ProductCodeHelper.ToProductCode("122C").Data));
 }