Esempio n. 1
0
        public void ManipulateProjectData()
        {
            //假定已经成功读取到数据文件中的数据
            //测试组织项目数据的类是否可以正常工作
            List <LoopModel> lstLoop = new List <LoopModel>();

            lstLoop.Add(new TestAssistant.LoopBuilder <DeviceInfo8036>().WithControllerID(2)
                        .WithDevice(new TestAssistant.DeviceBuilder8036().WithLoopID(1).Builder()).Build());
            lstLoop.Add(new TestAssistant.LoopBuilder <DeviceInfo8036>().WithControllerID(2)
                        .WithDevice(new TestAssistant.DeviceBuilder8036().WithLoopID(1).WithID(2).WithSimpleCode("002").Builder()).Build());

            List <ControllerModel> lstController = new List <ControllerModel>();

            lstController.Add(new TestAssistant.ControllerBuilder().WithProjectID(1).Build());
            lstController.Add(new TestAssistant.ControllerBuilder().WithProjectID(1).WithID(2).WithName("Controller2")
                              .WithLoop(lstLoop).Build());


            ProjectModel pModel = new TestAssistant.ProjectBuilder()
                                  .WithController(lstController).Build();

            _projManager.CreateProject(pModel);
            //_databaseService = new SQLiteDatabaseAccess(_projManager.Project.SavePath, _logRecorder, _fileService);
            //_projService = new ProjectService(_databaseService);
            //_projService.Dispose();
            Assert.That(pModel.ID, Is.EqualTo(_projManager.Project.ID), "ID");
            Assert.That(pModel.Name, Is.EqualTo(_projManager.Project.Name), "Name");
            Assert.That(pModel.SavePath, Is.EqualTo(_projManager.Project.SavePath), "SavePath");
            Assert.That(pModel.SaveInterval, Is.EqualTo(_projManager.Project.SaveInterval), "SaveInterval");
        }
Esempio n. 2
0
        public void CreateProject()
        {
            ProjectModel pModel = new TestAssistant.ProjectBuilder().Build();

            _projManager.CreateProject(pModel);
            Assert.That(_projManager.Project.ID, Is.EqualTo(1));
            Assert.That(_projManager.Project.Name, Is.EqualTo(pModel.Name));
            Assert.That(_projManager.Project.SavePath, Is.EqualTo(pModel.SavePath));
            Assert.That(_projManager.Project.SaveInterval, Is.EqualTo(30));
        }
Esempio n. 3
0
        public void SaveProject()
        {
            ProjectModel pModel = new TestAssistant.ProjectBuilder().Build();

            _projManager.CreateProject(pModel);
            bool blnFileExists = _fileService.IsExistFile(_projManager.Project.SavePath);

            Assert.That(blnFileExists, Is.EqualTo(false), "文件不应该存在");
            _databaseService = new SQLiteDatabaseAccess(_projManager.Project.SavePath, _logRecorder, _fileService);
            _projService     = new ProjectService();
            bool blnResult = _projService.CreateProject(_projManager.Project, null);

            _projService.Dispose();
            blnFileExists = _fileService.IsExistFile(_projManager.Project.SavePath);
            Assert.That(blnFileExists, Is.EqualTo(true), "文件应该存在");
            _fileService.DeleteFile(_projManager.Project.SavePath);
        }
Esempio n. 4
0
        public void DisplayProjectInfo()
        {
            List <LoopModel> lstLoop = new List <LoopModel>();

            lstLoop.Add(new TestAssistant.LoopBuilder <DeviceInfo8036>().WithControllerID(1).WithDeviceAmount(1)
                        .WithDevice(new TestAssistant.DeviceBuilder8036().WithLoopID(1).Builder()).Build());

            List <ControllerModel> lstController = new List <ControllerModel>();

            lstController.Add(new TestAssistant.ControllerBuilder().WithProjectID(1).WithLoop(lstLoop).Build());
            lstController.Add(new TestAssistant.ControllerBuilder().WithProjectID(1).WithID(2).WithName("Controller2")
                              .WithLoop(lstLoop).Build());

            ProjectModel pModel = new TestAssistant.ProjectBuilder()
                                  .WithController(lstController)
                                  //.WithController(new TestAssistant.ControllerBuilder().WithProjectID(1).WithID(2).WithName("Controller2")
                                  //    .WithLoop(new TestAssistant.LoopBuilder().WithControllerID(2)
                                  //       .WithDevice(new TestAssistant.DeviceBuilder8036().WithLoopID(1)
                                  //       .Builder())
                                  //       .WithDevice(new TestAssistant.DeviceBuilder8036().WithLoopID(1).WithID(2).WithSimpleCode("002")
                                  //       .Builder())
                                  //.Build())
                                  //.Build())
                                  .Build();
            SummaryNodeInfo summaryInfo = _projManager.DisplaySummaryInfo(pModel);

            Assert.That(summaryInfo.ChildNodes.Count(), Is.EqualTo(3), "应为三个子节点");

            var             result          = from s in summaryInfo.ChildNodes where s.OrderNumber == 0 select s;
            SummaryNodeInfo projectNodeInfo = result.FirstOrDefault();

            Assert.That(projectNodeInfo.DisplayName, Is.EqualTo("秦皇岛火车站"), "项目名称应为秦皇岛火车站");


            result = from s in summaryInfo.ChildNodes where s.OrderNumber > 0 orderby s.OrderNumber select s;

            Assert.That(result.Count(), Is.EqualTo(2), "应为两个控制器");

            //控制器级别

            Assert.That(result.ElementAt(0).DisplayName, Is.EqualTo("Controller8036"), "控制器名称应为8036");


            var controllerNodes = result.ElementAt(0).ChildNodes;

            Assert.That(controllerNodes.Count, Is.EqualTo(6), "应为6个节点");

            string strNodes = "";

            foreach (var node in controllerNodes)
            {
                strNodes += node.DisplayName;
            }
            Assert.That(strNodes.IndexOf("回路"), Is.GreaterThan(-1), "未找到回路");

            var controller = result.ElementAt(0);

            Assert.That(controller.NodeAmount["回路"], Is.EqualTo(1), "应为一个回路");

            Assert.That(controller.NodeAmount["器件数量"], Is.EqualTo(1), "应为一个器件");

            //Assert.That(deviceResult.Count, Is.EqualTo(1), "应为一个器件");

            //Assert.That(deviceResult.ElementAt(0).DisplayName, Is.EqualTo(""), "应为一个器件");

            Assert.That(result.ElementAt(1).DisplayName, Is.EqualTo("Controller2"), "控制器名称应为Controller2");



            //foreach (var controllerNodeInfo in result)
            //{
            //    Assert.That(controllerNodeInfo.DisplayName, Is.EqualTo(""), "文件应该存在");
            //}
        }