コード例 #1
0
        public void Edit_ReturnsFalseOnExcepiton()
        {
            // Arrange
            var articlesService = new ArticlesService(null);

            // Act
            var result = articlesService.Edit(null);

            //Assert
            Assert.False(result);
        }
コード例 #2
0
        public void Edit_ReturnsFalseIfNotFound()
        {
            // Arrange
            var context = this.ServiceProvider.GetRequiredService <WmipDbContext>();
            var article = new Article {
                Id = 1, Title = "art1"
            };

            context.Articles.Add(article);
            context.SaveChanges();
            var articlesService = new ArticlesService(context);
            var editInfo        = new EditPostDto()
            {
                Id = 2, Title = "aaaararar"
            };

            // Act
            var result = articlesService.Edit(editInfo);

            //Assert
            Assert.False(result);
        }
コード例 #3
0
        public void Edit_ChangesProperties()
        {
            // Arrange
            var context = this.ServiceProvider.GetRequiredService <WmipDbContext>();
            var article = new Article {
                Id = 1, Title = "art1"
            };

            context.Articles.Add(article);
            context.SaveChanges();
            var articlesService = new ArticlesService(context);
            var editInfo        = new EditPostDto()
            {
                Id = 1, Title = "aaaararar"
            };

            // Act
            var result = articlesService.Edit(editInfo);

            //Assert
            Assert.True(result);
            Assert.Equal(editInfo.Title, context.Articles.First().Title);
        }