public void CanEditBlog() { var mockedBlogRepo = new Mock<IBlogPostRepository>(); var mockedProjectRepo = new Mock<IPortfolioProjectRepository>(); var blogPost = new BlogPost { Id = 1, Date = new DateTime(2012, 1, 1), RouteName = "sample-post", Text = "This is a sample", Title = "Sample Post" }; mockedBlogRepo.Setup(m => m.GetBlogPost(1)).Returns(blogPost); var target = new AdminController(mockedBlogRepo.Object, mockedProjectRepo.Object); var result = (AdminBlogFull)target.AddOrEditBlogPost(1).ViewData.Model; Assert.AreEqual(result.Title, "Sample Post"); }
public void CanSaveValidPortfolioChanges() { var mockedBlog = new Mock<IBlogPostRepository>(); var mockedPortfolio = new Mock<IPortfolioProjectRepository>(); var target = new AdminController(mockedBlog.Object, mockedPortfolio.Object); var project = new AdminPortfolioFull { Id = 3, Name = "A New Project", Description = "desc", ImgUrl = "/Content", LinkUrl = "www.sample.com", Technologies = "C#, Java" }; var sameProject = new PortfolioProject { Id = 3, Name = "A New Project", Description = "desc", ImgUrl = "/Content", LinkUrl = "www.sample.com", Technologies = "C#, Java" }; //mockedPortfolio.Setup(m => m.SavePortfolioProject(sameProject)).Returns(sameProject); var result = target.AddOrEditPortfolio(project); portfolioMock.Verify(m => m.SavePortfolioProject(sameProject)); Assert.IsInstanceOfType(result, typeof (RedirectResult)); }
public void CanEditPortfolio() { var mockedBlogRepo = new Mock<IBlogPostRepository>(); var mockedPortfolioRepo = new Mock<IPortfolioProjectRepository>(); mockedPortfolioRepo.Setup(m => m.GetPortfolioProject(1)).Returns(new PortfolioProject { Id = 1, Name = "FutureCodr", Description = "sample desc", Technologies = "ASP.NET, Javascript", ImgUrl = "/Content", LinkUrl = "futurecodr.com" }); var target = new AdminController(mockedBlogRepo.Object, mockedPortfolioRepo.Object); var result = (AdminPortfolioFull)target.AddOrEditPortfolio(1).ViewData.Model; Assert.AreEqual(result.Name, "FutureCodr"); }