コード例 #1
0
        public void GivenANullSearchRequest_WhenICallSearch_AnExceptionIsThrown()
        {
            var shirts = CreateShirtRange();

            var shirtFinder = new LinqShirtFinder(shirts);

            Assert.Throws <ArgumentNullException>(() => shirtFinder.Find(null));
        }
コード例 #2
0
        public void GivenAnEmptySearchRequestWhenThereAreShirtsAvailable_WhenICallSearch_NoneAreReturned()
        {
            var shirts = CreateShirtRange();

            var shirtFinder = new LinqShirtFinder(shirts);

            var searchOptions = new SearchOptions();

            var results = shirtFinder.Find(searchOptions);

            AssertResults(results.Shirts, searchOptions);
            AssertSizeCounts(shirts, searchOptions, results.SizeCounts);
            AssertColorCounts(shirts, searchOptions, results.ColorCounts);
        }
コード例 #3
0
        public void GivenANullColorInSearchRequest_WhenICallSearch_AnExceptionIsThrown()
        {
            var shirts = CreateShirtRange();

            var shirtFinder = new LinqShirtFinder(shirts);

            var searchOptions = new SearchOptions()
            {
                Colors = null,
                Sizes  = { Size.Medium }
            };

            Assert.Throws <ArgumentNullException>(() => shirtFinder.Find(searchOptions));
        }
コード例 #4
0
        public void GivenASearchRequestForSmallOrLargeAndRedOrBlueShirts_WhenICallSearch_TheyAreReturned()
        {
            var shirts = CreateShirtRange();

            var shirtFinder = new LinqShirtFinder(shirts);

            var searchOptions = new SearchOptions()
            {
                Colors = { Color.Red, Color.Blue },
                Sizes  = { Size.Small, Size.Large }
            };

            var results = shirtFinder.Find(searchOptions);

            AssertResults(results.Shirts, searchOptions);
            AssertSizeCounts(shirts, searchOptions, results.SizeCounts);
            AssertColorCounts(shirts, searchOptions, results.ColorCounts);
        }
コード例 #5
0
        public void GivenAValidSearchRequestWhenThereAreNoShirts_WhenICallSearch_NoneAreReturned()
        {
            var shirts = new List <Shirt>
            {
            };

            var shirtFinder = new LinqShirtFinder(shirts);

            var searchOptions = new SearchOptions()
            {
                Colors = { Color.Red },
                Sizes  = { Size.Small }
            };

            var results = shirtFinder.Find(searchOptions);

            AssertResults(results.Shirts, searchOptions);
            AssertSizeCounts(shirts, searchOptions, results.SizeCounts);
            AssertColorCounts(shirts, searchOptions, results.ColorCounts);
        }
コード例 #6
0
        public void GivenASearchRequestForSmallRedShirtsWhenNonExist_WhenICallSearch_NoneAreReturned()
        {
            var shirts = new List <Shirt>
            {
                new Shirt(Guid.NewGuid(), "Small Yellow", Size.Small, Color.Yellow),
                new Shirt(Guid.NewGuid(), "Small White", Size.Small, Color.White),
                new Shirt(Guid.NewGuid(), "Large Blue", Size.Large, Color.Blue),
                new Shirt(Guid.NewGuid(), "Medium Blue", Size.Medium, Color.Blue),
            };

            var shirtFinder = new LinqShirtFinder(shirts);

            var searchOptions = new SearchOptions()
            {
                Colors = { Color.Red },
                Sizes  = { Size.Small }
            };

            var results = shirtFinder.Find(searchOptions);

            AssertResults(results.Shirts, searchOptions);
            AssertSizeCounts(shirts, searchOptions, results.SizeCounts);
            AssertColorCounts(shirts, searchOptions, results.ColorCounts);
        }