コード例 #1
0
        public async void Validate_ViewModel_Duplicate()
        {
            var serviceProvider = GetServiceProvider();

            var service = new GarmentLeftoverWarehouseBuyerService(serviceProvider.Object, _dbContext(GetCurrentMethod()));

            serviceProvider.Setup(s => s.GetService(typeof(IGarmentLeftoverWarehouseBuyerService)))
            .Returns(service);

            var data = await _dataUtil(service).GetTestData();

            var viewModel = new GarmentLeftoverWarehouseBuyerViewModel
            {
                Code    = data.Code,
                Name    = data.Name,
                Address = data.Address,
                NPWP    = data.NPWP,
                WPName  = data.WPName
            };

            var validationContext = new ValidationContext(viewModel, serviceProvider.Object, null);

            var result = viewModel.Validate(validationContext);

            Assert.NotEmpty(result.ToList());
        }
コード例 #2
0
        public void Validate_ViewModel()
        {
            var serviceProvider = GetServiceProvider();

            var viewModel         = new GarmentLeftoverWarehouseBuyerViewModel();
            var validationContext = new ValidationContext(viewModel, serviceProvider.Object, null);

            var result = viewModel.Validate(validationContext);

            Assert.NotEmpty(result.ToList());
        }