当前位置: 首页>>代码示例>>C#>>正文


C# TestControllerBuilder.InitializeController方法代码示例

本文整理汇总了C#中TestControllerBuilder.InitializeController方法的典型用法代码示例。如果您正苦于以下问题:C# TestControllerBuilder.InitializeController方法的具体用法?C# TestControllerBuilder.InitializeController怎么用?C# TestControllerBuilder.InitializeController使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestControllerBuilder的用法示例。


在下文中一共展示了TestControllerBuilder.InitializeController方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: order_is_equal

        public void order_is_equal()
        {
            //Arrange
            TestControllerBuilder builder = new TestControllerBuilder();
            var controller = new OrderController(new OrderBLL(new OrderDALStub()));
            builder.InitializeController(controller);
            builder.HttpContext.Session["loggedInUser"] = new Customer() { admin = true };

            var order = new Order()
            {

                id = 298423,
                customerid = 1,
                orderdate = DateTime.Now
            };

            //Act 
            var actrow = (ViewResult)controller.ListOrders(null, null, null);
            var result = (IPagedList<OrderViewModel>)actrow.Model;

            //Assert
           Assert.AreEqual(actrow.ViewName, "" );
           Assert.AreEqual(result[0].id, order.id);
           Assert.AreEqual(result[0].customerid, order.customerid);


        }
开发者ID:forsen,项目名称:hioa_itpe3200_nettbutikk,代码行数:27,代码来源:OrderControllerTest.cs

示例2: GetControllerContext

        protected ControllerContext GetControllerContext()
        {
            var testHelper = new TestControllerBuilder();
            testHelper.InitializeController(controller);

            return controller.ControllerContext;
        }
开发者ID:roryf,项目名称:FluentMvc,代码行数:7,代码来源:ControllerContextBuilder.cs

示例3: AuthenticationControllerSpecSetUp

 public void AuthenticationControllerSpecSetUp()
 {
     AuthenticationServiceMock = new Mock<IAuthenticationService>();
     AuthenticationController = new AuthenticationController(BranchRepositoryMock.Object, AuthenticationServiceMock.Object);
     var testControllerBuilder = new TestControllerBuilder();
     testControllerBuilder.InitializeController(AuthenticationController);
 }
开发者ID:tamizhvendan,项目名称:gameo,代码行数:7,代码来源:AuthenticationControllerSpecBase.cs

示例4: GetController

 private TwitterSearchController GetController()
 {
     TestControllerBuilder builder = new TestControllerBuilder();
     TwitterSearchController controller = new TwitterSearchController();
     builder.InitializeController(controller);
     return controller;
 }
开发者ID:sconno05,项目名称:twitter-search,代码行数:7,代码来源:TwitterSearchControllerTests.cs

示例5: GET_Create_UsesCreateOutputModel

        public void GET_Create_UsesCreateOutputModel()
        {
            // Arrange

            var roleManager = new RoleManagerController();

            var builder = new TestControllerBuilder();

            builder.InitializeController(roleManager);

            roleManager.CreateOutputModel = new RoleManagerCreateOutputModel(
                );

            // act
            var result = roleManager.Create();

            // Assert
            Assert.IsInstanceOf<ViewResult>(result);

            var viewResult = result as ViewResult;

            var model = viewResult.ViewData.Model;

            Assert.IsInstanceOf<RoleManagerCreateOutputModel>(model);
        }
开发者ID:sharpoverride,项目名称:Booker,代码行数:25,代码来源:RoleManagerTests.cs

示例6: Delete_post_failed

        public void Delete_post_failed()
        {
            // Arrange
            var controller = new FileBrowserController();

            TestControllerBuilder builder = new TestControllerBuilder();
            builder.InitializeController(controller);
            builder.Form["Ident"] = "some_name";
            controller.MockUser("delete_ok");

            // Act
            // Act
            ActionResult createResult = controller.Upload(new HttpPostedFileMock("test.jpg", 40));
            // get first
            var createModel = createResult.AssertViewRendered().WithViewData<FileBrowserViewModel>();
            var item = createModel.UserFiles.First();
            item.Ident += "_not_exists";
            // delete first
            ActionResult result = controller.Delete(item);

            // Assert
            result.AssertViewRendered();

            Assert.IsFalse(controller.ModelState.IsValid);
        }
