public async void CutPassThroughConduitInCC1()
        {
            var sutRouteNetworkElement = TestRouteNetwork.CC_1;
            var sutSpanEquipment       = TestUtilityNetwork.MultiConduit_12x7_HH_1_to_HH_10;

            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            // Act
            utilityNetwork.TryGetEquipment <SpanEquipment>(sutSpanEquipment, out var spanEquipment);

            // Cut segments in structure 1 (the outer conduit and second inner conduit)
            var cutCmd = new CutSpanSegmentsAtRouteNode(Guid.NewGuid(), new UserContext("test", Guid.Empty),
                                                        routeNodeId: TestRouteNetwork.CC_1,
                                                        spanSegmentsToCut: new Guid[] {
                spanEquipment.SpanStructures[0].SpanSegments[0].Id,
                spanEquipment.SpanStructures[2].SpanSegments[0].Id,
                spanEquipment.SpanStructures[4].SpanSegments[0].Id,
                spanEquipment.SpanStructures[6].SpanSegments[0].Id,
                spanEquipment.SpanStructures[7].SpanSegments[0].Id
            }
                                                        );

            var cutResult = await _commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd);

            cutResult.IsSuccess.Should().BeTrue();

            var getDiagramQueryResult = await _queryDispatcher.HandleAsync <GetDiagram, Result <GetDiagramResult> >(new GetDiagram(TestRouteNetwork.CC_1));

            if (System.Environment.OSVersion.Platform.ToString() == "Win32NT")
            {
                new GeoJsonExporter(getDiagramQueryResult.Value.Diagram).Export("c:/temp/diagram/test.geojson");
            }
        }
Exemple #2
0
        public async void TryCutSameSpanSegmentTwoTimes_ShouldFailSecondTime()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            utilityNetwork.TryGetEquipment <SpanEquipment>(TestUtilityNetwork.MultiConduit_3x10_CC_1_to_HH_11, out var spanEquipment1);

            var cutCmd1 = new CutSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.J_1,
                spanSegmentsToCut: new Guid[] {
                spanEquipment1.SpanStructures[0].SpanSegments[0].Id,
                spanEquipment1.SpanStructures[1].SpanSegments[0].Id
            }
                );

            var cutResult1 = await _commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd1);

            utilityNetwork.TryGetEquipment <SpanEquipment>(TestUtilityNetwork.MultiConduit_3x10_CC_1_to_HH_11, out var spanEquipment2);

            var cutCmd2 = new CutSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.J_1,
                spanSegmentsToCut: new Guid[] {
                spanEquipment2.SpanStructures[0].SpanSegments[0].Id
            }
                );

            var cutResult2 = await _commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd2);

            cutResult1.IsSuccess.Should().BeTrue();
            cutResult2.IsFailed.Should().BeTrue();
            ((CutSpanSegmentsAtRouteNodeError)cutResult2.Errors.First()).Code.Should().Be(CutSpanSegmentsAtRouteNodeErrorCodes.SPAN_SEGMENT_ALREADY_CUT);
        }
Exemple #3
0
        public async void TestCut5x10ConduitAtCC_1_ShouldSucceed()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            var sutSpanEquipment = TestUtilityNetwork.MultiConduit_5x10_HH_1_to_HH_10;

            utilityNetwork.TryGetEquipment <SpanEquipment>(sutSpanEquipment, out var spanEquipment);

            // Cut the outer conduit and 4 inner conduit
            var cutCmd = new CutSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.CC_1,
                spanSegmentsToCut: new Guid[] {
                spanEquipment.SpanStructures[0].SpanSegments[0].Id,
                spanEquipment.SpanStructures[1].SpanSegments[0].Id,
                spanEquipment.SpanStructures[2].SpanSegments[0].Id,
                spanEquipment.SpanStructures[3].SpanSegments[0].Id,
                spanEquipment.SpanStructures[4].SpanSegments[0].Id
            }
                );

            var cutResult = await _commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd);

            var equipmentQueryResult = await _queryDispatcher.HandleAsync <GetEquipmentDetails, Result <GetEquipmentDetailsResult> >(
                new GetEquipmentDetails(new EquipmentIdList()
            {
                sutSpanEquipment
            })
                );

            equipmentQueryResult.IsSuccess.Should().BeTrue();

            // Assert
            cutResult.IsSuccess.Should().BeTrue();

            var spanEquipmentAfterCut = equipmentQueryResult.Value.SpanEquipment[sutSpanEquipment];

            spanEquipmentAfterCut.NodesOfInterestIds.Length.Should().Be(3);
            spanEquipmentAfterCut.NodesOfInterestIds[0].Should().Be(spanEquipment.NodesOfInterestIds[0]);
            spanEquipmentAfterCut.NodesOfInterestIds[1].Should().Be(TestRouteNetwork.CC_1);
            spanEquipmentAfterCut.NodesOfInterestIds[2].Should().Be(spanEquipment.NodesOfInterestIds[1]);

            // Outer conduit
            spanEquipmentAfterCut.SpanStructures[0].SpanSegments.Length.Should().Be(2);

            // Last inner conduit (should not be cut)
            spanEquipmentAfterCut.SpanStructures[5].SpanSegments.Length.Should().Be(1);

            // Second inner conduit
            spanEquipmentAfterCut.SpanStructures[2].SpanSegments.Length.Should().Be(2);

            // Check if an event is published to the notification.utility-network topic having an idlist containing the span equipment id we just created
            var utilityNetworkNotifications = _externalEventProducer.GetMessagesByTopic("notification.utility-network").OfType <RouteNetworkElementContainedEquipmentUpdated>();
            var utilityNetworkUpdatedEvent  = utilityNetworkNotifications.First(n => n.IdChangeSets != null && n.IdChangeSets.Any(i => i.IdList.Any(i => i == sutSpanEquipment)));

            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.CC_1);
        }
