public void list_returns_system_templates()
 {
     var mockSer = new Mock<ITemplateService>();
     mockSer.Expect(s => s.Get()).Returns(new List<Template>
                                      {
                                          new Template(),
                                          new Template()
                                      });
     var con = new TemplateController(mockSer.Object);
     var result = con.List(null);
     Assert.IsNotNull(result);
     result.AssertViewResult(con, null, "list");
     Assert.IsInstanceOfType(typeof(IList<Template>), con.ViewData.Model);
     Assert.AreEqual(2, (con.ViewData.Model as IList<Template>).Count);
 }
        public void save_saves_user_template()
        {
            var template = new Template();
            var username = "******";
            var mockSer = new Mock<ITemplateService>();
            mockSer.Expect(s => s.Save(username, "name", "content")).Returns(1);
            var con = new TemplateController(mockSer.Object);
            con.SetFakeControllerContext();

            var result = con.Save("name", "content");

            mockSer.VerifyAll();
            Assert.IsInstanceOfType(typeof(JsonResult), result);
            var jsonResult = result as JsonResult;
            Assert.IsInstanceOfType(typeof(JsonData), jsonResult.Data);
            Assert.IsTrue(((JsonData)jsonResult.Data).success);
            Assert.AreEqual(1, ((JsonData)jsonResult.Data).id);
        }