本文整理汇总了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);
}
示例2: GetControllerContext
protected ControllerContext GetControllerContext()
{
var testHelper = new TestControllerBuilder();
testHelper.InitializeController(controller);
return controller.ControllerContext;
}
示例3: AuthenticationControllerSpecSetUp
public void AuthenticationControllerSpecSetUp()
{
AuthenticationServiceMock = new Mock<IAuthenticationService>();
AuthenticationController = new AuthenticationController(BranchRepositoryMock.Object, AuthenticationServiceMock.Object);
var testControllerBuilder = new TestControllerBuilder();
testControllerBuilder.InitializeController(AuthenticationController);
}
示例4: GetController
private TwitterSearchController GetController()
{
TestControllerBuilder builder = new TestControllerBuilder();
TwitterSearchController controller = new TwitterSearchController();
builder.InitializeController(controller);
return controller;
}
示例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);
}
示例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);
}
示例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]);
}
示例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");
}
示例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);
}
}
示例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"]);
}
示例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;
}
示例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);
}
示例13: SetUp
public void SetUp()
{
builder = new TestControllerBuilder();
serverService = new Mock<IServerService>();
controller = new ServerController { ServerService = serverService.Object };
builder.InitializeController(controller);
}
示例14: ShouldSetHitsOnSession
public void ShouldSetHitsOnSession()
{
var builder = new TestControllerBuilder();
var controller = new SessionController();
builder.InitializeController(controller);
controller.Index();
Assert.IsNotNull(controller.Session["hits"]);
}
示例15: LeaveRequestControllerTest
public void LeaveRequestControllerTest()
{
LeaveController leave = new LeaveController();
TestControllerBuilder builder = new TestControllerBuilder();
builder.InitializeController(leave);
//leave.Session["blabla"] = 1234;
Assert.AreEqual(true, true);
}