本文整理汇总了C#中TestControllerBuilder类的典型用法代码示例。如果您正苦于以下问题:C# TestControllerBuilder类的具体用法?C# TestControllerBuilder怎么用?C# TestControllerBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestControllerBuilder类属于命名空间,在下文中一共展示了TestControllerBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: Setup
public void Setup()
{
this._builder = new TestControllerBuilder();
this._runtimeSession = MockRepository.GenerateMock<IRuntimeSession>();
this._bragRepository = MockRepository.GenerateMock<IRepository<IBrag>>();
this._controller = _builder.CreateController<HomeController>(this._runtimeSession, this._bragRepository);
}
开发者ID:spidermoore,项目名称:peerconnect,代码行数:7,代码来源:HomeControllerTests.cs
示例3: GetController
private TwitterSearchController GetController()
{
TestControllerBuilder builder = new TestControllerBuilder();
TwitterSearchController controller = new TwitterSearchController();
builder.InitializeController(controller);
return controller;
}
开发者ID:sconno05,项目名称:twitter-search,代码行数:7,代码来源:TwitterSearchControllerTests.cs
示例4: TestControllerBuilder
public static TestControllerBuilder TestControllerBuilder(ControllerCustomization customization = ControllerCustomization.None)
{
if (!TestControllerBuilders.ContainsKey(customization))
{
var testControllerBuilder = new TestControllerBuilder();
switch (customization)
{
case ControllerCustomization.ForUrlHelper:
testControllerBuilder.HttpContext.Response
.Stub(x => x.ApplyAppPathModifier(null))
.IgnoreArguments().Do(new Func<string, string>(s => s))
.Repeat.Any();
break;
}
TestControllerBuilders.Add(customization, testControllerBuilder);
}
var builder = TestControllerBuilders[customization];
builder.HttpContext.User = null;
builder.RouteData.DataTokens.Remove("ParentActionViewContext");
return builder;
}
开发者ID:saibalghosh,项目名称:UCosmic,代码行数:27,代码来源:ReuseMock.cs
示例5: 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
示例6: 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
示例7: 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
示例8: 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
示例9: Setup
public void Setup()
{
this._builder = new TestControllerBuilder();
this._repository = MockRepository.GenerateMock<IRepository<IUser>>();
this._runtimeSession = MockRepository.GenerateMock<IRuntimeSession>();
this._sut = _builder.CreateController<SessionController>(this._runtimeSession, this._repository);
}
开发者ID:WpgDotNetUG,项目名称:peerconnect,代码行数:7,代码来源:SessionControllerTests.cs
示例10: 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
示例11: Setup
public void Setup()
{
var tcb = new TestControllerBuilder();
context = new AuthorizationContext {HttpContext = tcb.HttpContext};
appSettings = MockRepository.GenerateStub<IAppSettings>();
filter = new EnsureSsl(appSettings);
}
开发者ID:sthapa123,项目名称:sutekishop,代码行数:7,代码来源:EnsureSslFilterTester.cs
示例12: GetControllerContext
protected ControllerContext GetControllerContext()
{
var testHelper = new TestControllerBuilder();
testHelper.InitializeController(controller);
return controller.ControllerContext;
}
开发者ID:roryf,项目名称:FluentMvc,代码行数:7,代码来源:ControllerContextBuilder.cs
示例13: 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
示例14: AddShouldAddObject
public void AddShouldAddObject()
{
var builder = new TestControllerBuilder();
builder.Session["Variable1"] = "Value1";
builder.Session.Add("Variable2", "Value2");
Assert.AreEqual("Value1", builder.Session["Variable1"]);
Assert.AreEqual("Value2", builder.Session["Variable2"]);
}
开发者ID:JonKruger,项目名称:MvcContrib,代码行数:8,代码来源:SessionTests.cs
示例15: 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
示例16: GetUrl
private string GetUrl(string routeName) {
new RouteConfigurator().RegisterRoutes(() => { });
var builder = new TestControllerBuilder();
var context = new RequestContext(builder.HttpContext, new RouteData());
context.HttpContext.Response.Expect(x => x.ApplyAppPathModifier(null)).IgnoreArguments().Do(new Func<string, string>(s => s)).Repeat.Any();
var urlhelper = new UrlHelper(context);
return urlhelper.RouteUrl(routeName, new { sessionKey = "this-is-the-session", conferenceKey = "austincodecamp" });
}
开发者ID:sthapa123,项目名称:codecampserver,代码行数:8,代码来源:UrlGenerationTester.cs
示例17: 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
示例18: 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
示例19: 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
示例20: 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
注:本文中的TestControllerBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论