public void SaveItemAsync_NullItem()
        {
            var validator = new Mock <IValidator>(MockBehavior.Strict).Object;
            var next      = new Mock <ISaveItemService <Uom> >(MockBehavior.Strict).Object;
            var uut       = new SaveItemServiceValidate <Uom>(validator, next);

            Assert.ThrowsAsync <ArgumentNullException>
            (
                async() => await uut.SaveItemAsync(null)
            );
        }
        public async Task SaveItemAsync()
        {
            var uom = new Uom();
            //var expectedErrorDictionary = new Dictionary<string, ReadOnlyCollection<string>>();
            Dictionary <string, ReadOnlyCollection <string> > expectedErrorDictionary = null;
            var validator = new Mock <IValidator>(MockBehavior.Strict);

            validator.Setup(v => v.Validate(uom, out expectedErrorDictionary)).Returns(true);
            var next = new Mock <ISaveItemService <Uom> >(MockBehavior.Strict);

            next.Setup(n => n.SaveItemAsync(uom)).Returns(Task.CompletedTask);
            var uut = new SaveItemServiceValidate <Uom>(validator.Object, next.Object);
            await uut.SaveItemAsync(uom);
        }
        public void SaveItemAsync_InvalidItem()
        {
            var uom = new Uom();
            var expectedErrorDictionary = new Dictionary <string, ReadOnlyCollection <string> >();
            var validator = new Mock <IValidator>(MockBehavior.Strict);

            validator.Setup(v => v.Validate(uom, out expectedErrorDictionary)).Returns(false);
            var next      = new Mock <ISaveItemService <Uom> >(MockBehavior.Strict).Object;
            var uut       = new SaveItemServiceValidate <Uom>(validator.Object, next);
            var exception = Assert.ThrowsAsync <BadRequestHttpException>
                            (
                async() => await uut.SaveItemAsync(uom)
                            );

            Assert.AreEqual(expectedErrorDictionary, exception.ErrorDictionary);
        }