MvcContrib
第5章
MvcContrib Grid 同拉动进度的公文及充满的利用
MVcContrib是社区开源之asp.net
mvc增强同扩充库,如中的Grid,即可快速之展开统筹以只是灵活的支配表的布局[比Web
Form 的GridView简化了成千上万]
以Codeplex.com上足找到该种,上面有文档,特别对Grid有详实的事例参考,如下图
例子在MVCContrib.Extras.release.zip中
以下是扶助[在MVCContrib.release.zip中]
测试
当出多单零件协作时,接口就定义好的景况,如果某个因组件如A还未曾兑现,此时要只要拓展依赖让A的次序的测试,此时得以用测试桩来法;另外为了减小组件对于其余资源的乘,如某组件依赖数据库同时还亟需相关的安装等,此时经过测试桩的办法可减去因的错综复杂。
一个可用的开源库是Rhino Mocks。
A favorite library for automating the creation of mocks and stubs is
Rhino Mocks written by Oren Eini
(www.ayende.com/projects/rhino-mocks.aspx).
[Test]
public void CacheTest()
{
//setup controller w/ fake cache
var fakeCache = MockRepository.GenerateStub<ICache>();
var controller = new HomeController(fakeCache);
//set the cache behavior
fakeCache.Stub(x => x.Exists("test")).Return(false);
//invoke the action
controller.CacheTest();
//the item should have been added to the cache
fakeCache.AssertWasCalled(x => x.Add("test", "value"));
//the item should be retrieved from the cache
fakeCache.AssertWasCalled(x => x.Get<string>("test"));
}
[Test]
public void SessionTest()
{
var controller = new HomeController();
//setup fake session
var httpContext = MockRepository.GenerateStub<HttpContextBase>();
var mockSession = MockRepository.GenerateStub<HttpSessionStateBase>();
httpContext.Stub(x => x.Session).Return(mockSession).Repeat.Any();
//attach fake context/session to controller
controller.ControllerContext = new ControllerContext(httpContext, new RouteData(), controller);
//invoke action
controller.ViewCart();
//verify methods were called
mockSession.VerifyAllExpectations();
}
其他
MS Press的书Programming Microsoft ASP.NET
MVC2,涉及的十分完善,详细讲解了拖欠框架的向上历史及实现分析。
特别是内的例证发展历史ProgMvc-Samples.zip,具体体现了事关拖欠框架的各个方面的壮大、定制及以等诸方面,具体参考每个工程下之todo.txt说明。