Example #1
0
        public void GetSizesShouldReturnSizesShouldFilterBySexIfNotTypeClothes()
        {
            var sizeRepo = new Mock <IRepository <Size> >();

            sizeRepo.Setup(r => r.All()).Returns(new List <Size>
            {
                new ShoesSize {
                    Sex = Sex.Kids
                },
                new ClothesSize {
                    Sex = null
                },
                new ShoesSize {
                    Sex = Sex.Men, Name = "32"
                },
                new ShoesSize {
                    Sex = Sex.Women
                },
            }.AsQueryable());

            var service = new SizesService(sizeRepo.Object, null);
            var sizes   = service.GetSizes(CategoryType.Shoes, Sex.Men);

            Assert.Equal(1, sizes.Count);
            sizeRepo.Verify(r => r.All(), Times.Once);
        }
Example #2
0
        public void GetSizesShouldReturnSizesShouldFilterBySexIfNotTypeClothesAndOrderByName()
        {
            var sizeRepo = new Mock <IRepository <Size> >();

            sizeRepo.Setup(r => r.All()).Returns(new List <Size>
            {
                new ShoesSize {
                    Sex = Sex.Men, Name = "34"
                },
                new ClothesSize {
                    Sex = null
                },
                new ShoesSize {
                    Sex = Sex.Men, Name = "32"
                },
                new ShoesSize {
                    Sex = Sex.Men, Name = "33"
                },
            }.AsQueryable());

            var service = new SizesService(sizeRepo.Object, null);
            var sizes   = service.GetSizes(CategoryType.Shoes, Sex.Men).ToList();

            Assert.Equal(3, sizes.Count);
            Assert.Equal("32", sizes.First().Name);
            Assert.Equal("33", sizes[1].Name);
            Assert.Equal("34", sizes.Last().Name);
            sizeRepo.Verify(r => r.All(), Times.Once);
        }
Example #3
0
        public void GetSizesShouldReturnAllSizes()
        {
            var sizeRepo = new Mock <IRepository <Size> >();

            sizeRepo.Setup(r => r.All()).Returns(new List <Size>
            {
                new ClothesSize {
                    Sex = Sex.Men
                },
                new ClothesSize()
                {
                    Sex = Sex.Men
                },
                new ClothesSize()
                {
                    Sex = Sex.Men
                }
            }.AsQueryable());

            var service = new SizesService(sizeRepo.Object, null);
            var sizes   = service.GetSizes(CategoryType.Clothes, Sex.Men);

            Assert.Equal(3, sizes.Count);
            sizeRepo.Verify(r => r.All(), Times.Once);
        }