Exemple #4
0
        public async void TryCutWhenSpanEquipmentIsNotAffixedToNodeContainer_ShouldFail()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            utilityNetwork.TryGetEquipment <SpanEquipment>(TestUtilityNetwork.MultiConduit_3x10_CC_1_to_HH_11, out var spanEquipment);

            var cutCmd = new CutSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.J_2,
                spanSegmentsToCut: new Guid[] { spanEquipment.SpanStructures[1].SpanSegments[0].Id }
                );

            var cutResult = await _commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd);

            cutResult.IsFailed.Should().BeTrue();
            ((CutSpanSegmentsAtRouteNodeError)cutResult.Errors.First()).Code.Should().Be(CutSpanSegmentsAtRouteNodeErrorCodes.SPAN_EQUIPMENT_NOT_AFFIXED_TO_NODE_CONTAINER);
        }
Exemple #5
0
        public async void TryCutAtSpanEquipmentEnd_ShouldFail()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            utilityNetwork.TryGetEquipment <SpanEquipment>(TestUtilityNetwork.MultiConduit_3x10_CC_1_to_HH_11, out var spanEquipment);

            var cutCmd = new CutSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.CC_1,
                spanSegmentsToCut: new Guid[] { spanEquipment.SpanStructures[1].SpanSegments[0].Id }
                );

            var cutResult = await _commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd);

            cutResult.IsFailed.Should().BeTrue();
            ((CutSpanSegmentsAtRouteNodeError)cutResult.Errors.First()).Code.Should().Be(CutSpanSegmentsAtRouteNodeErrorCodes.SPAN_EQUIPMENT_CANNOT_BE_CUT_AT_ENDS);
        }
Exemple #6
0
        public async void CutInnerConduit1InHH2_ShouldSucceed()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            var sutSpanEquipment = TestUtilityNetwork.MultiConduit_5x10_HH_1_to_HH_10;

            utilityNetwork.TryGetEquipment <SpanEquipment>(sutSpanEquipment, out var spanEquipmentBeforeCut);

            // Cut inner conduit 1 in HH 2
            var cutCmd = new CutSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.HH_2,
                spanSegmentsToCut: new Guid[] {
                spanEquipmentBeforeCut.SpanStructures[0].SpanSegments[0].Id,
                spanEquipmentBeforeCut.SpanStructures[1].SpanSegments[0].Id
            }
                );

            var cutResult = await _commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd);

            utilityNetwork.TryGetEquipment <SpanEquipment>(sutSpanEquipment, out var spanEquipmentAfterCut);

            var equipmentQueryResult = await _queryDispatcher.HandleAsync <GetEquipmentDetails, Result <GetEquipmentDetailsResult> >(
                new GetEquipmentDetails(new EquipmentIdList()
            {
                sutSpanEquipment
            })
                );

            equipmentQueryResult.IsSuccess.Should().BeTrue();

            // Assert
            cutResult.IsSuccess.Should().BeTrue();

            // Check that inner conduit 1 is connected correctly in graph
            var innerConduit1Segment1Id = spanEquipmentAfterCut.SpanStructures[1].SpanSegments[0].Id;

            utilityNetwork.Graph.TryGetGraphElement <IUtilityGraphElement>(innerConduit1Segment1Id, out var conduit1segment1UtilityGraphElement);

            conduit1segment1UtilityGraphElement.Should().NotBeNull();

            var traceResult = utilityNetwork.Graph.TraceSegment(innerConduit1Segment1Id);

            ((UtilityGraphConnectedTerminal)traceResult.Downstream.Last()).NodeOfInterestId.Should().Be(TestRouteNetwork.CO_1);
            ((UtilityGraphConnectedTerminal)traceResult.Upstream.Last()).NodeOfInterestId.Should().Be(TestRouteNetwork.HH_2);
        }
Exemple #7
0
        public async void TryCutAtSpanSegmentThatDontExist_ShouldFail()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            utilityNetwork.TryGetEquipment <SpanEquipment>(TestUtilityNetwork.MultiConduit_3x10_CC_1_to_HH_11, out var spanEquipment);

            var cutCmd = new CutSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.J_1,
                spanSegmentsToCut: new Guid[] {
                Guid.NewGuid()     // This one defiantly will not exists
            }
                );

            var cutResult = await _commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd);

            cutResult.IsFailed.Should().BeTrue();
            ((CutSpanSegmentsAtRouteNodeError)cutResult.Errors.First()).Code.Should().Be(CutSpanSegmentsAtRouteNodeErrorCodes.SPAN_SEGMENT_NOT_FOUND);
        }
