public void Validate_When_Id_Empty() { GarmentWeeklyPlanViewModel viewModel = new GarmentWeeklyPlanViewModel() { Unit = new UnitViewModel() { Id = 1, } }; Dictionary <string, string> order = new Dictionary <string, string>(); var data = new List <GarmentWeeklyPlan>() { new GarmentWeeklyPlan() }; ReadResponse <GarmentWeeklyPlan> response = new ReadResponse <GarmentWeeklyPlan>(data, 1, order, new List <string>()); Mock <IWeeklyPlanFacade> facade = new Mock <IWeeklyPlanFacade>(); facade .Setup(s => s.Read(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <List <string> >(), It.IsAny <string>(), It.IsAny <string>())) .Returns(response); Mock <IServiceProvider> servicesProvider = new Mock <IServiceProvider>(); servicesProvider .Setup(s => s.GetService(typeof(IWeeklyPlanFacade))) .Returns(facade.Object); ValidationContext valContext = new ValidationContext(viewModel, servicesProvider.Object, null); var result = viewModel.Validate(valContext); Assert.True(result.Count() > 0); }
public void ValidateDefault() { GarmentWeeklyPlanViewModel viewModel = new GarmentWeeklyPlanViewModel(); var result = viewModel.Validate(null); Assert.True(result.Count() > 0); }