Exemplo n.º 1
0
        public async void UpdateMarkingInfo_ShouldSucceed()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            var sutSpanEquipmentId = TestUtilityNetwork.MultiConduit_3x10_SDU_1_to_SDU_2;

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

            var updateCmd = new UpdateSpanEquipmentProperties(spanEquipmentOrSegmentId: sutSpanEquipmentId)
            {
                MarkingInfo = new MarkingInfo()
                {
                    MarkingColor = "Red", MarkingText = "Rød"
                }
            };

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

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

            // Assert
            updateResult.IsSuccess.Should().BeTrue();
            spanEquipmentAfterUpdate.MarkingInfo.Should().BeEquivalentTo(updateCmd.MarkingInfo);

            // 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.Category == "EquipmentModification.PropertiesUpdated" && n.IdChangeSets != null && n.IdChangeSets.Any(i => i.IdList.Any(i => i == sutSpanEquipmentId)));

            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.J_1);
        }
Exemplo n.º 2
0
        public async void TestAffixConduitToContainer_ShouldSucceed()
        {
            var nodeContainerId = PlaceNodeContainer(TestRouteNetwork.HH_2);

            var testNetwork = new TestUtilityNetwork(_commandDispatcher, _queryDispatcher).Run();

            var testConduitId = TestUtilityNetwork.MultiConduit_5x10_HH_1_to_HH_10;

            var testConduit = _eventStore.Projections.Get <UtilityNetworkProjection>().SpanEquipments[testConduitId];

            var affixConduitToContainerCommand = new AffixSpanEquipmentToNodeContainer(
                spanEquipmentOrSegmentId: testConduit.SpanStructures[0].SpanSegments[0].Id,
                nodeContainerId: nodeContainerId,
                nodeContainerIngoingSide: NodeContainerSideEnum.West
                );

            var affixResult = await _commandDispatcher.HandleAsync <AffixSpanEquipmentToNodeContainer, Result>(affixConduitToContainerCommand);

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

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

            equipmentQueryResult.Value.SpanEquipment[testConduitId].NodeContainerAffixes.First(n => n.NodeContainerId == nodeContainerId).NodeContainerIngoingSide.Should().Be(NodeContainerSideEnum.West);

            // 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 == nodeContainerId) && i.ChangeType == Events.Changes.ChangeTypeEnum.Modification));

            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.HH_2);
        }
        public async void ReverseVerticalAlligmentInContainerInJ2_ShouldSucceed()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            var sutNodeContainerId = TestUtilityNetwork.NodeContainer_J_1;

            utilityNetwork.TryGetEquipment <NodeContainer>(sutNodeContainerId, out var nodeContainerBeforeFlip);

            var reverseCmd    = new ReverseNodeContainerVerticalContentAlignment(sutNodeContainerId);
            var reverseResult = await _commandDispatcher.HandleAsync <ReverseNodeContainerVerticalContentAlignment, Result>(reverseCmd);

            var equipmentQueryResult = await _queryDispatcher.HandleAsync <GetEquipmentDetails, Result <GetEquipmentDetailsResult> >(
                new GetEquipmentDetails(new InterestIdList()
            {
                nodeContainerBeforeFlip.InterestId
            })
                );

            // Assert
            nodeContainerBeforeFlip.VertialContentAlignmemt.Should().Be(NodeContainerVerticalContentAlignmentEnum.Bottom);
            reverseResult.IsSuccess.Should().BeTrue();
            equipmentQueryResult.IsSuccess.Should().BeTrue();
            equipmentQueryResult.Value.NodeContainers[sutNodeContainerId].VertialContentAlignmemt.Should().Be(NodeContainerVerticalContentAlignmentEnum.Top);

            // Check if an event is published to the notification.utility-network topic having an idlist containing the node container we just changed
            var utilityNetworkNotifications = _externalEventProducer.GetMessagesByTopic("notification.utility-network").OfType <RouteNetworkElementContainedEquipmentUpdated>();
            var utilityNetworkUpdatedEvent  = utilityNetworkNotifications.First(n => n.Category == "EquipmentModification" && n.IdChangeSets != null && n.IdChangeSets.Any(i => i.IdList.Any(i => i == sutNodeContainerId)));

            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.J_1);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public async void TestAddAdditionalStructuresTo5x10_ShouldSucceed()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            var sutSpanEquipmentId = TestUtilityNetwork.FlexConduit_40_Red_CC_1_to_SP_1;

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

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

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

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

            var equipmentAfterAddingStructure = equipmentQueryResult.Value.SpanEquipment[sutSpanEquipmentId];

            // Assert
            addStructureResult.IsSuccess.Should().BeTrue();
            equipmentQueryResult.IsSuccess.Should().BeTrue();

            equipmentAfterAddingStructure.SpanStructures.Count(s => s.Level == 2).Should().Be(2);
            equipmentAfterAddingStructure.SpanStructures.Count(s => s.Level == 2 && s.Position == 1).Should().Be(1);
            equipmentAfterAddingStructure.SpanStructures.Count(s => s.Level == 2 && s.Position == 2).Should().Be(1);
            equipmentAfterAddingStructure.SpanStructures[1].Id.Should().NotBeEmpty();
            equipmentAfterAddingStructure.SpanStructures[1].SpanSegments[0].Id.Should().NotBeEmpty();
            equipmentAfterAddingStructure.SpanStructures[2].Id.Should().NotBeEmpty();
            equipmentAfterAddingStructure.SpanStructures[2].SpanSegments[0].Id.Should().NotBeEmpty();

            // Check utility graph
            utilityNetwork.Graph.TryGetGraphElement <IUtilityGraphSegmentRef>(equipmentAfterAddingStructure.SpanStructures[2].SpanSegments[0].Id, out var fromGraphSegmentRef);
            fromGraphSegmentRef.SpanSegment(utilityNetwork).FromTerminalId.Should().BeEmpty();
            fromGraphSegmentRef.SpanSegment(utilityNetwork).ToTerminalId.Should().BeEmpty();


            // 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.Category == "EquipmentModification.StructuresAdded" && n.IdChangeSets != null && n.IdChangeSets.Any(i => i.IdList.Any(i => i == sutSpanEquipmentId)));

            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.CC_1);
        }
        public async void TestPlaceValidNodeContainer_ShouldSucceed()
        {
            new TestSpecifications(_commandDispatcher, _queryDispatcher).Run();

            var nodeOfInterestId = Guid.NewGuid();
            var registerNodeOfInterestCommand       = new RegisterNodeOfInterest(nodeOfInterestId, TestRouteNetwork.HH_11);
            var registerNodeOfInterestCommandResult = _commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand).Result;

            var placeNodeContainerCommand = new PlaceNodeContainerInRouteNetwork(Guid.NewGuid(), TestSpecifications.Conduit_Closure_Emtelle_Branch_Box, registerNodeOfInterestCommandResult.Value)
            {
                ManufacturerId = TestSpecifications.Manu_Emtelle
            };

            // Act
            var placeNodeContainerResult = await _commandDispatcher.HandleAsync <PlaceNodeContainerInRouteNetwork, Result>(placeNodeContainerCommand);

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

            // Assert
            placeNodeContainerResult.IsSuccess.Should().BeTrue();
            equipmentQueryResult.IsSuccess.Should().BeTrue();

            equipmentQueryResult.Value.NodeContainers[placeNodeContainerCommand.NodeContainerId].Id.Should().Be(placeNodeContainerCommand.NodeContainerId);
            equipmentQueryResult.Value.NodeContainers[placeNodeContainerCommand.NodeContainerId].SpecificationId.Should().Be(placeNodeContainerCommand.NodeContainerSpecificationId);
            equipmentQueryResult.Value.NodeContainers[placeNodeContainerCommand.NodeContainerId].ManufacturerId.Should().Be(placeNodeContainerCommand.ManufacturerId);
            equipmentQueryResult.Value.NodeContainers[placeNodeContainerCommand.NodeContainerId].InterestId.Should().Be(nodeOfInterestId);
            equipmentQueryResult.Value.NodeContainers[placeNodeContainerCommand.NodeContainerId].VertialContentAlignmemt.Should().Be(NodeContainerVerticalContentAlignmentEnum.Bottom);

            // Check if an event is published to the notification.utility-network topic having an idlist containing the node container 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 == placeNodeContainerCommand.NodeContainerId)));

            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.HH_11);
        }