Exemple #8
0
        public async void TestCutInnerConduit1In3x10_ShouldSucceed()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            var sutSpanEquipment = TestUtilityNetwork.MultiConduit_3x10_SDU_1_to_SDU_2;

            utilityNetwork.TryGetEquipment <SpanEquipment>(sutSpanEquipment, out var spanEquipment);

            // Cut sthe outer conduit and first inner conduit
            var cutCmd = new CutSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.J_1,
                spanSegmentsToCut: new Guid[] {
                spanEquipment.SpanStructures[0].SpanSegments[0].Id,
                spanEquipment.SpanStructures[1].SpanSegments[0].Id,
            }
                );

            var cutResult = await _commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd);

            cutResult.IsSuccess.Should().BeTrue();
        }
        private async void MakeSureTestConduitIsCutAndConnectedAtCC_1()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            var sutSpanEquipment = TestUtilityNetwork.MultiConduit_5x10_HH_1_to_HH_10;

            utilityNetwork.TryGetEquipment <SpanEquipment>(sutSpanEquipment, out var spanEquipment);

            // Cut segments in structure 1 (the outer conduit and second inner conduit)
            var cutCmd = new CutSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.CC_1,
                spanSegmentsToCut: new Guid[] {
                spanEquipment.SpanStructures[0].SpanSegments[0].Id,
                spanEquipment.SpanStructures[1].SpanSegments[0].Id,
                spanEquipment.SpanStructures[2].SpanSegments[0].Id,
                spanEquipment.SpanStructures[3].SpanSegments[0].Id,
                spanEquipment.SpanStructures[4].SpanSegments[0].Id
            }
                );

            await _commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd);


            var sutConnectFromSpanEquipment = TestUtilityNetwork.MultiConduit_5x10_HH_1_to_HH_10;
            var sutConnectToSpanEquipment   = TestUtilityNetwork.MultiConduit_3x10_CC_1_to_SP_1;

            utilityNetwork.TryGetEquipment <SpanEquipment>(sutConnectFromSpanEquipment, out var sutFromSpanEquipment);
            utilityNetwork.TryGetEquipment <SpanEquipment>(sutConnectToSpanEquipment, out var sutToSpanEquipment);

            // Connect inner conduit 2 in 5x10 with inner conduit 3 in 3x10
            var connectCmd = new ConnectSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.CC_1,
                spanSegmentsToConnect: new Guid[] {
                sutFromSpanEquipment.SpanStructures[4].SpanSegments[0].Id,
                sutToSpanEquipment.SpanStructures[3].SpanSegments[0].Id
            }
                );

            var connectResult = await _commandDispatcher.HandleAsync <ConnectSpanSegmentsAtRouteNode, Result>(connectCmd);
        }
