Exemple #1
0
        public void WithTreeAndRecursive_ShouldAssembleChilds()
        {
            IController controller = Controller(
                activeAlarm: Alarm("Root Alarm", AlarmType.Info),
                actualValues: new [] { VelocityTag() },
                children: new[] { ChildController(
                                      parameters: new[] { Tag(
                                                              dataType: "INT",
                                                              name: "AnyTag",
                                                              value: 13,
                                                              unit: "...",
                                                              comment: "Whatever") }).Object },
                commands: new [] { Command("Start", "Starts the system") },
                configurations: new Tag[0],
                controllerMode: ControllerMode.Auto,
                currentState: "Running",
                currentSubState: "Sub-Running",
                enableForcing: true,
                id: 1,
                isEnabled: true,
                isSimulation: true,
                name: "Root",
                fullname: "Root",
                parameters: new Tag[0],
                type: "RootController").Object;
            PlcInformationDtoAssembler assembler = CreateAssembler();
            ControllerDTO dto = assembler.AssembleControllerDto(controller, recursive: true);

            ApprovalTests.Approvals.Verify(dto.ToJson());
        }
Exemple #2
0
        public void WithNull_ShouldReturnNull()
        {
            PlcInformationDtoAssembler assembler = CreateAssembler();
            ControllerDTO dto = assembler.AssembleControllerDto(null);

            dto.Should().BeNull();
        }
Exemple #3
0
        public void WithControllerHavingChildAndNonRecursive_ShouldReturnNoChild()
        {
            IController controller = ChildController(children: new[] { ChildController(name: "Subchild").Object }).Object;
            PlcInformationDtoAssembler assembler = CreateAssembler();
            ControllerDTO dto = assembler.AssembleControllerDto(controller, recursive: false);

            dto.Children.Should().BeEmpty();
        }
Exemple #4
0
        public void WithControllerHavingNoAlarm_ShouldReturnDtoWithEmptyAlarm()
        {
            IController controller = ChildController().Object;
            PlcInformationDtoAssembler assembler = CreateAssembler();
            ControllerDTO dto = assembler.AssembleControllerDto(controller);

            dto.ActiveAlarm.Should().BeEmpty();
        }
Exemple #5
0
        public void WithControllerHavingChildAndRecurcive_ShouldReturnBothDtos()
        {
            IController controller = ChildController(children: new[] { ChildController(name: "Subchild").Object }).Object;
            PlcInformationDtoAssembler assembler = CreateAssembler();
            ControllerDTO dto = assembler.AssembleControllerDto(controller, recursive: true);

            dto.Children.Should().HaveCount(1);
            dto.Children.First().Name.Should().Be("Subchild");
        }
Exemple #6
0
        public void WithControllerChild_ShouldReturnDtoChild()
        {
            IController controller = ChildController(
                activeAlarm: Alarm("Special Child Alarm", AlarmType.Warning)).Object;
            PlcInformationDtoAssembler assembler = CreateAssembler();
            ControllerDTO dto = assembler.AssembleControllerDto(controller);

            dto.ShouldHaveValues(
                activeAlarm: "Special Child Alarm",
                alarmType: PlcEssentials.PlcInformation.DTOs.AlarmType.Warning,
                currentState: "Ready",
                currentSubState: "Sub-Ready",
                enableForcing: false,
                id: 2,
                isEnabled: false,
                isSimulated: false,
                mode: PlcEssentials.PlcInformation.DTOs.ControllerMode.Manual,
                name: "Child",
                fullname: "Child",
                type: "ChildType");
        }
Exemple #7
0
        public void WithControllerRoot_ShouldReturnDtoRoot()
        {
            IController controller = Controller(
                activeAlarm: Alarm("Root Alarm", AlarmType.Info),
                actualValues: new Tag[0],
                children: new IController[0],
                commands: new ICommand[0],
                configurations: new Tag[0],
                controllerMode: ControllerMode.Auto,
                currentState: "Running",
                currentSubState: "Sub-Running",
                enableForcing: true,
                id: 1,
                isEnabled: true,
                isSimulation: true,
                name: "Root",
                fullname: "Root",
                parameters: new Tag[0],
                type: "RootController").Object;
            PlcInformationDtoAssembler assembler = CreateAssembler();
            ControllerDTO dto = assembler.AssembleControllerDto(controller);

            dto.ShouldHaveValues(
                activeAlarm: "Root Alarm",
                alarmType: PlcEssentials.PlcInformation.DTOs.AlarmType.Normal,
                currentState: "Running",
                currentSubState: "Sub-Running",
                enableForcing: true,
                id: 1,
                isEnabled: true,
                isSimulated: true,
                mode: PlcEssentials.PlcInformation.DTOs.ControllerMode.Auto,
                name: "Root",
                fullname: "Root",
                type: "RootController");
        }