Beispiel #1
0
        public async Task GetVendorByName_ReturnsVendorByUserName()
        {
            // arrange
            var vendor = new Vendor {
                id = 123, userName = "******", name = "name1", website = "website_1"
            };
            var service = new VendorServices {
                vendorId           = 123, flatFee = true, price = 20,
                serviceDescription = "desc", serviceName = "svcName", serviceType = "Venue"
            };

            vendor.services = new List <VendorServices> {
                service
            };

            _vendorsQueryMock.Setup(x => x.GetByUserName(vendor.userName))
            .Returns(Task.Factory.StartNew(() => vendor));

            // act
            var task = await _sut.GetByUserName(vendor.userName);

            // assert
            Assert.IsType <OkObjectResult>(task);

            var result      = task as OkObjectResult;
            var usersResult = result.Value as Vendor;

            Assert.Equal(vendor, usersResult);
        }