Beispiel #1
0
        private static Dictionary <string, RuleContents> LoadRuleContents()
        {
            Dictionary <string, RuleContents> ruleContents = new Dictionary <string, RuleContents>();
            JObject o = JsonFileController.LoadJsonFile("assets\\基準30.json");

            foreach (var rule in o)
            {
                RuleContents r = new RuleContents(
                    rule.Value["Title"].ToString(),
                    rule.Value["NotFitText"].ToString(),
                    rule.Value["PassCondition"].ToString(),
                    (int)rule.Value["Class"]
                    );

                int number = 1;
                foreach (JObject sub in rule.Value["SubRuleList"])
                {
                    SubRuleContents content = new SubRuleContents(
                        sub["Description"].ToString(),
                        sub["DefaultAcceptText"].ToString(),
                        sub["DefaultFailText"].ToString(),
                        number);
                    r.SubRuleContentsList.Add(content);
                    number++;
                }
                ruleContents.Add(rule.Key, r);
            }
            return(ruleContents);
        }
Beispiel #2
0
        private void SaveFile(string file)
        {
            Console.WriteLine("[INFO] 儲存檔案 : " + file);
            JsonFileController json = new JsonFileController(file);

            json.SaveFile(CurrentSelectedTab.Report);
            CurrentSelectedTab.Report.CurrentOpenedFile = file;
            CurrentSelectedTab.Report.MarkAsSaved();
        }
Beispiel #3
0
        public void Initializer()
        {
            //New up everytime the test runs
            _mockContext            = new Mock <StoreContext>();
            _mockSetStoragePlace    = new Mock <DbSet <StoragePlace> >();
            _mockSetOrder           = new Mock <DbSet <Order> >();
            _mockSetCustomerAddress = new Mock <DbSet <CustomerAddress> >();
            _mockSetOrderProduct    = new Mock <DbSet <OrderProduct> >();
            _mockSetCustomer        = new Mock <DbSet <Customer> >();
            _mockSetAddress         = new Mock <DbSet <Address> >();

            //Add data
            var dataStoragePlace    = ResourceData.StoragePlaces.AsQueryable();
            var dataOrder           = ResourceData.Orders.AsQueryable();
            var dataCustomerAddress = ResourceData.CustomerAddresses.AsQueryable();
            var dataProduct         = ResourceData.OrderProducts.AsQueryable();
            var dataCustomer        = ResourceData.Customers.AsQueryable();
            var dataAddress         = ResourceData.Addresses.AsQueryable();

            //Setup behavior
            var setupDbSp = Helper.SetupDb(_mockSetStoragePlace, dataStoragePlace);
            var setupDbOr = Helper.SetupDb(_mockSetOrder, dataOrder);
            var setupDbCA = Helper.SetupDb(_mockSetCustomerAddress, dataCustomerAddress);
            var setupDbOP = Helper.SetupDb(_mockSetOrderProduct, dataProduct);
            var setupDbCu = Helper.SetupDb(_mockSetCustomer, dataCustomer);
            var setupDbAd = Helper.SetupDb(_mockSetAddress, dataAddress);


            _mockContext.Setup(x => x.StoragePlaces).Returns(setupDbSp.Object);
            _mockContext.Setup(x => x.Orders).Returns(setupDbOr.Object);
            _mockContext.Setup(x => x.CustomerAddresses).Returns(setupDbCA.Object);
            _mockContext.Setup(x => x.OrderProducts).Returns(setupDbOP.Object);
            _mockContext.Setup(x => x.Customers).Returns(setupDbCu.Object);
            _mockContext.Setup(x => x.Addresses).Returns(setupDbAd.Object);

            //This will make the mock version of the db approve any string given to the include method.
            //Without this you will get null reference exception when calling include.
            _mockSetStoragePlace.Setup(x => x.Include(It.IsAny <string>())).Returns(_mockSetStoragePlace.Object);
            _mockSetOrder.Setup(x => x.Include(It.IsAny <string>())).Returns(_mockSetOrder.Object);
            _mockSetCustomerAddress.Setup(x => x.Include(It.IsAny <string>())).Returns(_mockSetCustomerAddress.Object);
            _mockSetOrderProduct.Setup(x => x.Include(It.IsAny <string>())).Returns(_mockSetOrderProduct.Object);
            _mockSetCustomer.Setup(x => x.Include(It.IsAny <string>())).Returns(_mockSetCustomer.Object);
            _mockSetAddress.Setup(x => x.Include(It.IsAny <string>())).Returns(_mockSetAddress.Object);

            //Inject mock data via overload constructor
            var dbStoragePlaceRepository    = new DbStoragePlaceRepository(_mockContext.Object);
            var dbOrderRepository           = new DbOrderRepository(_mockContext.Object);
            var dbOrderProductRepository    = new DbOrderProductRepository(_mockContext.Object);
            var dbCustomerAddressRepository = new DbCustomerAddressRepository(_mockContext.Object);
            var dbProductRepository         = new DbProductRepository(_mockContext.Object);

            //Setup fakerepo via overloaded constructor
            _jsonFileController = new JsonFileController(dbStoragePlaceRepository, dbOrderRepository, dbOrderProductRepository, dbCustomerAddressRepository, dbProductRepository);
        }