private EmployeeVM CreateEmployeeVM( Action <IVMDependencyBuilder <EmployeeVM, EmployeeVMDescriptor> > dependencyConfigurationAction, ProjectVMDescriptor projectVMDescriptor = null ) { projectVMDescriptor = projectVMDescriptor ?? ProjectVM.CreateDescriptor(null, false); return(new EmployeeVM(dependencyConfigurationAction, projectVMDescriptor, true, Results, new RefreshControllerBehaviorMock())); }
public EmployeeVM( Action <IVMDependencyBuilder <EmployeeVM, EmployeeVMDescriptor> > dependencyConfigurationAction, ProjectVMDescriptor projectVMDescriptor, bool useMockBehaviors, ValidatorMockConfigurationFluent results, RefreshControllerBehaviorMock refreshControllerBehavior ) : base( CreateDescriptor( dependencyConfigurationAction, projectVMDescriptor, refreshControllerBehavior, useMockBehaviors ) ) { RefreshControllerBehaviorMock = refreshControllerBehavior; Results = results; }
private static EmployeeVMDescriptor CreateDescriptor( Action <IVMDependencyBuilder <EmployeeVM, EmployeeVMDescriptor> > dependencyConfigurationAction, ProjectVMDescriptor projectVMDescriptor, RefreshControllerBehaviorMock refreshControllerBehavior, bool useMockBehaviors ) { return(VMDescriptorBuilder .OfType <EmployeeVMDescriptor>() .For <EmployeeVM>() .WithProperties((d, c) => { var b = c.GetPropertyBuilder(); d.Name = b.Property.Of <string>(); d.Projects = b.Collection.Of <ProjectVM>(projectVMDescriptor); d.SelectedProject = b.VM.Of <ProjectVM>(); }) .WithValidators(b => { b.Check(x => x.Name) .Custom((args) => { if (args.Owner.InvalidateNameProperty) { args.AddError("Test triggered failure"); } }); b.Check(x => x.SelectedProject) .Custom(args => args.Owner.Results.PerformValidation(args)); }) .WithDependencies( dependencyConfigurationAction ) .WithBehaviors(b => { if (useMockBehaviors) { if (refreshControllerBehavior != null) { b.AddBehavior(refreshControllerBehavior); } } }) .Build()); }