Exemplo n.º 7
0
        public async void TestRemoveNonConnectedFixedSpanEquipment_ShouldSucceed()
        {
            MakeSureTestConduitsHasInnerConduitsAndConnections();

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

            var sutSpanEquipmentId = TestUtilityNetwork.MultiConduit_5x10_SDU_1_to_SDU_2;

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

            var removeStructureCmd = new RemoveSpanStructureFromSpanEquipment(spanEquipment.SpanStructures[0].SpanSegments[0].Id);

            var removeStructureCmdResult = await _commandDispatcher.HandleAsync <RemoveSpanStructureFromSpanEquipment, Result>(removeStructureCmd);

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

            // Assert
            removeStructureCmdResult.IsSuccess.Should().BeTrue();
            equipmentQueryResult.Value.SpanEquipment.Any(s => s.Id == sutSpanEquipmentId).Should().BeFalse();

            // Make sure segment is removed from the graph as well
            utilityNetwork.Graph.TryGetGraphElement <IUtilityGraphElement>(spanEquipment.SpanStructures[0].SpanSegments[0].Id, out _).Should().BeFalse();
            utilityNetwork.Graph.TryGetGraphElement <IUtilityGraphElement>(spanEquipment.SpanStructures[1].SpanSegments[0].Id, out _).Should().BeFalse();
            utilityNetwork.Graph.TryGetGraphElement <IUtilityGraphElement>(spanEquipment.SpanStructures[2].SpanSegments[0].Id, out _).Should().BeFalse();
            utilityNetwork.Graph.TryGetGraphElement <IUtilityGraphElement>(spanEquipment.SpanStructures[3].SpanSegments[0].Id, out _).Should().BeFalse();
            utilityNetwork.Graph.TryGetGraphElement <IUtilityGraphElement>(spanEquipment.SpanStructures[4].SpanSegments[0].Id, out _).Should().BeFalse();
            utilityNetwork.Graph.TryGetGraphElement <IUtilityGraphElement>(spanEquipment.SpanStructures[5].SpanSegments[0].Id, out _).Should().BeFalse();

            // 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.Category == "EquipmentDeletion" && n.IdChangeSets != null && n.IdChangeSets.Any(i => i.IdList.Any(i => i == sutSpanEquipmentId)));

            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.J_1);
        }
