Exemplo n.º 1
0
        public void ReturnsEmptyIfListingHasNoImages()
        {
            var listing1 = new ListingFixture().Build();
            var image1   = new ListingImageFixture().Build();
            var image2   = new ListingImageFixture().Build();

            var mockContext = new Mock <IPortalDbContext>();

            mockContext.Setup(m => m.Query <ListingImage>())
            .Returns(() => new[] { image1, image2 }.AsQueryable())
            .Verifiable();

            var coordinator = new GetAllImagesCoordinator(mockContext.Object);

            var result = coordinator.GetAllImages(listing1.Id);

            mockContext.VerifyAll();
            Assert.Empty(result);
        }
Exemplo n.º 2
0
        public void FindsAllImagesThatBelongToAListing()
        {
            var listing1 = new ListingFixture().Build();
            var listing2 = new ListingFixture().Build();
            var image1   = new ListingImageFixture().ForListing(listing1).Build();
            var image2   = new ListingImageFixture().ForListing(listing2).Build();

            var mockContext = new Mock <IPortalDbContext>();

            mockContext.Setup(m => m.Query <ListingImage>())
            .Returns(() => new[] { image1, image2 }.AsQueryable())
            .Verifiable();

            var coordinator = new GetAllImagesCoordinator(mockContext.Object);

            var result = coordinator.GetAllImages(listing1.Id);

            mockContext.VerifyAll();
            Assert.Contains(image1, result);
            Assert.DoesNotContain(image2, result);
        }