예제 #1
0
        public async Task DeleteAllUserNewsByUserIdAsync_WithValidData_ShoulRemoveFromRepository()
        {
            var         context    = SteuDbContextInMemoryFactory.InitializeContext();
            NewsService service    = this.IntializeNewsService(context);
            var         repository = new EfDeletableEntityRepository <News>(context);

            var tempNews = new News()
            {
                Content    = "content",
                SteuUserId = "userId",
            };

            var temp2News = new News()
            {
                Content    = "content2",
                SteuUserId = "idUser",
            };

            await repository.AddAsync(tempNews);

            await repository.AddAsync(temp2News);

            await repository.SaveChangesAsync();

            await service.DeleteAllUserNewsByUserIdAsync("userId");

            var actualResult = await repository.All().ToListAsync();

            Assert.Single(actualResult);
        }
예제 #2
0
        public async Task DeleteAllUserNewsByUserIdAsync_WithInValidUserId_ShouldReturnNormalList()
        {
            var         context    = SteuDbContextInMemoryFactory.InitializeContext();
            NewsService service    = this.IntializeNewsService(context);
            var         repository = new EfDeletableEntityRepository <News>(context);

            var tempNews = new News()
            {
                Content    = "content",
                SteuUserId = "userId",
            };

            var temp2News = new News()
            {
                Content    = "content2",
                SteuUserId = "idUser",
            };

            await repository.AddAsync(tempNews);

            await repository.AddAsync(temp2News);

            await repository.SaveChangesAsync();

            await service.DeleteAllUserNewsByUserIdAsync("orderId");

            var actualResult = await repository.All().ToListAsync();

            Assert.Equal(2, actualResult.Count);
        }