开发者ID:vlko,项目名称:vlko,代码行数:25,代码来源:FileBrowserControllerTest.cs

示例7: CacheIsAvailable

        public void CacheIsAvailable()
        {
            var builder = new TestControllerBuilder();

            Assert.IsNotNull(builder.HttpContext.Cache);

            var controller = new TestHelperController();
            builder.InitializeController(controller);

            Assert.IsNotNull(controller.HttpContext.Cache);

            string testKey = "TestKey";
            string testValue = "TestValue";

            controller.HttpContext.Cache.Add(testKey,
                                             testValue,
                                             null,
                                             DateTime.Now.AddSeconds(1),
                                             Cache.NoSlidingExpiration,
                                             CacheItemPriority.Normal,
                                             null);

            Assert.AreEqual(testValue,
                            controller.HttpContext.Cache[testKey]);
        }
开发者ID:serene,项目名称:MvcContrib,代码行数:25,代码来源:ControllerBuilderTests.cs

示例8: EndreBok_funnet

        public void EndreBok_funnet()
        {
            var SessionMock = new TestControllerBuilder();

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

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

            var innBok = new Boken()
            {
                ForfatterId = 100,
                SjangerId = 100,
                Tittel = "Isprinsessen",
                Pris = 399,
                Sjanger = "Krim",
                Forfatter = "Camilla Läckberg"
            };
            // Act
            var actionResultat = (RedirectToRouteResult)controller.EndreBok(1, innBok);

            // Assert
            Assert.AreEqual(actionResultat.RouteName, "");
            Assert.AreEqual(actionResultat.RouteValues.Values.First(), "hentAlleBoker");
        }
开发者ID:kariannelokke,项目名称:Bokhandel,代码行数:25,代码来源:AdminTestController.cs

示例9: Detaljer_Ok_get

        public void Detaljer_Ok_get()
        {
            //Arrange
            var controller = new SkoAdminController(new SkoBLL(new DbSkoStub()), new AttributtBLL(new DbAttributterStub()));
            var SessionMock = new TestControllerBuilder();
            SessionMock.InitializeController(controller);
            controller.Session["AdminLoggetInn"] = true;
            var forventetResultat = new Skoen
            {
                skoId = 1,
                navn = "B&CO 2455100311",
                beskrivelse = "Tøff B&CO damesko med lisser. Skoen er i tekstil med små metall nitter. Den har sort kantbånd rundt lisser stykket og langs kanten. Skoen er sort med brune flammer. Den har canvas dekksåle og canvas fôr. Gummisålen er tofarget hvit og sort.",
                merke = "B&CO",
                farge = "Sort",
                forHvem = "Dame",
                kategori = "Sko",
                pris = 499.00M,
                storlekar = new List<Storlek>
                        {
                            new Storlek { storlekId = 1, storlek = 36, antall = 10 },
                            new Storlek { storlekId = 2, storlek = 37, antall = 11 },
                            new Storlek { storlekId = 3, storlek = 38, antall = 12 },
                            new Storlek { storlekId = 4, storlek = 39, antall = 13 },
                            new Storlek { storlekId = 5, storlek = 40, antall = 14 },
                            new Storlek { storlekId = 6, storlek = 41, antall = 15 }
                        },
                bilder = new List<Bilde>
                        {
                            new Bilde { bildeId = 1, bildeUrl = "bilde1.jpg" },
                            new Bilde { bildeId = 2, bildeUrl = "bilde2.jpg" },
                            new Bilde { bildeId = 3, bildeUrl = "bilde3.jpg" },
                        }
            };

            //Act
            var resultat = (ViewResult)controller.Detaljer(1);
            var resultatListe = (Skoen)resultat.Model;

            //Assert
            Assert.AreEqual(resultat.ViewName, "");
            Assert.AreEqual(forventetResultat.skoId, resultatListe.skoId);
            Assert.AreEqual(forventetResultat.navn, resultatListe.navn);
            Assert.AreEqual(forventetResultat.merke, resultatListe.merke);
            Assert.AreEqual(forventetResultat.forHvem, resultatListe.forHvem);
            Assert.AreEqual(forventetResultat.kategori, resultatListe.kategori);
            Assert.AreEqual(forventetResultat.farge, resultatListe.farge);
            Assert.AreEqual(forventetResultat.beskrivelse, resultatListe.beskrivelse);
            Assert.AreEqual(forventetResultat.pris, resultatListe.pris);
            for (var i = 0; i < resultatListe.bilder.Count; ++i) {
                Assert.AreEqual(forventetResultat.bilder[i].bildeId, resultatListe.bilder[i].bildeId);
                Assert.AreEqual(forventetResultat.bilder[i].bildeUrl, resultatListe.bilder[i].bildeUrl);
            }
            for (var i = 0; i < resultatListe.storlekar.Count; ++i)
            {
                Assert.AreEqual(forventetResultat.storlekar[i].storlekId, resultatListe.storlekar[i].storlekId);
                Assert.AreEqual(forventetResultat.storlekar[i].storlek, resultatListe.storlekar[i].storlek);
                Assert.AreEqual(forventetResultat.storlekar[i].antall, resultatListe.storlekar[i].antall);
            }
        }
