Beispiel #1
0
        public async Task TestGetAllSuggestProducts_WithoutGivenType_ShouldReturnAllSuggestProducts()
        {
            // Arrange
            var context = ApplicationDbContextInMemoryFactory.InitializeContext();

            var groupRepository          = new EfDeletableEntityRepository <Product_Group>(context);
            var productRepository        = new EfDeletableEntityRepository <Product>(context);
            var suggestProductRepository = new EfDeletableEntityRepository <SuggestProduct>(context);

            var groupService          = new GroupService(groupRepository);
            var suggestproductService = new SuggestProdcut(suggestProductRepository);

            var seeder = new DbContextTestsSeeder();
            await seeder.SeedUsersAsync(context);

            await seeder.SeedGroupAsync(context);

            await seeder.SeedSuggestProductAsync(context);

            // Act
            AutoMapperConfig.RegisterMappings(typeof(IndexSuggestProductViewModel).Assembly);
            var result   = suggestproductService.GetAllSuggestion <IndexSuggestProductViewModel>("abc1");
            var expected = result.ToList().Count;
            var actual   = context.SuggestProducts.Count();

            // Assert
            Assert.True(expected == actual, string.Format(ErrorMessage, "GetAllSuggestion"));
        }