コード例 #1
0
        public void Setup()
        {
            var optionsBuilder = new DbContextOptionsBuilder <PortFreightContext>()
                                 .UseInMemoryDatabase("InMemoryDb")
                                 .Options;

            var httpContext = new DefaultHttpContext();

            tempData = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>());

            var modelState = new ModelStateDictionary();

            actionContext = new ActionContext(httpContext, new RouteData(), new PageActionDescriptor(), modelState);
            var modelMetadataProvider = new EmptyModelMetadataProvider();

            viewData = new ViewDataDictionary(modelMetadataProvider, modelState);

            pageContext = new PageContext(actionContext)
            {
                ViewData = viewData
            };

            actualContext = new PortFreightContext(optionsBuilder);

            cargoPortValidateService = new CargoPortValidateService(null, helperService);
            helperService            = new HelperService(actualContext);
        }
        public CargoPortValidateServiceTest()
        {
            _helperService = new Mock <IHelperService>();
            var optionsBuilder = new DbContextOptionsBuilder <PortFreightContext>()
                                 .UseInMemoryDatabase("InMemoryDb")
                                 .Options;

            actualContext             = new PortFreightContext(optionsBuilder);
            _cargoPortValidateService = new CargoPortValidateService(actualContext, _helperService.Object);
        }