ProductUnitTest.cs


Dosyayı İndir
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using AspMvcTestable.Controllers;
using System.Web.Mvc;

namespace AspMvcTestable.Tests.Controllers
{
    [TestClass]
    public class ProductUnitTest
    {
        [TestMethod]
        public void TestProductNotFound()
        {
            ProductController controller = new ProductController();
            ActionResult result=controller.Details(-4);
            Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult));
        }
        [TestMethod]
        public void TestProductFound()
        {
            ProductController controller = new ProductController();
 
            ViewResult result = controller.Details(3) as ViewResult;
            Product product = (Product)result.Model;
            Assert.AreEqual(product.ProductName,"Disk Çalar"); 
        }
        [TestMethod]
        public void TestProductCreate()
        {
            ProductController controller = new ProductController();
            Product product = new Product();
            product.ProductName = "Ürün Adı";
            product.SalesPrice = 1243;
            ActionResult result = controller.Create(product);
            Assert.AreEqual(false,controller.ModelState.IsValid);
        }
    }
}

				
Dosyayı İndir

Bu Sayfayı Paylaş:




Bu Sayfayı Paylaş:

İletişim Bilgileri

Takip Et

Her Hakkı Saklıdır. Bu sitede yayınlanan tüm bilgi ve fikirlerin kullanımından fibiler.com sorumlu değildir. Bu sitede üretilmiş , derlenmiş içerikleri, fibiler.com'u kaynak göstermek koşuluyla kendi sitenizde kullanılabilirsiniz. Ancak telif hakkı olan içeriklerin hakları sahiplerine aittir