Exemplo n.º 8
0
        public async void MergeTheTwo12x7inJ_1_ShouldSucceed()
        {
            var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>();

            // NB: Both span equipment have from node in J_1
            var sutFromSpanEquipmentId = TestUtilityNetwork.MultiConduit_12x7_SDU_1_to_J_1;
            var sutToSpanEquipmentId   = TestUtilityNetwork.MultiConduit_12x7_SDU_2_to_J_1;

            utilityNetwork.TryGetEquipment <SpanEquipment>(sutFromSpanEquipmentId, out var fromSpanEquipmentBeforeConnect);
            utilityNetwork.TryGetEquipment <SpanEquipment>(sutToSpanEquipmentId, out var toSpanEquipmentBeforeConnect);

            // Connect the two outer conduits, which should result in a merge of the two span equipments
            var connectCmd = new ConnectSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.J_1,
                spanSegmentsToConnect: new Guid[] {
                fromSpanEquipmentBeforeConnect.SpanStructures[0].SpanSegments[0].Id,
                toSpanEquipmentBeforeConnect.SpanStructures[0].SpanSegments[0].Id
            }
                );

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

            utilityNetwork.TryGetEquipment <SpanEquipment>(sutFromSpanEquipmentId, out var fromSpanEquipmentAfterConnect);
            utilityNetwork.TryGetEquipment <SpanEquipment>(sutToSpanEquipmentId, out var toSpanEquipmentAfterConnect);

            var j1NetworkQueryResult = await _queryDispatcher.HandleAsync <GetRouteNetworkDetails, Result <GetRouteNetworkDetailsResult> >(
                new GetRouteNetworkDetails(new RouteNetworkElementIdList()
            {
                TestRouteNetwork.J_1
            })
            {
                RelatedInterestFilter = RelatedInterestFilterOptions.ReferencesFromRouteElementAndInterestObjects
            }
                );


            // Assert
            connectResult.IsSuccess.Should().BeTrue();
            j1NetworkQueryResult.IsSuccess.Should().BeTrue();

            // from span equipment must still be referenced from J_1
            j1NetworkQueryResult.Value.RouteNetworkElements[TestRouteNetwork.J_1].InterestRelations.Any(i => i.RefId == fromSpanEquipmentBeforeConnect.WalkOfInterestId).Should().BeTrue();

            // to span equipment must no longer be referenced from J_1
            j1NetworkQueryResult.Value.RouteNetworkElements[TestRouteNetwork.J_1].InterestRelations.Any(i => i.RefId == toSpanEquipmentBeforeConnect.WalkOfInterestId).Should().BeFalse();

            // to span equipment must no have an interest
            j1NetworkQueryResult.Value.Interests.ContainsKey(toSpanEquipmentBeforeConnect.WalkOfInterestId).Should().BeFalse();

            // Check interest information of from span equipment
            j1NetworkQueryResult.Value.Interests[fromSpanEquipmentBeforeConnect.WalkOfInterestId].RouteNetworkElementRefs.Count().Should().Be(5);
            j1NetworkQueryResult.Value.Interests[fromSpanEquipmentBeforeConnect.WalkOfInterestId].RouteNetworkElementRefs[0].Should().Be(TestRouteNetwork.SDU_2);
            j1NetworkQueryResult.Value.Interests[fromSpanEquipmentBeforeConnect.WalkOfInterestId].RouteNetworkElementRefs[1].Should().Be(TestRouteNetwork.S8);
            j1NetworkQueryResult.Value.Interests[fromSpanEquipmentBeforeConnect.WalkOfInterestId].RouteNetworkElementRefs[2].Should().Be(TestRouteNetwork.J_1);
            j1NetworkQueryResult.Value.Interests[fromSpanEquipmentBeforeConnect.WalkOfInterestId].RouteNetworkElementRefs[3].Should().Be(TestRouteNetwork.S7);
            j1NetworkQueryResult.Value.Interests[fromSpanEquipmentBeforeConnect.WalkOfInterestId].RouteNetworkElementRefs[4].Should().Be(TestRouteNetwork.SDU_1);

            fromSpanEquipmentAfterConnect.Should().NotBeNull();

            // To span equipment should be deleted
            toSpanEquipmentAfterConnect.Should().BeNull();

            // From span segment should still end in SDU_1
            fromSpanEquipmentAfterConnect.NodesOfInterestIds.Last().Should().Be(TestRouteNetwork.SDU_1);

            // From span segment should now start en SDU 2
            fromSpanEquipmentAfterConnect.NodesOfInterestIds.First().Should().Be(TestRouteNetwork.SDU_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.Category == "EquipmentModification.Merge" && n.IdChangeSets != null && n.IdChangeSets.Any(i => i.IdList.Any(i => i == sutFromSpanEquipmentId)));

            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.J_1);
            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.SDU_1);
            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.SDU_2);

            // Assert trace is correct
            var traceQueryResult = await _queryDispatcher.HandleAsync <GetEquipmentDetails, Result <GetEquipmentDetailsResult> >(
                new GetEquipmentDetails(new EquipmentIdList()
            {
                sutFromSpanEquipmentId
            })
            {
                EquipmentDetailsFilter = new EquipmentDetailsFilterOptions()
                {
                    IncludeRouteNetworkTrace = true
                }
            }
                );

            traceQueryResult.IsSuccess.Should().BeTrue();

            var innerConduit1TraceId = traceQueryResult.Value.SpanEquipment[sutFromSpanEquipmentId].RouteNetworkTraceRefs.First(tr => tr.SpanEquipmentOrSegmentId == fromSpanEquipmentBeforeConnect.SpanStructures[1].SpanSegments[0].Id).TraceId;

            var routeNetworkTraces = traceQueryResult.Value.RouteNetworkTraces[innerConduit1TraceId];

            routeNetworkTraces.FromRouteNodeId.Should().Be(TestRouteNetwork.SDU_2);
            routeNetworkTraces.ToRouteNodeId.Should().Be(TestRouteNetwork.SDU_2);
        }
        public async void TestDisconnect5x10From3x10ConduitAtCC_1_ShouldSucceed()
        {
            MakeSureTestConduitIsCutAndConnectedAtCC_1();

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

            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);

            // Disconnect inner conduit 4 in 5x10 from inner conduit 3 in 3x10
            var disconnectCmd = new DisconnectSpanSegmentsAtRouteNode(
                routeNodeId: TestRouteNetwork.CC_1,
                spanSegmentsToDisconnect: new Guid[] {
                sutFromSpanEquipment.SpanStructures[4].SpanSegments[0].Id,
                sutToSpanEquipment.SpanStructures[3].SpanSegments[0].Id
            }
                );

            var disconnectResult = await _commandDispatcher.HandleAsync <DisconnectSpanSegmentsAtRouteNode, Result>(disconnectCmd);

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

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

            // Assert
            disconnectResult.IsSuccess.Should().BeTrue();
            fromEquipmentQueryResult.IsSuccess.Should().BeTrue();
            toEquipmentQueryResult.IsSuccess.Should().BeTrue();

            var fromEquipmentAfterDisconnect = fromEquipmentQueryResult.Value.SpanEquipment[sutConnectFromSpanEquipment];

            fromEquipmentAfterDisconnect.SpanStructures[4].SpanSegments[0].ToTerminalId.Should().BeEmpty();
            fromEquipmentAfterDisconnect.SpanStructures[4].SpanSegments[0].FromTerminalId.Should().BeEmpty();

            var toEquipmentAfterDisconnect = toEquipmentQueryResult.Value.SpanEquipment[sutConnectToSpanEquipment];

            toEquipmentAfterDisconnect.SpanStructures[3].SpanSegments[0].FromTerminalId.Should().BeEmpty();
            toEquipmentAfterDisconnect.SpanStructures[3].SpanSegments[0].ToTerminalId.Should().BeEmpty();

            // Check utility graph
            utilityNetwork.Graph.TryGetGraphElement <IUtilityGraphSegmentRef>(fromEquipmentAfterDisconnect.SpanStructures[4].SpanSegments[0].Id, out var fromGraphSegmentRef);
            fromGraphSegmentRef.SpanSegment(utilityNetwork).FromTerminalId.Should().BeEmpty();
            fromGraphSegmentRef.SpanSegment(utilityNetwork).ToTerminalId.Should().BeEmpty();

            utilityNetwork.Graph.TryGetGraphElement <IUtilityGraphSegmentRef>(toEquipmentAfterDisconnect.SpanStructures[3].SpanSegments[0].Id, out var toGraphSegmentRef);
            toGraphSegmentRef.SpanSegment(utilityNetwork).FromTerminalId.Should().BeEmpty();
            toGraphSegmentRef.SpanSegment(utilityNetwork).ToTerminalId.Should().BeEmpty();

            // 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.Category == "EquipmentConnectivityModification.Disconnect" && n.IdChangeSets != null && n.IdChangeSets.Any(i => i.IdList.Any(i => i == sutConnectFromSpanEquipment)));

            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.CC_1);
        }
