public void Validate_ViewModel() { var serviceProvider = GetServiceProvider(); var viewModel = new GarmentForwarderViewModel(); var validationContext = new ValidationContext(viewModel, serviceProvider.Object, null); var result = viewModel.Validate(validationContext); Assert.NotEmpty(result.ToList()); }
public async void Validate_ViewModel_Duplicate() { var serviceProvider = GetServiceProvider(); var service = new GarmentForwarderService(serviceProvider.Object, _dbContext(GetCurrentMethod())); serviceProvider.Setup(s => s.GetService(typeof(IGarmentForwarderService))) .Returns(service); var data = await _dataUtil(service).GetTestData(); var viewModel = new GarmentForwarderViewModel { Code = data.Code, Name = data.Name }; var validationContext = new ValidationContext(viewModel, serviceProvider.Object, null); var result = viewModel.Validate(validationContext); Assert.NotEmpty(result.ToList()); }