Пример #1
0
        public void Should_return_one_image_in_every_size_category(
            int img1Height, int img1Width,
            int count,
            int?img2Height = null, int?img2Width = null,
            int?img3Height = null, int?img3Width = null,
            bool same      = false
            )
        {
            var imageLinks = ImageListBuilder.With()
                             .AddImage(x => x.Default().SetHeight(img1Height.ToString()).SetWidth(img1Width.ToString()));

            // ReSharper disable PossibleInvalidOperationException
            if (img2Height.HasValue)
            {
                imageLinks.AddImage(x =>
                                    x.Default().SetHeight(img2Height.Value.ToString()).SetWidth(img2Width.Value.ToString())
                                    .SetUrl(same ? "Same" : Guid.NewGuid().ToString()));
            }

            if (img3Height.HasValue)
            {
                imageLinks.AddImage(x =>
                                    x.Default().SetHeight(img3Height.Value.ToString()).SetWidth(img3Width.Value.ToString())
                                    .SetUrl(same ? "Same" : Guid.NewGuid().ToString()));
            }
            // ReSharper restore PossibleInvalidOperationException

            var images = ImageSelector.FilterImages(imageLinks.Build());

            images.Should().HaveCount(count);
        }
Пример #2
0
        public void Should_not_add_images_from_wrong_group()
        {
            var imageList = ImageListBuilder.With()
                            .AddImage(x => x.Default())
                            .AddImage(x => x.Default().SetSizeCategory(SizeCategoryEnum.Wrong))
                            .Build();
            var images = ImageSelector.FilterImages(imageList);

            images.Should().HaveCount(1);
        }
Пример #3
0
        public void Should_return_one_image_per_master_object_name_and_size_group()
        {
            var imageList = ImageListBuilder.With()
                            .AddImage(x => x.Default())
                            .AddImage(x => x.Default().SetMasterObjectName("2"))
                            .Build();
            var images = ImageSelector.FilterImages(imageList);

            images.Should().HaveCount(2);
        }
Пример #4
0
        public void Should_remove_all_duplicates()
        {
            var imageList = ImageListBuilder.With()
                            .AddImage(x => x.Default().SetUrl("http://1.jpg"))
                            .AddImage(x => x.Default().SetUrl("http://1.jpg").SetMasterObjectName("2"))
                            .Build();
            var images = ImageSelector.FilterImages(imageList);

            images.Should().HaveCount(1);
        }
Пример #5
0
        public void Should_deprioritize_documentTypeDetail_of_certain_types()
        {
            var imageList = ImageListBuilder.With()
                            .AddImage(x => x.Default().SetDocumentTypeDetail("product image - not as shown"))
                            .AddImage(x => x.Default().SetDocumentTypeDetail("product image"))
                            .Build();
            var images = ImageSelector.FilterImages(imageList);

            images.Should().HaveCount(1);
            images[0].TypeDetail.Should().Be("product image");
        }
Пример #6
0
        public void Should_return_prefer_CmgAcronym_cmg674()
        {
            var imageList = ImageListBuilder.With()
                            .AddImage(x => x.Default().SetCmgAcronym("cmg675"))
                            .AddImage(x => x.Default())
                            .Build();
            var images = ImageSelector.FilterImages(imageList);

            images.Should().HaveCount(1);
            images[0].GroupingKey1.Should().Be("cmg674");
        }
Пример #7
0
        public void Should_pick_one_of_each_orientation()
        {
            var imageList = ImageListBuilder.With()
                            .AddImage(x => x.Default().SetOrientation("Center facing"))
                            .AddImage(x => x.Default().SetOrientation("Left facing"))
                            .AddImage(x => x.Default().SetOrientation("Rear facing"))
                            .Build();
            var images = ImageSelector.FilterImages(imageList);

            images.Should().HaveCount(3);
        }
Пример #8
0
        public void Should_return_prefer_content_type_jpg_then_png_then_gif()
        {
            var imageList = ImageListBuilder.With()
                            .AddImage(x => x.Default().SetCmgAcronym("cmg675").SetContentType("gif"))
                            .AddImage(x => x.Default().SetCmgAcronym("cmg675").SetContentType("png"))
                            .AddImage(x => x.Default().SetCmgAcronym("cmg675").SetContentType("jpg"))
                            .AddImage(x => x.Default().SetContentType("gif"))
                            .AddImage(x => x.Default().SetContentType("jpg"))
                            .AddImage(x => x.Default().SetContentType("png"))
                            .Build();
            var images = ImageSelector.FilterImages(imageList);

            images.Should().HaveCount(1);
            images[0].GroupingKey1.Should().Be("cmg674");
            images[0].ContentType.Should().Be("jpg");
        }