Ejemplo n.º 1
0
        public async Task GetClothesDetails_Ok()
        {
            var    genderEntities                 = GenderEntitiesData.GenderEntities;
            var    clothesTypeEntities            = ClothesTypeEntitiesData.ClothesTypeEntities;
            var    genderType                     = genderEntities.First().GenderType;
            string clothesType                    = clothesTypeEntities.First().Name;
            var    clothesEntities                = ClothesEntitiesData.ClothesEntities;
            var    genderWithClothesEntities      = GenderEntitiesData.GetGenderEntitiesWithClothes(genderEntities, clothesEntities);
            var    clothesTypeWithClothesEntities = ClothesTypeEntitiesData.GetClothesTypeEntitiesWithClothes(clothesTypeEntities,
                                                                                                              clothesEntities);
            var genderTable            = GenderTableMock.GetGenderTable(genderWithClothesEntities);
            var clothesTypeTable       = ClothesTypeTableMock.GetClothesTypeTable(clothesTypeWithClothesEntities);
            var clothesTable           = ClothesTableMock.GetClothesTable(clothesEntities);
            var clothesEntityConverter = ClothesEntityConverterMock.ClothesDetailEntityConverter;
            var database = GetDatabase(genderTable, clothesTypeTable, clothesTable);
            var clothesDatabaseService = GetClothesDatabaseService(database.Object, GetDatabaseValidationService(clothesTable));

            var clothesResults = await clothesDatabaseService.GetClothesDetails(genderType, clothesType);

            var clothesDomains = clothesEntityConverter.FromEntities(clothesEntities);

            Assert.True(clothesResults.OkStatus);
            Assert.True(clothesResults.Value.SequenceEqual(clothesDomains.Value.Where(clothes => clothes.GenderType == genderType &&
                                                                                      clothes.ClothesTypeName == clothesType)));
        }
        public async Task GetGenderCategories_Ok()
        {
            var genderCategoryEntities  = GenderEntitiesData.GenderCategoryEntities;
            var categoryEntities        = CategoryEntitiesData.CategoryEntities;
            var clothesTypeEntities     = ClothesTypeEntitiesData.ClothesTypeEntities;
            var categoryWithGenders     = CategoryEntitiesData.GetCategoryEntitiesWithGenders(categoryEntities, genderCategoryEntities);
            var clothesTypeWithCategory = ClothesTypeEntitiesData.GetClothesTypeEntitiesWithCategory(clothesTypeEntities, categoryEntities.First());
            var genderTable             = GenderTableMock.GetGenderTable(genderCategoryEntities);
            var categoryTable           = CategoryTableMock.GetCategoryTable(categoryWithGenders);
            var clothesTypeTable        = ClothesTypeTableMock.GetClothesTypeTable(clothesTypeWithCategory);
            var database = GetDatabase(genderTable, categoryTable, clothesTypeTable);
            var genderEntityConverter         = GenderEntityConverterMock.GenderEntityConverter;
            var genderCategoryEntityConverter = GenderEntityConverterMock.GenderCategoryEntityConverter;
            var genderDatabaseService         = new GenderDatabaseService(database.Object,
                                                                          GetDatabaseValidationService(genderTable),
                                                                          genderEntityConverter,
                                                                          genderCategoryEntityConverter);

            var genderResults = await genderDatabaseService.GetGenderCategories();

            var gendersDomains = genderCategoryEntityConverter.FromEntities(genderCategoryEntities);

            Assert.True(genderResults.OkStatus);
            Assert.True(genderResults.Value.SequenceEqual(gendersDomains.Value));
        }
        public async Task GetGenderCategories_Error()
        {
            var errorInitial            = ErrorData.DatabaseError;
            var genderCategoryEntities  = GenderEntitiesData.GenderCategoryEntities;
            var genderResult            = new ResultCollection <GenderEntity>(errorInitial);
            var categoryEntities        = CategoryEntitiesData.CategoryEntities;
            var clothesTypeEntities     = ClothesTypeEntitiesData.ClothesTypeEntities;
            var categoryWithGenders     = CategoryEntitiesData.GetCategoryEntitiesWithGenders(categoryEntities, genderCategoryEntities);
            var clothesTypeWithCategory = ClothesTypeEntitiesData.GetClothesTypeEntitiesWithCategory(clothesTypeEntities, categoryEntities.First());
            var genderTable             = GenderTableMock.GetGenderTable(genderResult);
            var categoryTable           = CategoryTableMock.GetCategoryTable(categoryWithGenders);
            var clothesTypeTable        = ClothesTypeTableMock.GetClothesTypeTable(clothesTypeWithCategory);
            var database = GetDatabase(genderTable.Object, categoryTable, clothesTypeTable);
            var genderEntityConverter         = GenderEntityConverterMock.GenderEntityConverter;
            var genderCategoryEntityConverter = GenderEntityConverterMock.GenderCategoryEntityConverter;
            var genderDatabaseService         = new GenderDatabaseService(database.Object,
                                                                          GetDatabaseValidationService(genderTable.Object),
                                                                          genderEntityConverter,
                                                                          genderCategoryEntityConverter);

            var genderResults = await genderDatabaseService.GetGenderCategories();

            Assert.True(genderResults.HasErrors);
            Assert.Equal(errorInitial.ErrorResultType, genderResults.Errors.First().ErrorResultType);
        }
Ejemplo n.º 4
0
        public async Task GetClothes_Error()
        {
            var    errorInitial                   = ErrorData.DatabaseError;
            var    genderEntities                 = GenderEntitiesData.GenderEntities;
            var    clothesTypeEntities            = ClothesTypeEntitiesData.ClothesTypeEntities;
            var    genderType                     = genderEntities.First().GenderType;
            string clothesType                    = clothesTypeEntities.First().Name;
            var    clothesEntities                = ClothesEntitiesData.ClothesEntities;
            var    clothesResult                  = new ResultCollection <ClothesEntity>(errorInitial);
            var    genderWithClothesEntities      = GenderEntitiesData.GetGenderEntitiesWithClothes(genderEntities, clothesEntities);
            var    clothesTypeWithClothesEntities = ClothesTypeEntitiesData.GetClothesTypeEntitiesWithClothes(clothesTypeEntities,
                                                                                                              clothesEntities);
            var genderTable            = GenderTableMock.GetGenderTable(genderWithClothesEntities);
            var clothesTypeTable       = ClothesTypeTableMock.GetClothesTypeTable(clothesTypeWithClothesEntities);
            var clothesTable           = ClothesTableMock.GetClothesTable(clothesResult);
            var database               = GetDatabase(genderTable, clothesTypeTable, clothesTable.Object);
            var clothesDatabaseService = GetClothesDatabaseService(database.Object, GetDatabaseValidationService(clothesTable.Object));

            var clothesResults = await clothesDatabaseService.GetClothes(genderType, clothesType);

            Assert.True(clothesResults.HasErrors);
            Assert.Equal(errorInitial.ErrorResultType, clothesResults.Errors.First().ErrorResultType);
        }
 /// <summary>
 /// Сервис проверки данных из базы категорий одежды
 /// </summary>
 public static IClothesTypeDatabaseValidateService GetClothesTypeDatabaseValidateService(IEnumerable <ClothesTypeEntity> clothesTypes,
                                                                                         IEnumerable <CategoryEntity> categories) =>
 new ClothesTypeDatabaseValidateService(ClothesTypeTableMock.GetClothesTypeTable(clothesTypes),
                                        CategoryDatabaseValidateServiceMock.GetCategoryDatabaseValidateService(categories));