Exemplo n.º 10
0
        public async void TestMoveNonConnectedSpanEquipmentEnd_ShouldSucceed()
        {
            MakeSureTestConduitsHasInnerConduitsAndConnections();

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

            var sutSpanEquipmentId = TestUtilityNetwork.MultiConduit_5x10_SDU_1_to_J_1;

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

            var moveCmd = new MoveSpanEquipment(spanEquipment.Id, new RouteNetworkElementIdList()
            {
                TestRouteNetwork.S8
            });

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

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

            var sdu1RouteNetworkQueryResult = await _queryDispatcher.HandleAsync <GetRouteNetworkDetails, Result <GetRouteNetworkDetailsResult> >(
                new GetRouteNetworkDetails(new RouteNetworkElementIdList()
            {
                TestRouteNetwork.SDU_1, TestRouteNetwork.S7
            })
            {
                RelatedInterestFilter = RelatedInterestFilterOptions.ReferencesFromRouteElementOnly
            }
                );

            var sdu2RouteNetworkQueryResult = await _queryDispatcher.HandleAsync <GetRouteNetworkDetails, Result <GetRouteNetworkDetailsResult> >(
                new GetRouteNetworkDetails(new RouteNetworkElementIdList()
            {
                TestRouteNetwork.SDU_2, TestRouteNetwork.S8
            })
            {
                RelatedInterestFilter = RelatedInterestFilterOptions.ReferencesFromRouteElementOnly
            }
                );

            var spanEquipmentAfterMove = equipmentQueryResult.Value.SpanEquipment[sutSpanEquipmentId];

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

            // Check that sut conduit is no longer to be found in SDU_1 and S7
            sdu1RouteNetworkQueryResult.Value.RouteNetworkElements.Any(r => r.InterestRelations.Any(i => i.RefId == spanEquipment.WalkOfInterestId)).Should().BeFalse();

            // Check that sut conduit is now found in SDU_2 and S8
            sdu2RouteNetworkQueryResult.Value.RouteNetworkElements.Count(r => r.InterestRelations.Any(i => i.RefId == spanEquipment.WalkOfInterestId)).Should().Be(2);

            // Check if nodes of interest has changed to reflect new location
            spanEquipmentAfterMove.NodesOfInterestIds.First().Should().Be(TestRouteNetwork.J_1);
            spanEquipmentAfterMove.NodesOfInterestIds.Last().Should().Be(TestRouteNetwork.SDU_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.Category == "EquipmentModification.Moved" && n.IdChangeSets != null && n.IdChangeSets.Any(i => i.IdList.Any(i => i == sutSpanEquipmentId)));

            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.J_1);
        }
