using System; using System.Configuration; using System.IO; using System.Linq; using System.Reflection; using Blog.DAL.Infrastructure; using Blog.DAL.Model; using Blog.DAL.Repository; using System.Diagnostics; using TDD.DbTestHelpers.Yaml; using TDD.DbTestHelpers.Core; using NUnit.Framework; namespace Blog.DAL.Tests { [TestFixture] public class RepositoryTests// : DbBaseTest { [Test] public void GetAllPost_OnePostInDb_ReturnTwoPosts() { // arrange var context = new BlogContext(); context.Database.CreateIfNotExists(); var repository = new BlogRepository(); context.Posts.ToList().ForEach(x => context.Posts.Remove(x)); context.Posts.Add(new Post { Author = "me", Content = "lorem ipsum" }); context.SaveChanges(); // act var result = repository.GetAllPosts(); // assert Assert.AreEqual(1, result.Count()); } [Test] public void AddInvalidPost_TwoPostsInDb_ReturnThreePosts() { // arrange var context = new BlogContext(); context.Database.CreateIfNotExists(); var repository = new BlogRepository(); // act Assert.Throws(() => { repository.add(new Post { Author = null, Content = "lorem ipsum" }); }); } } }