public void GetBugsShouldReturnAllBugs()
        {
            DbContext = new NewsDbContext();
            this.data = new NewsData(DbContext);
            // Arrange -> prapare the objects

            this.data.News.Add(new NewsItem
            {
                Title = "Test",
                Content = "Test",
                PublishDate = DateTime.Now
            });

            this.data.News.Add(new NewsItem
            {
                Title = ";sdka;skladfh;aklsj kljoidflkjal",
                Content = "Test;Test;Test;Test",
                PublishDate = DateTime.Now.AddDays(-1)
            });
            this.data.SaveChanges();

            // Act -> perform some logic
            var news = this.data.News.All().Count();

            // Assert -> validate the results
            Assert.AreEqual(2, news);
        }
        public void CreateNewsItemWithoutContentDataShouldThrowException()
        {
            DbContext = new NewsDbContext();
            this.data = new NewsData(DbContext);

            this.data.News.Add(new NewsItem
            {
                Title = "Test",
                PublishDate = DateTime.Now
            });

            this.data.SaveChanges();
        }
        public void AddNewsItemThenGetTheNewItemSouldBeTheSame()
        {
            DbContext = new NewsDbContext();
            this.data = new NewsData(DbContext);

            var news = new NewsItem
            {
                Title = "Test",
                Content = "Test",
                PublishDate = DateTime.Now
            };

            this.data.News.Add(news);
            this.data.SaveChanges();

            Assert.AreEqual(news, this.data.News.All().OrderBy(n => n.Id).FirstOrDefault());
        }
        public void ModifyExistingNewsItemWithValidData()
        {
            DbContext = new NewsDbContext();
            this.data = new NewsData(DbContext);

            var news = new NewsItem
            {
                Title = "Tesaat",
                Content = "Testaa",
                PublishDate = DateTime.Now
            };

            this.data.News.Add(news);
            this.data.SaveChanges();

            news.Title = "New title";
            this.data.SaveChanges();

            var itemAfterChange = this.data.News.All().FirstOrDefault();

            Assert.AreEqual("New title", itemAfterChange.Title);
        }