public void TestListInvoices()
 {
     InvoiceController ic = new InvoiceController();
     System.Web.Mvc.ViewResult result = ic.Index(null);
     Assert.IsNotNull(result.ViewData.Model);
     Assert.IsInstanceOf(typeof(IPagedList<Invoice>), result.ViewData.Model);
 }
        public void TestDeleteInvoice()
        {
            InvoiceController ic = new InvoiceController();
            System.Web.Mvc.ViewResult result = ic.Index(null);

            Invoice i = ((IPagedList<Invoice>)result.ViewData.Model).First();
            Assert.NotNull(i);

            //ask deletion action
            System.Web.Mvc.ActionResult invoiceAskDeletion = ic.Delete(i.InvoiceID);
            Assert.IsInstanceOf(typeof(System.Web.Mvc.ViewResult), invoiceAskDeletion);

            //delete action
            System.Web.Mvc.ActionResult invoiceDeletion = ic.DeleteConfirmed(i.InvoiceID);
            Assert.IsInstanceOf(typeof(System.Web.Mvc.RedirectToRouteResult), invoiceDeletion);
        }
        public void TestEditInvoice()
        {
            InvoiceController ic = new InvoiceController();
            System.Web.Mvc.ViewResult result = ic.Index(null);
            Invoice i = ((IPagedList<Invoice>)result.ViewData.Model).First();
            System.Web.Mvc.ActionResult invoiceEdition = ic.Edit(i.InvoiceID);

            //post edited
            i.Name = "Change invoice name test";

            //get
            System.Web.Mvc.ActionResult resultEditionView = ic.Edit(i.InvoiceID);
            Assert.IsInstanceOf(typeof(System.Web.Mvc.ViewResult), resultEditionView);

            //post
            System.Web.Mvc.ActionResult resultEdition = ic.Edit(i);
            Assert.IsInstanceOf(typeof(System.Web.Mvc.RedirectToRouteResult), resultEdition);
        }