public void OnlyAppliesToType_HttpContextBase() { var binder = new HttpContextPropertyBinder(); var model = new HttpContextRequestModel(); binder.Matches(model.GetType().GetProperty("HttpContext")).ShouldBeTrue(); binder.Matches(model.GetType().GetProperty("NotHttpContext")).ShouldBeFalse(); }
public void SetsPropertyFromContextOnModel() { var binder = new HttpContextPropertyBinder(); var model = new HttpContextRequestModel(); var context = new Mock<IBindingContext>(); var httpContext = new Mock<HttpContextBase>().Object; context.Setup(x => x.Service<HttpContextBase>()).Returns(httpContext); context.SetupGet(x => x.Object).Returns(model); binder.Bind(model.GetType().GetProperty("HttpContext"), context.Object); model.HttpContext.ShouldEqual(httpContext); }