public void Setup() { mapper = MockRepository.GenerateStub <IMapper>(); config = MockRepository.GenerateStub <IYuzuConfiguration>(); mapperAddItems = new List <IMapperAddItem>(); svc = MockRepository.GeneratePartialMock <YuzuDefinitionTemplates>(new object[] { mapper, config, mapperAddItems.ToArray() }); settings = new RenderSettings(); config.GetRenderedHtmlCache = null; config.SetRenderedHtmlCache = null; templates = new Dictionary <string, Func <object, string> >(); templateName = "template"; templateRenderer = (object data) => { return(html); }; config.GetTemplatesCache = () => { return(templates); }; exampleModel = new ExampleModel() { Text = "text" }; exampleViewModel = new vmPage_ExampleViewModel(); inputMappingItems = new Dictionary <string, object>(); Func <object, IDictionary <string, object>, vmPage_ExampleViewModel> doFunction = (object source, IDictionary <string, object> items) => { usedMappingItems = items; return(exampleViewModel); }; mapper.Stub(x => x.Map <vmPage_ExampleViewModel>(null, null)).IgnoreArguments().Do(doFunction); Mapper.Reset(); }
public void Setup() { mapper = new Moq.Mock <IMapper>(); config = new Moq.Mock <IYuzuConfiguration>().SetupAllProperties(); typeFactoryRunner = new Moq.Mock <IYuzuTypeFactoryRunner>(); mapperAddItems = new List <IMapperAddItem>(); svc = new Moq.Mock <YuzuDefinitionTemplates>(MockBehavior.Loose, mapper.Object, config.Object, mapperAddItems.ToArray(), typeFactoryRunner.Object) { CallBase = true }; settings = new RenderSettings(); config.Object.GetRenderedHtmlCache = null; config.Object.SetRenderedHtmlCache = null; templates = new Dictionary <string, Func <object, string> >(); templateName = "template"; templateRenderer = (object data) => { return(html); }; config.Object.GetTemplatesCache = () => { return(templates); }; exampleModel = new ExampleModel() { Text = "text" }; exampleViewModel = new vmPage_ExampleViewModel(); inputMappingItems = new Dictionary <string, object>(); Func <object, IDictionary <string, object>, vmPage_ExampleViewModel> doFunction = (object source, IDictionary <string, object> items) => { usedMappingItems = items; return(exampleViewModel); }; mapper.Setup(x => x.Map <vmPage_ExampleViewModel>(It.IsAny <object>(), It.IsAny <IDictionary <string, object> >())).Returns(doFunction); Mapper.Reset(); }