public void WithEnumerableNull_ShouldReturnEmptyList() { PlcInformationDtoAssembler assembler = CreateAssembler(); IEnumerable <ControllerDTO> dtos = assembler.AssembleControllerDtos(null).ToList(); dtos.Should().BeEmpty(); }
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()); }
public void WithNullEnumerable_ShouldReturnEmptyList() { PlcInformationDtoAssembler assembler = CreateAssembler(); IEnumerable <CommandDTO> dtos = assembler.AssembleCommandDtos(null); dtos.Should().BeEmpty(); }
public void WithNull_ShouldReturnNull() { PlcInformationDtoAssembler assembler = CreateAssembler(); ControllerDTO dto = assembler.AssembleControllerDto(null); dto.Should().BeNull(); }
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(); }
public void WithControllerHavingNoAlarm_ShouldReturnDtoWithEmptyAlarm() { IController controller = ChildController().Object; PlcInformationDtoAssembler assembler = CreateAssembler(); ControllerDTO dto = assembler.AssembleControllerDto(controller); dto.ActiveAlarm.Should().BeEmpty(); }
public void WithCommandStop_ShouldReturnDtoStop() { ICommand command = Command(Stop(), StopsIt()); PlcInformationDtoAssembler assembler = CreateAssembler(); CommandDTO dto = assembler.AssembleCommandDto(command); dto.ShouldHaveValues(Stop(), StopsIt()); }
public void WithEnumerableHavingNullValue_ShouldIgnoreNullValues() { IEnumerable <IController> controllers = new[] { null, ChildController().Object }; PlcInformationDtoAssembler assembler = CreateAssembler(); IEnumerable <ControllerDTO> dtos = assembler.AssembleControllerDtos(controllers).ToList(); dtos.Should().HaveCount(1); dtos.First().Name.Should().Be("Child"); }
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"); }
public void WithEnumerableHavingNullValues_ShouldIgnoreNullValues() { IEnumerable <ICommand> commands = new[] { Command(Start(), StartsIt()), null }; PlcInformationDtoAssembler assembler = CreateAssembler(); IEnumerable <CommandDTO> dtos = assembler.AssembleCommandDtos(commands).ToList(); dtos.Should().HaveCount(1); dtos.First().ShouldHaveValues(Start(), StartsIt()); }
public void WithEnumerableOfTwoControllers_ShouldReturnBothAsDtos() { IEnumerable <IController> controllers = new[] { ChildController().Object, ChildController(name: "Root").Object }; PlcInformationDtoAssembler assembler = CreateAssembler(); IEnumerable <ControllerDTO> dtos = assembler.AssembleControllerDtos(controllers).ToList(); dtos.Should().HaveCount(2); dtos.First().Name.Should().Be("Child"); dtos.Last().Name.Should().Be("Root"); }
public void WithEnumerableHavingTwoCommands_ShouldReturnBothAsDtos() { IEnumerable <ICommand> commands = new[] { Command(Start(), StartsIt()), Command(Stop(), StopsIt()) }; PlcInformationDtoAssembler assembler = CreateAssembler(); IEnumerable <CommandDTO> dtos = assembler.AssembleCommandDtos(commands).ToList(); dtos.Should().HaveCount(2); dtos.First().ShouldHaveValues(Start(), StartsIt()); dtos.Last().ShouldHaveValues(Stop(), StopsIt()); }
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"); }
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"); }