public void OnlyAppliesToType_TimeSpan() { var cookies = new Mock<ICookieStorage>(); var binder = new TimeZoneInfoPropertyBinder(cookies.Object); var model = new TimeZoneRequestModel(); binder.Matches(model.GetType().GetProperty("TimeZoneInfo")).ShouldBeTrue(); binder.Matches(model.GetType().GetProperty("NotTimeZoneInfo")).ShouldBeFalse(); }
public void SetsPropertyFromCookieValue() { var cookies = new Mock<ICookieStorage>(); var binder = new TimeZoneInfoPropertyBinder(cookies.Object); var model = new TimeZoneRequestModel(); var context = new Mock<IBindingContext>(); cookies.Setup(x => x.Contains(UserAccount.TimeZoneCookieName)).Returns(true); cookies.Setup(x => x.Get(UserAccount.TimeZoneCookieName, false)).Returns("300"); context.SetupGet(x => x.Object).Returns(model); binder.Bind(model.GetType().GetProperty("TimeZoneInfo"), context.Object); model.TimeZoneInfo.TotalMinutes.ShouldEqual(300); }