コード例 #1
0
        public void VisOrdre_vis_View()
        {
            var SessionMock = new TestControllerBuilder();

            var controller = new AdminController(new AdminBLL(new AdminRepositoryStub()));

            SessionMock.InitializeController(controller);
            controller.Session["AdminLoggetInn"] = true;

            var forventetResultat = new List<Bestilling>();
            var ordre = new Bestilling()
            {
                BestillingsID = 100,
                KundeId = "sofia",
                BestillingsDato = new DateTime(2015, 11, 04, 08, 00, 00),
                Total = 10,
            };

            forventetResultat.Add(ordre);
            forventetResultat.Add(ordre);
            forventetResultat.Add(ordre);

            //act
            var actionResult = (ViewResult)controller.VisOrdre(1);
            var resultat = (List<Bestilling>)actionResult.Model;

            //assert

            Assert.AreEqual(actionResult.ViewName, "");

            for (var i = 0; i < resultat.Count; i++)
            {
                Assert.AreEqual(forventetResultat[i].BestillingsID, resultat[i].BestillingsID);
                Assert.AreEqual(forventetResultat[i].KundeId, resultat[i].KundeId);
                Assert.AreEqual(forventetResultat[i].BestillingsDato, resultat[i].BestillingsDato);
                Assert.AreEqual(forventetResultat[i].Total, resultat[i].Total);
            }
        }
コード例 #2
0
        public Bestilling hentAlleOrdreDetaljer(int id)
        {
            if (id == 0)
            {
                var bestilling = new Bestilling();
                bestilling.BestillingsID = 0;
                return bestilling;
            }
            else
            {
                var bestilling = new Bestilling()
                {
                    BestillingsID = 100,
                    KundeId = "sofia",
                    BestillingsDato = new DateTime(2015, 11, 04, 08, 00, 00),
                    Total = 0,

                };
                return bestilling;
            }
        }
コード例 #3
0
        public void VisOrdreDetaljer()
        {
            var SessionMock = new TestControllerBuilder();

            var controller = new AdminController(new AdminBLL(new AdminRepositoryStub()));

            SessionMock.InitializeController(controller);
            controller.Session["AdminLoggetInn"] = true;

            var forventetResultat = new Bestilling()
            {
                BestillingsID = 100,
                KundeId = "sofia",
                BestillingsDato = new DateTime(2015, 11, 04, 08, 00, 00),
                Total = 0,
            };
            // Act
            var actionResult = (ViewResult)controller.VisOrdreDetaljer(1);
            var resultat = (Bestilling)actionResult.Model;

            // Assert
            Assert.AreEqual(actionResult.ViewName, "");
            Assert.AreEqual(forventetResultat.BestillingsID, resultat.BestillingsID);
            Assert.AreEqual(forventetResultat.KundeId, resultat.KundeId);
            Assert.AreEqual(forventetResultat.BestillingsDato, resultat.BestillingsDato);
            Assert.AreEqual(forventetResultat.Total, resultat.Total);
        }
コード例 #4
0
        public List<Bestilling> hentAlleOrdre(int id)
        {
            if (id == 0)
            {
                var ordreListe = new List<Bestilling>();
                var ordre = new Bestilling();
                ordre.BestillingsID = 0;
                ordreListe.Add(ordre);
                return ordreListe;

            }
            else
            {
                var ordreListe = new List<Bestilling>();
                var ordre = new Bestilling()
                {
                    BestillingsID = 100,
                    KundeId = "sofia",
                    BestillingsDato = new DateTime(2015, 11, 04, 08, 00, 00),
                    Total = 10,
                };

                ordreListe.Add(ordre);
                ordreListe.Add(ordre);
                ordreListe.Add(ordre);
                return ordreListe;
            }
        }