Exemple #10
0
        private async void MakeSureTestConduitsHasInnerConduitsAndConnections()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            var sutSpanEquipmentId = TestUtilityNetwork.FlexConduit_40_Red_SDU_1_to_SDU_2;

            utilityNetwork.TryGetEquipment <SpanEquipment>(sutSpanEquipmentId, out var spanEquipment);

            if (spanEquipment.SpanStructures.Length > 1)
            {
                return;
            }

            // Add 3 inner conduits
            var addStructure = new PlaceAdditionalStructuresInSpanEquipment(
                spanEquipmentId: sutSpanEquipmentId,
                structureSpecificationIds: new Guid[] { TestSpecifications.Ø10_Red, TestSpecifications.Ø10_Black, TestSpecifications.Ø10_Violet }
                );

            var addStructureResult = await _commandDispatcher.HandleAsync <PlaceAdditionalStructuresInSpanEquipment, Result>(addStructure);

            addStructureResult.IsSuccess.Should().BeTrue();

            // Cut flex conduit inner conduit 1
            utilityNetwork.TryGetEquipment <SpanEquipment>(sutSpanEquipmentId, out var spanEquipment2);

            var cutCmd = new CutSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.J_1,
                spanSegmentsToCut: new Guid[] {
                spanEquipment2.SpanStructures[0].SpanSegments[0].Id,
                spanEquipment2.SpanStructures[1].SpanSegments[0].Id,
                spanEquipment2.SpanStructures[2].SpanSegments[0].Id,
                spanEquipment2.SpanStructures[3].SpanSegments[0].Id
            }
                );

            var cutCmdResult = await _commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd);

            cutCmdResult.IsSuccess.Should().BeTrue();

            // Cut 3x10 conduit 1
            utilityNetwork.TryGetEquipment <SpanEquipment>(TestUtilityNetwork.MultiConduit_3x10_CC_1_to_HH_11, out var spanEquipment3);

            var cutCmd2 = new CutSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.J_1,
                spanSegmentsToCut: new Guid[] {
                spanEquipment3.SpanStructures[0].SpanSegments[0].Id,
                spanEquipment3.SpanStructures[1].SpanSegments[0].Id
            }
                );

            // Might already be cut in SpanEquipmentCutTests
            await _commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd2);


            // Connect flex inner conduit 1 with 3-10 inner conduit 1
            utilityNetwork.TryGetEquipment <SpanEquipment>(TestUtilityNetwork.FlexConduit_40_Red_SDU_1_to_SDU_2, out var sutFromSpanEquipment);
            utilityNetwork.TryGetEquipment <SpanEquipment>(TestUtilityNetwork.MultiConduit_3x10_CC_1_to_HH_11, out var sutToSpanEquipment);

            var connectCmd = new ConnectSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.J_1,
                spanSegmentsToConnect: new Guid[] {
                sutFromSpanEquipment.SpanStructures[1].SpanSegments[0].Id,
                sutToSpanEquipment.SpanStructures[1].SpanSegments[0].Id
            }
                );

            var connectResult = await _commandDispatcher.HandleAsync <ConnectSpanSegmentsAtRouteNode, Result>(connectCmd);

            connectResult.IsSuccess.Should().BeTrue();
        }
        public async void TestDrawingSpanEquipmentWithSegmentsCut()
        {
            var sutRouteNetworkElement = TestRouteNetwork.CC_1;
            var sutSpanEquipment       = TestUtilityNetwork.MultiConduit_12x7_HH_1_to_HH_10;

            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            // Act
            utilityNetwork.TryGetEquipment <SpanEquipment>(sutSpanEquipment, out var spanEquipment);

            // Cut segments in structure 1 (the outer conduit and second inner conduit)
            var cutCmd = new CutSpanSegmentsAtRouteNode(Guid.NewGuid(), new UserContext("test", Guid.Empty),
                                                        routeNodeId: TestRouteNetwork.CC_1,
                                                        spanSegmentsToCut: new Guid[] {
                spanEquipment.SpanStructures[3].SpanSegments[0].Id
            }
                                                        );

            var cutResult = await _commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd);

            var getDiagramQueryResult = await _queryDispatcher.HandleAsync <GetDiagram, Result <GetDiagramResult> >(new GetDiagram(sutRouteNetworkElement));

            getDiagramQueryResult.IsSuccess.Should().BeTrue();

            var diagram = getDiagramQueryResult.Value.Diagram;

            if (System.Environment.OSVersion.Platform.ToString() == "Win32NT")
            {
                new GeoJsonExporter(diagram).Export("c:/temp/diagram/test.geojson");
            }

            // Assert
            cutResult.IsSuccess.Should().BeTrue();

            // Assert that north attached 3x10 has correct labels and id's
            utilityNetwork.TryGetEquipment <SpanEquipment>(TestUtilityNetwork.MultiConduit_3x10_CC_1_to_SP_1, out var cc1tosp1conduit);
            diagram.DiagramObjects.Count(o => o.Style == "OuterConduitOrange" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == cc1tosp1conduit.SpanStructures[0].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "InnerConduitBlue" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == cc1tosp1conduit.SpanStructures[1].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "InnerConduitYellow" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == cc1tosp1conduit.SpanStructures[2].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "InnerConduitWhite" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == cc1tosp1conduit.SpanStructures[3].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "NorthTerminalLabel" && o.Label == "SP-1" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == cc1tosp1conduit.SpanStructures[1].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "NorthTerminalLabel" && o.Label == "SP-1" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == cc1tosp1conduit.SpanStructures[2].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "NorthTerminalLabel" && o.Label == "SP-1" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == cc1tosp1conduit.SpanStructures[3].SpanSegments[0].Id).Should().Be(1);

            // Assert that 5x10 passing through node container has as correct labels and id's
            utilityNetwork.TryGetEquipment <SpanEquipment>(TestUtilityNetwork.MultiConduit_12x7_HH_1_to_HH_10, out var hh11tohh10conduit);
            diagram.DiagramObjects.Count(o => o.Style == "OuterConduitOrange" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == hh11tohh10conduit.SpanStructures[0].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "OuterConduitOrange" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == hh11tohh10conduit.SpanStructures[0].SpanSegments[1].Id).Should().Be(1);

            diagram.DiagramObjects.Count(o => o.Style == "InnerConduitBlue" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == hh11tohh10conduit.SpanStructures[1].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "WestTerminalLabel" && o.Label == "HH-1" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == hh11tohh10conduit.SpanStructures[1].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "EastTerminalLabel" && o.Label == "HH-10" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == hh11tohh10conduit.SpanStructures[1].SpanSegments[0].Id).Should().Be(1);

            diagram.DiagramObjects.Count(o => o.Style == "InnerConduitYellow" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == hh11tohh10conduit.SpanStructures[2].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "InnerConduitYellow" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == hh11tohh10conduit.SpanStructures[2].SpanSegments[1].Id).Should().Be(2);
            diagram.DiagramObjects.Count(o => o.Style == "WestTerminalLabel" && o.Label == "HH-1" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == hh11tohh10conduit.SpanStructures[2].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "EastTerminalLabel" && o.Label == "HH-10" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == hh11tohh10conduit.SpanStructures[2].SpanSegments[1].Id).Should().Be(1);

            // Assert that 3x10 starting in CC and ending in HH 11 has as correct labels and id's
            utilityNetwork.TryGetEquipment <SpanEquipment>(TestUtilityNetwork.MultiConduit_3x10_CC_1_to_HH_11, out var cc1tohh1conduit);
            diagram.DiagramObjects.Count(o => o.Style == "WestTerminalLabel" && o.Label == "HH-11" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == cc1tohh1conduit.SpanStructures[1].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "WestTerminalLabel" && o.Label == "HH-11" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == cc1tohh1conduit.SpanStructures[2].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "WestTerminalLabel" && o.Label == "HH-11" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == cc1tohh1conduit.SpanStructures[3].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "InnerConduitBlue" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == cc1tohh1conduit.SpanStructures[1].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "InnerConduitYellow" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == cc1tohh1conduit.SpanStructures[2].SpanSegments[0].Id).Should().Be(1);
            diagram.DiagramObjects.Count(o => o.Style == "InnerConduitWhite" && o.IdentifiedObject.RefClass == "SpanSegment" && o.IdentifiedObject.RefId == cc1tohh1conduit.SpanStructures[3].SpanSegments[0].Id).Should().Be(1);
        }
