Exemple #1
0
        public void ReadItemAsync_Id0()
        {
            var urlBuilder = new Mock <IItemReadUrlBuilder <Uom> >(MockBehavior.Strict).Object;
            var next       = new Mock <IReadItemServiceBuildRequest <Uom> >(MockBehavior.Strict).Object;
            var uut        = new ReadItemServiceBuildUrl <Uom>(urlBuilder, next);

            Assert.ThrowsAsync <ArgumentOutOfRangeException>(
                async() => await uut.ReadItemAsync(0)
                );
        }
Exemple #2
0
        public async Task ReadItemAsync()
        {
            var id          = 1001;
            var expectedUom = new Uom();
            var url         = "http://qtb3.com/a/b";
            var urlBuilder  = new Mock <IItemReadUrlBuilder <Uom> >(MockBehavior.Strict);

            urlBuilder.Setup(u => u.Build(id)).Returns(url);
            var next = new Mock <IReadItemServiceBuildRequest <Uom> >(MockBehavior.Strict);

            next.Setup(n => n.ReadItemAsync(url)).ReturnsAsync(expectedUom);
            var uut       = new ReadItemServiceBuildUrl <Uom>(urlBuilder.Object, next.Object);
            var actualUom = await uut.ReadItemAsync(id);

            Assert.AreEqual(expectedUom, actualUom);
        }