示例#1
0
        public void ClothesMain_Equal_Ok()
        {
            const int     id          = 1;
            const string  name        = "Полушубок";
            const string  description = "Полушубок красивый";
            const decimal price       = (decimal)0.55;
            var           images      = new List <IClothesImageDomain> {
                new ClothesImageDomain(1, Resources.TestImage, true)
            };
            var gender      = new GenderDomain(GenderType.Male, "Мужик");
            var clothesType = new ClothesTypeDomain("Тряпье нательное", SizeType.American, "Тряпье");
            var colors      = new List <IColorDomain> {
                new ColorDomain("Бежевый")
            };
            var sizes = new List <ISizeDomain> {
                new SizeDomain(SizeType.American, "1")
            };
            var sizeGroups = new List <ISizeGroupMainDomain> {
                new SizeGroupMainDomain(ClothesSizeType.Shirt, 1, sizes)
            };
            var clothes = new ClothesMainDomain(id, name, description, price, images, gender, clothesType, colors, sizeGroups);

            int clothesHash = HashCode.Combine(HashCode.Combine(id, name, price, description),
                                               gender.GetHashCode(), clothesType.GetHashCode(),
                                               colors.GetHashCodes(), sizeGroups.GetHashCodes());

            Assert.Equal(clothesHash, clothes.GetHashCode());
        }
示例#2
0
        public void ClothesMain_Equal_ClothesMain()
        {
            var first  = ClothesData.ClothesMainDomains.First();
            var second = new ClothesMainDomain(first.Id, first.Name, first.Description, first.Price, first.Images,
                                               first.Gender, first.ClothesType, first.Colors, first.SizeGroups);

            Assert.True(first.Equals(second));
        }
        public void ValidateModel_PriceError(decimal price)
        {
            var clothes      = ClothesData.ClothesMainDomains.First();
            var clothesPrice = new ClothesMainDomain(clothes.Id, clothes.Name, clothes.Description, price, clothes.Images,
                                                     clothes.Gender, clothes.ClothesType, clothes.Colors, clothes.SizeGroups);

            var result = ValidateModel(clothesPrice);

            Assert.True(result.HasErrors);
            Assert.True(result.Errors.First().ErrorResultType == ErrorResultType.ValueNotValid);
        }
        public void ValidateModel_DescriptionError()
        {
            var clothes = ClothesData.ClothesMainDomains.First();
            var clothesEmptyDescription = new ClothesMainDomain(clothes.Id, clothes.Name, String.Empty, clothes.Price, clothes.Images,
                                                                clothes.Gender, clothes.ClothesType, clothes.Colors, clothes.SizeGroups);

            var result = ValidateModel(clothesEmptyDescription);

            Assert.True(result.HasErrors);
            Assert.True(result.Errors.First().ErrorResultType == ErrorResultType.ValueNotValid);
        }
        public async Task ValidateIncludes_SizeGroupsNotFound()
        {
            var sizeGroups      = SizeGroupData.SizeGroupMainDomains.Append(new SizeGroupMainDomain(ClothesSizeType.Dress, 0, Enumerable.Empty <ISizeDomain>()));
            var clothes         = ClothesData.ClothesMainDomains.First();
            var clothesNotFound = new ClothesMainDomain(clothes, clothes.Images, clothes.Gender, clothes.ClothesType,
                                                        clothes.Colors, sizeGroups);

            var result = await ValidateIncludes(clothesNotFound);

            Assert.True(result.HasErrors);
            Assert.True(result.Errors.First().ErrorResultType == ErrorResultType.ValueNotFound);
        }
        public async Task ValidateIncludes_ColorsNotFound()
        {
            var colors          = ColorData.ColorDomains.Append(new ColorDomain("NotFound"));
            var clothes         = ClothesData.ClothesMainDomains.First();
            var clothesNotFound = new ClothesMainDomain(clothes, clothes.Images, clothes.Gender, clothes.ClothesType,
                                                        colors, clothes.SizeGroups);

            var result = await ValidateIncludes(clothesNotFound);

            Assert.True(result.HasErrors);
            Assert.True(result.Errors.First().ErrorResultType == ErrorResultType.ValueNotFound);
        }
        public async Task ValidateIncludes_GenderNotFound()
        {
            var gender          = new GenderDomain(GenderType.Child, "NotFound");
            var clothes         = ClothesData.ClothesMainDomains.First();
            var clothesNotFound = new ClothesMainDomain(clothes, clothes.Images, gender, clothes.ClothesType,
                                                        clothes.Colors, clothes.SizeGroups);

            var result = await ValidateIncludes(clothesNotFound);

            Assert.True(result.HasErrors);
            Assert.True(result.Errors.First().ErrorResultType == ErrorResultType.ValueNotFound);
        }
        public void ValidateModel_SizeGroupsError()
        {
            var clothes = ClothesData.ClothesMainDomains.First();
            var clothesEmptySizeGroups = new ClothesMainDomain(clothes.Id, clothes.Name, clothes.Description, clothes.Price, clothes.Images,
                                                               clothes.Gender, clothes.ClothesType, clothes.Colors,
                                                               Enumerable.Empty <ISizeGroupMainDomain>());

            var result = ValidateModel(clothesEmptySizeGroups);

            Assert.True(result.HasErrors);
            Assert.True(result.Errors.First().ErrorResultType == ErrorResultType.CollectionEmpty);
        }
示例#9
0
        public void ClothesMain_Equal_Color()
        {
            var first  = ClothesData.ClothesDomains.First();
            var images = new List <IClothesImageDomain> {
                new ClothesImageDomain(1, Resources.TestImage, true)
            };
            var second = new ClothesMainDomain(first, images, GenderData.GenderCategoryDomains.First(),
                                               ClothesTypeData.ClothesTypeMainDomains.First(),
                                               ColorData.ColorDomains, SizeGroupData.SizeGroupMainDomains);

            Assert.True(first.Equals(second));
        }