Exemple #12
0
        public async void CutInnerConduit10In10x10inCC1_ShouldSucceed()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            var sutSpanEquipment = TestUtilityNetwork.MultiConduit_10x10_HH_1_to_HH_10;

            utilityNetwork.TryGetEquipment <SpanEquipment>(sutSpanEquipment, out var spanEquipmentBeforeCut);

            // Cut inner conduit 10 in CC 1
            var cutCmd = new CutSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.CC_1,
                spanSegmentsToCut: new Guid[] {
                spanEquipmentBeforeCut.SpanStructures[0].SpanSegments[0].Id,
                spanEquipmentBeforeCut.SpanStructures[10].SpanSegments[0].Id
            }
                );

            var cutResult = await _commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd);

            utilityNetwork.TryGetEquipment <SpanEquipment>(sutSpanEquipment, out var spanEquipmentAfterCut);

            var equipmentQueryResult = await _queryDispatcher.HandleAsync <GetEquipmentDetails, Result <GetEquipmentDetailsResult> >(
                new GetEquipmentDetails(new EquipmentIdList()
            {
                sutSpanEquipment
            })
                );

            equipmentQueryResult.IsSuccess.Should().BeTrue();

            var traceQueryResult = await _queryDispatcher.HandleAsync <GetEquipmentDetails, Result <GetEquipmentDetailsResult> >(
                new GetEquipmentDetails(new EquipmentIdList()
            {
                sutSpanEquipment
            })
            {
                EquipmentDetailsFilter = new EquipmentDetailsFilterOptions()
                {
                    IncludeRouteNetworkTrace = true
                }
            }
                );

            // Assert
            cutResult.IsSuccess.Should().BeTrue();
            traceQueryResult.IsSuccess.Should().BeTrue();

            // Check route network traces
            var routeNetworkTraces = traceQueryResult.Value.RouteNetworkTraces;

            routeNetworkTraces.Count.Should().Be(3); // one coveringt the whole conduit and 2 covering the two pieces left from cut of inner conduit 10

            var firstSpanTrace  = routeNetworkTraces.First(rt => rt.FromRouteNodeId == TestRouteNetwork.HH_1 && rt.ToRouteNodeId == TestRouteNetwork.CC_1);
            var secondSpanTrace = routeNetworkTraces.First(rt => rt.FromRouteNodeId == TestRouteNetwork.CC_1 && rt.ToRouteNodeId == TestRouteNetwork.HH_10);

            var spanEquipmentTraceRefs = traceQueryResult.Value.SpanEquipment[sutSpanEquipment].RouteNetworkTraceRefs;

            var segment1TraceRef = spanEquipmentTraceRefs.First(tr => tr.SpanEquipmentOrSegmentId == spanEquipmentAfterCut.SpanStructures[10].SpanSegments[0].Id).TraceId;
            var segment2TraceRef = spanEquipmentTraceRefs.First(tr => tr.SpanEquipmentOrSegmentId == spanEquipmentAfterCut.SpanStructures[10].SpanSegments[1].Id).TraceId;

            segment1TraceRef.Should().Be(firstSpanTrace.Id);
            segment2TraceRef.Should().Be(secondSpanTrace.Id);
        }