开发者ID:s165519,项目名称:Webapplikasjoner,代码行数:59,代码来源:SkoAdminControllerTest.cs

示例10: CanSpecifySessionVariables

 public void CanSpecifySessionVariables()
 {
     var builder = new TestControllerBuilder();
     builder.Session["Variable"] = "Value";
     var testHelperController = new TestHelperController();
     builder.InitializeController(testHelperController);
     Assert.AreEqual("Value", testHelperController.HttpContext.Session["Variable"]);
 }
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:8,代码来源:SessionTests.cs

示例11: AdminControllerTest

 public AdminControllerTest()
 {
     _session = new TestControllerBuilder();
     _ctrl = new AdminController(new AdminBLL(new AdminDALStub(), new KundeDALStub()), new KundeBLL(new KundeDALStub()), new ProduktBLL(new ProduktDALStub()));
     // initierer sessionvariablen for innlogging for alle metoder
     // feilaktig innlogging blir testet ved testing av innloggingsmetoden
     _session.InitializeController(_ctrl);
     _ctrl.Session["Admin"] = (bool)true;
 }
开发者ID:msteenhoff,项目名称:MVCWebShop,代码行数:9,代码来源:AdminControllerTest.cs

示例12: setup

 public void setup()
 {
     mocks = new MockRepository();
     builder = new TestControllerBuilder();
     session = mocks.DynamicMock<ISession>();
     todoRepository = mocks.StrictMock<TodoRepository>(session);
     todoController = new TodoController(todoRepository);
     builder.InitializeController(todoController);
 }
开发者ID:gkeary,项目名称:myGetOrg,代码行数:9,代码来源:TodoControllerTest.cs

示例13: SetUp

        public void SetUp()
        {
            builder = new TestControllerBuilder();
            serverService = new Mock<IServerService>();

            controller = new ServerController { ServerService = serverService.Object };

            builder.InitializeController(controller);
        }
开发者ID:phil-b-higgins,项目名称:jenkins.net,代码行数:9,代码来源:ServerControllerTest.cs

示例14: ShouldSetHitsOnSession

        public void ShouldSetHitsOnSession()
        {
            var builder = new TestControllerBuilder();
            var controller = new SessionController();
            builder.InitializeController(controller);

            controller.Index();
            Assert.IsNotNull(controller.Session["hits"]);
        }
开发者ID:rgan,项目名称:configstore,代码行数:9,代码来源:SessionControllerTest.cs

示例15: LeaveRequestControllerTest

        public void LeaveRequestControllerTest()
        {
            LeaveController leave = new LeaveController();
            TestControllerBuilder builder = new TestControllerBuilder();
            builder.InitializeController(leave);

            //leave.Session["blabla"] = 1234;

            Assert.AreEqual(true, true);
        }
开发者ID:buhaibogdan,项目名称:HR_Management,代码行数:10,代码来源:SessionPersisterTests.cs


注:本文中的TestControllerBuilder.InitializeController方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。