Exemplo n.º 11
0
        public async void TestPlaceValidSpanEquipment_ShouldSucceed()
        {
            // Setup
            var specs = new TestSpecifications(_commandDispatcher, _queryDispatcher).Run();

            var walkOfInterestId = Guid.NewGuid();
            var registerWalkOfInterestCommand = new RegisterWalkOfInterest(walkOfInterestId, new RouteNetworkElementIdList()
            {
                TestRouteNetwork.S1
            });
            var registerWalkOfInterestCommandResult = _commandDispatcher.HandleAsync <RegisterWalkOfInterest, Result <RouteNetworkInterest> >(registerWalkOfInterestCommand).Result;

            var placeSpanEquipmentCommand = new PlaceSpanEquipmentInRouteNetwork(Guid.NewGuid(), TestSpecifications.Multi_Ø32_3x10, registerWalkOfInterestCommandResult.Value)
            {
                NamingInfo  = new NamingInfo("Hans", "Grethe"),
                MarkingInfo = new MarkingInfo()
                {
                    MarkingColor = "Red", MarkingText = "ABCDE"
                },
                ManufacturerId = Guid.NewGuid()
            };

            // Act
            var placeSpanEquipmentResult = await _commandDispatcher.HandleAsync <PlaceSpanEquipmentInRouteNetwork, Result>(placeSpanEquipmentCommand);

            var spanEquipmentQueryResult = await _queryDispatcher.HandleAsync <GetEquipmentDetails, Result <GetEquipmentDetailsResult> >(
                new GetEquipmentDetails(new EquipmentIdList()
            {
                placeSpanEquipmentCommand.SpanEquipmentId
            })
                );

            // Assert
            placeSpanEquipmentResult.IsSuccess.Should().BeTrue();
            spanEquipmentQueryResult.IsSuccess.Should().BeTrue();
            spanEquipmentQueryResult.Value.Should().NotBeNull();
            spanEquipmentQueryResult.Value.SpanEquipment.Should().NotBeNull();

#pragma warning disable CS8602 // Dereference of a possibly null reference.
            spanEquipmentQueryResult.Value.SpanEquipment[placeSpanEquipmentCommand.SpanEquipmentId].Id.Should().Be(placeSpanEquipmentCommand.SpanEquipmentId);
#pragma warning restore CS8602 // Dereference of a possibly null reference.
            spanEquipmentQueryResult.Value.SpanEquipment[placeSpanEquipmentCommand.SpanEquipmentId].SpecificationId.Should().Be(placeSpanEquipmentCommand.SpanEquipmentSpecificationId);
            spanEquipmentQueryResult.Value.SpanEquipment[placeSpanEquipmentCommand.SpanEquipmentId].WalkOfInterestId.Should().Be(placeSpanEquipmentCommand.Interest.Id);
            spanEquipmentQueryResult.Value.SpanEquipment[placeSpanEquipmentCommand.SpanEquipmentId].NamingInfo.Should().BeEquivalentTo(placeSpanEquipmentCommand.NamingInfo);
            spanEquipmentQueryResult.Value.SpanEquipment[placeSpanEquipmentCommand.SpanEquipmentId].MarkingInfo.Should().BeEquivalentTo(placeSpanEquipmentCommand.MarkingInfo);
            spanEquipmentQueryResult.Value.SpanEquipment[placeSpanEquipmentCommand.SpanEquipmentId].ManufacturerId.Should().Be(placeSpanEquipmentCommand.ManufacturerId);

            spanEquipmentQueryResult.Value.SpanEquipment[placeSpanEquipmentCommand.SpanEquipmentId].SpanStructures.Length.Should().Be(4);

            // Check that span segments are correctly populated
            for (int structureIndex = 0; structureIndex < spanEquipmentQueryResult.Value.SpanEquipment[placeSpanEquipmentCommand.SpanEquipmentId].SpanStructures.Length; structureIndex++)
            {
                spanEquipmentQueryResult.Value.SpanEquipment[placeSpanEquipmentCommand.SpanEquipmentId].SpanStructures[structureIndex].SpanSegments.Length.Should().Be(1);
                spanEquipmentQueryResult.Value.SpanEquipment[placeSpanEquipmentCommand.SpanEquipmentId].SpanStructures[structureIndex].SpanSegments[0].FromTerminalId.Should().BeEmpty();
                spanEquipmentQueryResult.Value.SpanEquipment[placeSpanEquipmentCommand.SpanEquipmentId].SpanStructures[structureIndex].SpanSegments[0].ToTerminalId.Should().BeEmpty();
                spanEquipmentQueryResult.Value.SpanEquipment[placeSpanEquipmentCommand.SpanEquipmentId].SpanStructures[structureIndex].SpanSegments[0].FromNodeOfInterestIndex.Should().Be(0);
                spanEquipmentQueryResult.Value.SpanEquipment[placeSpanEquipmentCommand.SpanEquipmentId].SpanStructures[structureIndex].SpanSegments[0].ToNodeOfInterestIndex.Should().Be(1);
                spanEquipmentQueryResult.Value.SpanEquipment[placeSpanEquipmentCommand.SpanEquipmentId].SpanStructures[structureIndex].SpanSegments[0].Id.Should().NotBeEmpty();
            }

            // 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 == placeSpanEquipmentCommand.SpanEquipmentId)));
            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.CO_1);
            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.S1);
            utilityNetworkUpdatedEvent.AffectedRouteNetworkElementIds.Should().Contain(TestRouteNetwork.HH_1);
        }