コード例 #1
0
ファイル: RecipeControllerTests.cs プロジェクト: eriobe/mvc2
        public void FullDetailsReturnsViewAndModel()
        {
            roTest.GetRecipe(0).Returns(new RecipeDetailsModel
            {
                Name    = "Test Beer",
                Summary = "Tasty!"
            });
            //skapar ett objekt av controllern
            // var sut = new ReceipeController();

            //castar (nästan) objektet till kontrollermetoden
            var result = sut.FullDetails(1) as ViewResult;
            var model  = result.Model as RecipeDetailsModel;

            //Assert.AreEqual(testModel.Name, model.Name, "Namnen stämmer");
            Assert.IsNotNull(result, "Got a ViewResult");
            Assert.IsNotNull(model.Summary, "har en sammanfattning");
            Assert.IsNotNull(model.Ingredients, "har en sammanfattning");
        }