Beispiel #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)));
        }
Beispiel #2
0
        public async Task GetImage_NotFound()
        {
            var clothesEntity          = ClothesEntitiesData.ClothesEntities.First();
            var errorInitial           = ErrorData.NotFoundError;
            var clothesResult          = new ResultValue <ClothesEntity>(errorInitial);
            var clothesTable           = ClothesTableMock.GetClothesTable(clothesResult);
            var database               = GetDatabase(clothesTable.Object);
            var clothesDatabaseService = GetClothesDatabaseService(database.Object, GetDatabaseValidationService(clothesTable.Object));

            var clothesResults = await clothesDatabaseService.GetImage(clothesEntity.Id);

            Assert.True(clothesResults.HasErrors);
            Assert.Equal(ErrorResultType.ValueNotFound, clothesResults.Errors.First().ErrorResultType);
        }
Beispiel #3
0
        public async Task GetImage_Ok()
        {
            var clothesEntities        = ClothesEntitiesData.ClothesEntities;
            var clothesEntity          = clothesEntities.First();
            var image                  = clothesEntity.Images !.First(imageEntity => imageEntity.IsMain).Image;
            var clothesTable           = ClothesTableMock.GetClothesTable(clothesEntities);
            var database               = GetDatabase(clothesTable);
            var clothesDatabaseService = GetClothesDatabaseService(database.Object, GetDatabaseValidationService(clothesTable));

            var clothesResults = await clothesDatabaseService.GetImage(clothesEntity.Id);

            Assert.True(clothesResults.OkStatus);
            Assert.True(clothesResults.Value.SequenceEqual(image));
        }
Beispiel #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);
        }