public void CountShouldRemainTheSameWhenNoBugsAreAdded()
 {
     var repository = new BugLoggingSystemRepository<Bug>(new BugLoggingSystemDbContext());
     int previousBugsCount = repository.All().Count();
     int bugsCount = repository.All().Count();
     Assert.AreEqual(previousBugsCount, bugsCount);
 }
        public void AddShouldWriteData()
        {
            var repository = new BugLoggingSystemRepository<Bug>(new BugLoggingSystemDbContext());
            int previousBugsCount = repository.All().Count();
            repository.Add(new Bug
            {
                Text = "pesho",
                LogDate = DateTime.Now
            });

            repository.SaveChanges();
            int bugsCount = repository.All().Count();
            Assert.AreEqual(previousBugsCount + 1, bugsCount);
        }
        public void DeleteEntityShouldRemoveData()
        {
            var repository = new BugLoggingSystemRepository<Bug>(new BugLoggingSystemDbContext());
            int previousBugsCount = repository.All().Count();
            var bug = new Bug
            {
                Id = Guid.NewGuid(),
                Text = "pesho",
                LogDate = DateTime.Now
            };

            repository.Add(bug);
            repository.SaveChanges();
            int bugsCount = repository.All().Count();

            Assert.AreEqual(previousBugsCount + 1, bugsCount);

            repository.Delete(bug);
            repository.SaveChanges();
            bugsCount = repository.All().Count();

            Assert.AreEqual(previousBugsCount, bugsCount);
        }
        public void UpdateShouldChangeEntity()
        {
            var repository = new BugLoggingSystemRepository<Bug>(new BugLoggingSystemDbContext());
            int previousBugsCount = repository.All().Count();
            var bug = new Bug
            {
                Id = Guid.NewGuid(),
                Text = "pesho",
                LogDate = DateTime.Now
            };

            repository.Add(bug);
            repository.SaveChanges();
            int bugsCount = repository.All().Count();

            Assert.AreEqual(previousBugsCount + 1, bugsCount);

            bug.Text = "gosho";
            repository.Update(bug);
            repository.SaveChanges();

            Bug foundBug = repository.FindById(bug.Id.ToString());
            Assert.AreEqual("gosho", foundBug.Text);
        }