Exemple #13
0
        public SpanEquipmentMutations(ICommandDispatcher commandDispatcher, IEventStore eventStore)
        {
            Description = "Span equipment mutations";

            FieldAsync <CommandResultType>(
                "placeSpanEquipmentInRouteNetwork",
                description: "Place a span equipment (i.e. conduit, cable whatwever) in the route network",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "spanEquipmentId"
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "spanEquipmentSpecificationId"
            },
                    new QueryArgument <NonNullGraphType <ListGraphType <IdGraphType> > > {
                Name = "routeSegmentIds"
            },
                    new QueryArgument <IdGraphType> {
                Name = "manufacturerId"
            },
                    new QueryArgument <MarkingInfoInputType> {
                Name = "markingInfo"
            },
                    new QueryArgument <NamingInfoInputType> {
                Name = "namingInfo"
            },
                    new QueryArgument <AddressInfoInputType> {
                Name = "addressInfo"
            }
                    ),
                resolve: async context =>
            {
                var spanEquipmentId = context.GetArgument <Guid>("spanEquipmentId");
                var spanEquipmentSpecificationId = context.GetArgument <Guid>("spanEquipmentSpecificationId");
                var routeSegmentIds = context.GetArgument <List <Guid> >("routeSegmentIds");
                var manufacturerId  = context.GetArgument <Guid>("manufacturerId");
                var markingInfo     = context.GetArgument <MarkingInfo>("markingInfo");
                var namingInfo      = context.GetArgument <NamingInfo>("namingInfo");
                var addressInfo     = context.GetArgument <AddressInfo>("addressInfo");

                // Name conduit span equipment
                // TODO: Refactor into som class responsible for span equipment naming
                var spec   = eventStore.Projections.Get <SpanEquipmentSpecificationsProjection>().Specifications[spanEquipmentSpecificationId];
                namingInfo = CalculateName(eventStore, namingInfo, spec);

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId         = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");
                var commandUserContext = new UserContext(userName, workTaskId);

                var spanEquipments = eventStore.Projections.Get <UtilityNetworkProjection>().SpanEquipmentsByEquipmentId;

                // First register the walk in the route network where the client want to place the span equipment
                var walkOfInterestId = Guid.NewGuid();
                var walk             = new RouteNetworkElementIdList();
                walk.AddRange(routeSegmentIds);

                var registerWalkOfInterestCommand = new RegisterWalkOfInterest(correlationId, commandUserContext, walkOfInterestId, walk);

                var registerWalkOfInterestCommandResult = await commandDispatcher.HandleAsync <RegisterWalkOfInterest, Result <RouteNetworkInterest> >(registerWalkOfInterestCommand);

                if (registerWalkOfInterestCommandResult.IsFailed)
                {
                    return(new CommandResult(registerWalkOfInterestCommandResult));
                }

                // Now place the conduit in the walk
                var placeSpanEquipmentCommand = new PlaceSpanEquipmentInRouteNetwork(
                    correlationId, commandUserContext, spanEquipmentId, spanEquipmentSpecificationId, registerWalkOfInterestCommandResult.Value)
                {
                    ManufacturerId = manufacturerId,
                    NamingInfo     = namingInfo,
                    MarkingInfo    = markingInfo,
                    LifecycleInfo  = new LifecycleInfo(DeploymentStateEnum.InService, null, null),
                    AddressInfo    = addressInfo
                };

                var placeSpanEquipmentResult = await commandDispatcher.HandleAsync <PlaceSpanEquipmentInRouteNetwork, Result>(placeSpanEquipmentCommand);

                // Unregister interest if place span equipment failed
                if (placeSpanEquipmentResult.IsFailed)
                {
                    var unregisterCommandResult = await commandDispatcher.HandleAsync <UnregisterInterest, Result>(
                        new UnregisterInterest(correlationId, commandUserContext, walkOfInterestId));

                    if (unregisterCommandResult.IsFailed)
                    {
                        return(new CommandResult(unregisterCommandResult));
                    }
                }

                return(new CommandResult(placeSpanEquipmentResult));
            }
                );

            FieldAsync <CommandResultType>(
                "affixSpanEquipmentToNodeContainer",
                description: "Affix a span equipment to a node container - i.e. to some condult closure, man hole etc.",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ListGraphType <IdGraphType> > > {
                Name = "spanSegmentIds"
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "nodeContainerId"
            },
                    new QueryArgument <NonNullGraphType <NodeContainerSideEnumType> > {
                Name = "nodeContainerSide"
            }
                    ),
                resolve: async context =>
            {
                var spanSegmentIds  = context.GetArgument <List <Guid> >("spanSegmentIds");
                var nodeContainerId = context.GetArgument <Guid>("nodeContainerId");
                var side            = context.GetArgument <NodeContainerSideEnum>("nodeContainerSide");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId);

                foreach (var spanSegmentId in spanSegmentIds)
                {
                    var affixCommand = new AffixSpanEquipmentToNodeContainer(correlationId, commandUserContext, spanSegmentId, nodeContainerId, side);

                    var affixCommandResult = await commandDispatcher.HandleAsync <AffixSpanEquipmentToNodeContainer, Result>(affixCommand);

                    if (affixCommandResult.IsFailed)
                    {
                        return(new CommandResult(affixCommandResult));
                    }
                }

                return(new CommandResult(Result.Ok()));
            }
                );

            FieldAsync <CommandResultType>(
                "detachSpanEquipmentFromNodeContainer",
                description: "Detach a span equipment from a node container - i.e. from some condult closure, man hole etc.",
                arguments: new QueryArguments(
                    new QueryArgument <ListGraphType <IdGraphType> > {
                Name = "spanSegmentIds"
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "routeNodeId"
            }
                    ),
                resolve: async context =>
            {
                var spanSegmentIds = context.GetArgument <List <Guid> >("spanSegmentIds");
                var routeNodeId    = context.GetArgument <Guid>("routeNodeId");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId)
                {
                    EditingRouteNodeId = routeNodeId
                };

                foreach (var spanSegmentId in spanSegmentIds)
                {
                    var detachCommand       = new DetachSpanEquipmentFromNodeContainer(correlationId, commandUserContext, spanSegmentId, routeNodeId);
                    var detachCommandResult = await commandDispatcher.HandleAsync <DetachSpanEquipmentFromNodeContainer, Result>(detachCommand);

                    if (detachCommandResult.IsFailed)
                    {
                        return(new CommandResult(detachCommandResult));
                    }
                }

                return(new CommandResult(Result.Ok()));
            }
                );

            FieldAsync <CommandResultType>(
                "cutSpanSegments",
                description: "Cut the span segments belonging to som span equipment at the route node specified",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "routeNodeId"
            },
                    new QueryArgument <NonNullGraphType <ListGraphType <IdGraphType> > > {
                Name = "spanSegmentstoCut"
            }
                    ),
                resolve: async context =>
            {
                var routeNodeId      = context.GetArgument <Guid>("routeNodeId");
                var spanSegmentToCut = context.GetArgument <Guid[]>("spanSegmentstoCut");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId)
                {
                    EditingRouteNodeId = routeNodeId
                };

                var cutCmd    = new CutSpanSegmentsAtRouteNode(correlationId, commandUserContext, routeNodeId, spanSegmentToCut);
                var cutResult = await commandDispatcher.HandleAsync <CutSpanSegmentsAtRouteNode, Result>(cutCmd);

                return(new CommandResult(cutResult));
            }
                );

            FieldAsync <CommandResultType>(
                "connectSpanSegments",
                description: "Connect the span segments belonging to two different span equipment at the route node specified",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "routeNodeId"
            },
                    new QueryArgument <NonNullGraphType <ListGraphType <IdGraphType> > > {
                Name = "spanSegmentsToConnect"
            }
                    ),
                resolve: async context =>
            {
                var routeNodeId          = context.GetArgument <Guid>("routeNodeId");
                var spanSegmentToConnect = context.GetArgument <Guid[]>("spanSegmentsToConnect");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId)
                {
                    EditingRouteNodeId = routeNodeId
                };

                var connectCmd    = new ConnectSpanSegmentsAtRouteNode(correlationId, commandUserContext, routeNodeId, spanSegmentToConnect);
                var connectResult = await commandDispatcher.HandleAsync <ConnectSpanSegmentsAtRouteNode, Result>(connectCmd);

                return(new CommandResult(connectResult));
            }
                );

            FieldAsync <CommandResultType>(
                "disconnectSpanSegments",
                description: "Disconnect two span segments belonging to two different span equipment at the route node specified",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "routeNodeId"
            },
                    new QueryArgument <NonNullGraphType <ListGraphType <IdGraphType> > > {
                Name = "spanSegmentsToDisconnect"
            }
                    ),
                resolve: async context =>
            {
                var routeNodeId             = context.GetArgument <Guid>("routeNodeId");
                var spanSegmentToDisconnect = context.GetArgument <Guid[]>("spanSegmentsToDisconnect");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId)
                {
                    EditingRouteNodeId = routeNodeId
                };

                var disconnectCmd    = new DisconnectSpanSegmentsAtRouteNode(correlationId, commandUserContext, routeNodeId, spanSegmentToDisconnect);
                var disconnectResult = await commandDispatcher.HandleAsync <DisconnectSpanSegmentsAtRouteNode, Result>(disconnectCmd);

                return(new CommandResult(disconnectResult));
            }
                );

            FieldAsync <CommandResultType>(
                "addAdditionalInnerSpanStructures",
                description: "Add inner span structures to an existing span equipment",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "spanEquipmentOrSegmentId"
            },
                    new QueryArgument <NonNullGraphType <ListGraphType <IdGraphType> > > {
                Name = "spanStructureSpecificationIds"
            }
                    ),
                resolve: async context =>
            {
                var spanEquipmentOrSegmentId = context.GetArgument <Guid>("spanEquipmentOrSegmentId");
                var specificationsId         = context.GetArgument <Guid[]>("spanStructureSpecificationIds");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId);

                var addStructure = new PlaceAdditionalStructuresInSpanEquipment(
                    correlationId: correlationId,
                    userContext: commandUserContext,
                    spanEquipmentId: spanEquipmentOrSegmentId,
                    structureSpecificationIds: specificationsId
                    );

                var addStructureResult = await commandDispatcher.HandleAsync <PlaceAdditionalStructuresInSpanEquipment, Result>(addStructure);

                return(new CommandResult(addStructureResult));
            }
                );

            FieldAsync <CommandResultType>(
                "removeSpanStructure",
                description: "Remove inner or outer span structure of a span equipment. When the outer span structure is removed the entire span equipment is removed from the network.",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "spanSegmentId"
            }
                    ),
                resolve: async context =>
            {
                var spanSegmentId = context.GetArgument <Guid>("spanSegmentId");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId);

                var removeStructure = new RemoveSpanStructureFromSpanEquipment(
                    correlationId: correlationId,
                    userContext: commandUserContext,
                    spanSegmentId: spanSegmentId
                    );

                var removeStructureResult = await commandDispatcher.HandleAsync <RemoveSpanStructureFromSpanEquipment, Result>(removeStructure);

                return(new CommandResult(removeStructureResult));
            }
                );

            FieldAsync <CommandResultType>(
                "move",
                description: "Move a span equipment / change its walk in the route network",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "spanEquipmentOrSegmentId"
            },
                    new QueryArgument <NonNullGraphType <ListGraphType <IdGraphType> > > {
                Name = "routeSegmentIds"
            }
                    ),
                resolve: async context =>
            {
                var spanEquipmentOrSegmentId = context.GetArgument <Guid>("spanEquipmentOrSegmentId");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId);

                Guid[] routeSegmentIds = context.GetArgument <Guid[]>("routeSegmentIds");

                RouteNetworkElementIdList newWalkIds = new();
                newWalkIds.AddRange(routeSegmentIds);

                var moveCmd = new MoveSpanEquipment(
                    correlationId: correlationId,
                    userContext: commandUserContext,
                    spanEquipmentId: spanEquipmentOrSegmentId,
                    newWalkIds: newWalkIds
                    );

                var moveCmdResult = await commandDispatcher.HandleAsync <MoveSpanEquipment, Result>(moveCmd);

                return(new CommandResult(moveCmdResult));
            }
                );

            FieldAsync <CommandResultType>(
                "updateProperties",
                description: "Mutation that can be used to change the span equipment specification, manufacturer and/or marking information",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "spanEquipmentOrSegmentId"
            },
                    new QueryArgument <IdGraphType> {
                Name = "spanEquipmentSpecificationId"
            },
                    new QueryArgument <IdGraphType> {
                Name = "manufacturerId"
            },
                    new QueryArgument <MarkingInfoInputType> {
                Name = "markingInfo"
            },
                    new QueryArgument <AddressInfoInputType> {
                Name = "addressInfo"
            }
                    ),
                resolve: async context =>
            {
                var spanEquipmentOrSegmentId = context.GetArgument <Guid>("spanEquipmentOrSegmentId");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId);

                var updateCmd = new UpdateSpanEquipmentProperties(correlationId, commandUserContext, spanEquipmentOrSegmentId: spanEquipmentOrSegmentId)
                {
                    SpecificationId = context.HasArgument("spanEquipmentSpecificationId") ? context.GetArgument <Guid>("spanEquipmentSpecificationId") : null,
                    ManufacturerId  = context.HasArgument("manufacturerId") ? context.GetArgument <Guid>("manufacturerId") : null,
                    MarkingInfo     = context.HasArgument("markingInfo") ? context.GetArgument <MarkingInfo>("markingInfo") : null,
                    AddressInfo     = context.HasArgument("addressInfo") ? context.GetArgument <AddressInfo>("addressInfo") : null
                };

                var updateResult = await commandDispatcher.HandleAsync <UpdateSpanEquipmentProperties, Result>(updateCmd);

                return(new CommandResult(updateResult));
            }
                );

            FieldAsync <CommandResultType>(
                "affixSpanEquipmentToParent",
                description: "Affix a span equipment to a parent span equipment - i.e. put a cable inside a conduit",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "routeNodeId"
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "spanSegmentId1"
            },
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "spanSegmentId2"
            }
                    ),
                resolve: async context =>
            {
                var routeNodeId    = context.GetArgument <Guid>("routeNodeId");
                var spanSegmentId1 = context.GetArgument <Guid>("spanSegmentId1");
                var spanSegmentId2 = context.GetArgument <Guid>("spanSegmentId2");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId);

                var affixCommand       = new AffixSpanEquipmentToParent(correlationId, commandUserContext, routeNodeId, spanSegmentId1, spanSegmentId2);
                var affixCommandResult = await commandDispatcher.HandleAsync <AffixSpanEquipmentToParent, Result>(affixCommand);

                if (affixCommandResult.IsFailed)
                {
                    return(new CommandResult(affixCommandResult));
                }

                return(new CommandResult(Result.Ok()));
            }
                );

            FieldAsync <CommandResultType>(
                "connectToTerminalEquipment",
                description: "Connect one or more span segments inside a span equipment to terminals inside a terminal equipmment",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "routeNodeId"
            },
                    new QueryArgument <NonNullGraphType <ListGraphType <ConnectSpanSegmentToTerminalOperationInputType> > > {
                Name = "connects"
            }
                    ),
                resolve: async context =>
            {
                var routeNodeId = context.GetArgument <Guid>("routeNodeId");
                var connects    = context.GetArgument <ConnectSpanSegmentToTerminalOperation[]>("connects");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId);

                var connectCommand       = new ConnectSpanSegmentsWithTerminalsAtRouteNode(correlationId, commandUserContext, routeNodeId, connects);
                var connectCommandResult = await commandDispatcher.HandleAsync <ConnectSpanSegmentsWithTerminalsAtRouteNode, Result>(connectCommand);

                if (connectCommandResult.IsFailed)
                {
                    return(new CommandResult(connectCommandResult));
                }

                return(new CommandResult(Result.Ok()));
            }
                );

            FieldAsync <CommandResultType>(
                "disconnectFromTerminalEquipment",
                description: "Disconnect one or more span segments inside a span equipment from terminals inside a terminal equipmment",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "routeNodeId"
            },
                    new QueryArgument <NonNullGraphType <ListGraphType <DisconnectSpanSegmentFromTerminalOperationInputType> > > {
                Name = "disconnects"
            }
                    ),
                resolve: async context =>
            {
                var routeNodeId = context.GetArgument <Guid>("routeNodeId");
                var connects    = context.GetArgument <DisconnectSpanSegmentFromTerminalOperation[]>("disconnects");

                var correlationId = Guid.NewGuid();

                var userContext = context.UserContext as GraphQLUserContext;
                var userName    = userContext.Username;

                // TODO: Get from work manager
                var workTaskId = Guid.Parse("54800ae5-13a5-4b03-8626-a63b66a25568");

                var commandUserContext = new UserContext(userName, workTaskId);
                var connectCommand     = new DisconnectSpanSegmentsFromTerminalsAtRouteNode(correlationId, commandUserContext, routeNodeId, connects);

                var connectCommandResult = await commandDispatcher.HandleAsync <DisconnectSpanSegmentsFromTerminalsAtRouteNode, Result>(connectCommand);

                if (connectCommandResult.IsFailed)
                {
                    return(new CommandResult(connectCommandResult));
                }

                return(new CommandResult(Result.Ok()));
            }
                );
        }