private void Test(object rawValue, Type currentType, bool expectedResult, DateTime?expectedModel) { DateTimeFromUnixTimeStampBinder binder = new DateTimeFromUnixTimeStampBinder(); IValueProvider valueProvider = MockRepository.GenerateStub <IValueProvider>(); ValueProviderResult valueResult = new ValueProviderResult(rawValue, rawValue.ToString(), CultureInfo.CurrentCulture); DataAnnotationsModelMetadataProvider metadataProvider = new DataAnnotationsModelMetadataProvider(); valueProvider.Stub(s => s.GetValue(Arg <string> .Is.Anything)).Return(valueResult); ModelBindingContext context = new ModelBindingContext { ValueProvider = valueProvider, ModelMetadata = metadataProvider.GetMetadataForType(null, currentType) }; bool result = binder.BindModel(null, context); Assert.AreEqual(result, expectedResult); Assert.AreEqual(expectedModel, context.Model); }
public void SetUp() { _stub = MockRepository.GenerateStub<ISomeInterface>(); _stubValueProvider = MockRepository.GenerateStub<IValueProvider<int>>(); _stubValueProvider.Stub(x => x.Next()).Return(ExpectedReturnValue); }