public async void TestQuerySpanEquipmentByInterestId_ShouldSucceed() { // Setup var specs = new TestSpecifications(_commandDispatcher, _queryDispatcher).Run(); var walkOfInterest = new RouteNetworkInterest(Guid.NewGuid(), RouteNetworkInterestKindEnum.WalkOfInterest, new RouteNetworkElementIdList() { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() }); var placeSpanEquipmentCommand = new PlaceSpanEquipmentInRouteNetwork(Guid.NewGuid(), TestSpecifications.Multi_Ø32_3x10, walkOfInterest); // Act var placeSpanEquipmentResult = await _commandDispatcher.HandleAsync <PlaceSpanEquipmentInRouteNetwork, Result>(placeSpanEquipmentCommand); var spanEquipmentQueryResult = await _queryDispatcher.HandleAsync <GetEquipmentDetails, Result <GetEquipmentDetailsResult> >( new GetEquipmentDetails(new InterestIdList() { walkOfInterest.Id }) ); // Assert placeSpanEquipmentResult.IsSuccess.Should().BeTrue(); spanEquipmentQueryResult.IsSuccess.Should().BeTrue(); #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. }
public async void TestDrawingCableThrowSingleConduitInWellInsideNodeContainerCC1() { var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>(); var sutRouteNetworkElement = TestRouteNetwork.CC_1; // The span equipment/segment where to route the child span equipment var routeThroughSpanEquipmentId = TestUtilityNetwork.MultiConduit_12x7_HH_1_to_HH_10; var routeThroughSpanEquipmentId2 = TestUtilityNetwork.CustomerConduit_CC_1_to_SDU_1; utilityNetwork.TryGetEquipment <SpanEquipment>(routeThroughSpanEquipmentId, out var routeThoughSpanEquipment); utilityNetwork.TryGetEquipment <SpanEquipment>(routeThroughSpanEquipmentId2, out var routeThoughSpanEquipment2); var routeThroughSpanSegmentId = routeThoughSpanEquipment.SpanStructures[6].SpanSegments[0].Id; var routeThroughSpanSegmentId2 = routeThoughSpanEquipment2.SpanStructures[0].SpanSegments[0].Id; // Setup command var specs = new TestSpecifications(_commandDispatcher, _queryDispatcher).Run(); var routingHops = new RoutingHop[] { new RoutingHop(TestRouteNetwork.HH_1, routeThroughSpanSegmentId) }; var placeSpanEquipmentCommand = new PlaceSpanEquipmentInUtilityNetwork(Guid.NewGuid(), new UserContext("test", Guid.Empty), Guid.NewGuid(), TestSpecifications.FiberCable_288Fiber, routingHops) { NamingInfo = new NamingInfo("K999922222", null), ManufacturerId = Guid.NewGuid() }; // Act var placeSpanEquipmentResult = await _commandDispatcher.HandleAsync <PlaceSpanEquipmentInUtilityNetwork, Result>(placeSpanEquipmentCommand); var getDiagramQueryResult = await _queryDispatcher.HandleAsync <GetDiagram, Result <GetDiagramResult> >(new GetDiagram(sutRouteNetworkElement)); // Assert placeSpanEquipmentResult.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 diagram.DiagramObjects.Count(o => o.Style == "FiberCable" && o.Geometry is LineString).Should().Be(7); diagram.DiagramObjects.Count(o => o.Style == "OuterConduitOrange" && o.Geometry is Polygon).Should().Be(9); }
public void Run() { _logger.LogInformation("Checking conversion database..."); if (CheckIfConversionSchemaExists()) { _logger.LogInformation("Start seeding database with test specifications..."); var result = new TestSpecifications(_loggerFactory, _commandDispatcher, _queryDispatcher).Run(); _logger.LogInformation("Finish seeding database with test specifications."); var localDb = new Settings.GeoDatabaseSetting() { Host = "localhost", Database = "open-ftth", Username = "******", Password = "******", Port = "5432" }; var dbToReadConversionDataFrom = _geoDatabaseSetting; //new Checker(_loggerFactory.CreateLogger<Checker>(), _workTaskId, _eventStore, dbToReadConversionDataFrom, _commandDispatcher, _queryDispatcher).Run(); new CableSpanEquipmentImporter(_loggerFactory.CreateLogger <ConduitSpanEquipmentImporter>(), _eventStore, dbToReadConversionDataFrom, _commandDispatcher, _queryDispatcher).Run(); new NodeContainerImporter(_loggerFactory.CreateLogger <NodeContainerImporter>(), _workTaskId, _eventStore, dbToReadConversionDataFrom, _commandDispatcher, _queryDispatcher).Run(); new RackImporter(_loggerFactory.CreateLogger <RackImporter>(), _workTaskId, _eventStore, dbToReadConversionDataFrom, _commandDispatcher, _queryDispatcher).Run(); new TerminalEquipmentImporter(_loggerFactory.CreateLogger <TerminalEquipmentImporter>(), _workTaskId, _eventStore, dbToReadConversionDataFrom, _commandDispatcher, _queryDispatcher).Run(); new SegmentToTerminalConnectionsImporter(_loggerFactory.CreateLogger <SegmentToTerminalConnectionsImporter>(), _workTaskId, _eventStore, dbToReadConversionDataFrom, _commandDispatcher, _queryDispatcher).Run(); // Old don't run //new ConduitSpanEquipmentImporter(_loggerFactory.CreateLogger<ConduitSpanEquipmentImporter>(), _eventStore, _geoDatabaseSetting, _commandDispatcher, _queryDispatcher).Run(); } else { _logger.LogInformation("No conversion schema exists. Will therefore not seed conversion data."); } }
private Guid PlaceNodeContainer(Guid routeNodeId) { var specs = new TestSpecifications(_commandDispatcher, _queryDispatcher).Run(); var nodeContainerId = Guid.NewGuid(); var nodeOfInterestId = Guid.NewGuid(); var registerNodeOfInterestCommand = new RegisterNodeOfInterest(nodeOfInterestId, routeNodeId); var registerNodeOfInterestCommandResult = _commandDispatcher.HandleAsync <RegisterNodeOfInterest, Result <RouteNetworkInterest> >(registerNodeOfInterestCommand).Result; var placeNodeContainerCommand = new PlaceNodeContainerInRouteNetwork(nodeContainerId, TestSpecifications.Conduit_Closure_Emtelle_Branch_Box, registerNodeOfInterestCommandResult.Value) { ManufacturerId = TestSpecifications.Manu_Emtelle }; var placeNodeContainerResult = _commandDispatcher.HandleAsync <PlaceNodeContainerInRouteNetwork, Result>(placeNodeContainerCommand).Result; return(nodeContainerId); }
public async void TestDrawingCableInsideConduitPassingThrougRouteSegment() { var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>(); var sutRouteNetworkElement = TestRouteNetwork.S2; // The span equipment/segment where to route the child span equipment var routeThroughSpanEquipmentId = TestUtilityNetwork.MultiConduit_10x10_HH_1_to_HH_10; utilityNetwork.TryGetEquipment <SpanEquipment>(routeThroughSpanEquipmentId, out var routeThoughSpanEquipment); var routeThroughSpanSegmentId = routeThoughSpanEquipment.SpanStructures[10].SpanSegments[0].Id; // Setup command var specs = new TestSpecifications(_commandDispatcher, _queryDispatcher).Run(); var routingHops = new RoutingHop[] { new RoutingHop(TestRouteNetwork.HH_1, routeThroughSpanSegmentId) }; var placeSpanEquipmentCommand = new PlaceSpanEquipmentInUtilityNetwork(Guid.NewGuid(), new UserContext("test", Guid.Empty), Guid.NewGuid(), TestSpecifications.FiberCable_72Fiber, routingHops) { NamingInfo = new NamingInfo("K11112222", null), ManufacturerId = Guid.NewGuid() }; // Act var placeSpanEquipmentResult = await _commandDispatcher.HandleAsync <PlaceSpanEquipmentInUtilityNetwork, Result>(placeSpanEquipmentCommand); var getDiagramQueryResult = await _queryDispatcher.HandleAsync <GetDiagram, Result <GetDiagramResult> >(new GetDiagram(sutRouteNetworkElement)); var diagram = getDiagramQueryResult.Value.Diagram; if (System.Environment.OSVersion.Platform.ToString() == "Win32NT") { new GeoJsonExporter(diagram).Export("c:/temp/diagram/test.geojson"); } // Assert diagram.DiagramObjects.Count(o => o.Style == "FiberCable" && o.Geometry is LineString).Should().Be(2); diagram.DiagramObjects.Count(o => o.Label != null && o.Label.Contains("K11112222")).Should().Be(1); }
public async void TestDrawingCableEndOutsideConduitInRouteNode() { var utilityNetwork = _eventStore.Projections.Get <UtilityNetworkProjection>(); var sutRouteNetworkElement = TestRouteNetwork.CC_1; // Setup var specs = new TestSpecifications(_commandDispatcher, _queryDispatcher).Run(); // Cable directly in route network from HH_1 to CC_1 var routingHops = new RoutingHop[] { new RoutingHop( new Guid[] { TestRouteNetwork.HH_1, TestRouteNetwork.S2, TestRouteNetwork.HH_2, TestRouteNetwork.S4, TestRouteNetwork.CC_1 } ), }; var placeSpanEquipmentCommand = new PlaceSpanEquipmentInUtilityNetwork(Guid.NewGuid(), new UserContext("test", Guid.Empty), Guid.NewGuid(), TestSpecifications.FiberCable_192Fiber, routingHops) { NamingInfo = new NamingInfo("K12345678", null), ManufacturerId = Guid.NewGuid() }; // Act var placeSpanEquipmentResult = await _commandDispatcher.HandleAsync <PlaceSpanEquipmentInUtilityNetwork, Result>(placeSpanEquipmentCommand); utilityNetwork.TryGetEquipment <SpanEquipment>(placeSpanEquipmentCommand.SpanEquipmentId, out var placedSpanEquipment); // Act var getDiagramQueryResult = await _queryDispatcher.HandleAsync <GetDiagram, Result <GetDiagramResult> >(new GetDiagram(sutRouteNetworkElement)); var diagram = getDiagramQueryResult.Value.Diagram; if (System.Environment.OSVersion.Platform.ToString() == "Win32NT") { new GeoJsonExporter(diagram).Export("c:/temp/diagram/test.geojson"); } // Assert diagram.DiagramObjects.Count(o => o.Style == "FiberCable" && o.Geometry is LineString).Should().Be(1); diagram.DiagramObjects.Count(o => o.Label != null && o.Label.Contains("K12345678")).Should().Be(1); }
public async void TestPlaceTwoSpanEquipmentWithSameId_SecondOneShouldFail() { // Setup var specs = new TestSpecifications(_commandDispatcher, _queryDispatcher).Run(); var walkOfInterest = new RouteNetworkInterest(Guid.NewGuid(), RouteNetworkInterestKindEnum.WalkOfInterest, new RouteNetworkElementIdList() { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() }); var placeSpanEquipmentCommand = new PlaceSpanEquipmentInRouteNetwork(Guid.NewGuid(), TestSpecifications.Multi_Ø32_3x10, walkOfInterest); // Act var placeSpanEquipmentResult = await _commandDispatcher.HandleAsync <PlaceSpanEquipmentInRouteNetwork, Result>(placeSpanEquipmentCommand); var placeSpanEquipmentResult2 = await _commandDispatcher.HandleAsync <PlaceSpanEquipmentInRouteNetwork, Result>(placeSpanEquipmentCommand); // Assert placeSpanEquipmentResult.IsSuccess.Should().BeTrue(); placeSpanEquipmentResult2.IsSuccess.Should().BeFalse(); }
public TestUtilityNetwork(ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher) { _commandDispatcher = commandDispatcher; _queryDispatcher = queryDispatcher; _ = new TestSpecifications(commandDispatcher, queryDispatcher); }
private static TestSpecifications[] CreateTestSpecifications(Parameters parameters, int numClients) { TargetService.Description targetServiceType = TargetService.SupportedTypes[(TargetService.Types)parameters.ParameterValues[Parameters.Id.TargetServiceType]]; TestSpecifications[] testSpecifications = new TestSpecifications[numClients]; // Distribute the total work among the clients int numWriteOperationsTotal = (int)parameters.ParameterValues[Parameters.Id.NumWriteOperationsTotal]; int numWriteOperationsPerClient = numWriteOperationsTotal / numClients; int numWriteOperationsRemainder = numWriteOperationsTotal % numClients; int numOutstandingWriteOperations = (int)parameters.ParameterValues[Parameters.Id.NumOutstandingWriteOperations]; int numOutstandingWriteOperationsPerClient = numOutstandingWriteOperations / numClients; int numOutstandingWriteOperationsRemainder = numOutstandingWriteOperations % numClients; int numReadOperationsTotal = (int)parameters.ParameterValues[Parameters.Id.NumReadOperationsTotal]; int numReadOperationsPerClient = numReadOperationsTotal / numClients; int numReadOperationsRemainder = numReadOperationsTotal % numClients; int numOutstandingReadOperations = (int)parameters.ParameterValues[Parameters.Id.NumOutstandingReadOperations]; int numOutstandingReadOperationsPerClient = numOutstandingReadOperations / numClients; int numOutstandingReadOperationsRemainder = numOutstandingReadOperations % numClients; int numItems = (int)parameters.ParameterValues[Parameters.Id.NumItems]; int numItemsPerClient = numItems / numClients; int numItemsRemainder = numItems % numClients; for (int i = 0; i < numClients; i++) { // Create test specification for client testSpecifications[i] = new TestSpecifications() { NumWriteOperationsTotal = numWriteOperationsPerClient, NumOutstandingWriteOperations = numOutstandingWriteOperationsPerClient, NumReadOperationsTotal = numReadOperationsPerClient, NumOutstandingReadOperations = numOutstandingReadOperationsPerClient, OperationDataSizeInBytes = (int)parameters.ParameterValues[Parameters.Id.OperationDataSizeInBytes], NumItems = numItemsPerClient, RequestSenderAssemblyName = targetServiceType.AssemblyName, RequestSenderTypeName = targetServiceType.TypeName }; if (i < numWriteOperationsRemainder) { (testSpecifications[i].NumWriteOperationsTotal)++; } if (i < numOutstandingWriteOperationsRemainder) { (testSpecifications[i].NumOutstandingWriteOperations)++; } if (i < numReadOperationsRemainder) { (testSpecifications[i].NumReadOperationsTotal)++; } if (i < numOutstandingReadOperationsRemainder) { (testSpecifications[i].NumOutstandingReadOperations)++; } if (i < numItemsRemainder) { (testSpecifications[i].NumItems)++; } } return(testSpecifications); }
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); }
public void CreateSpanEquipmentSpecifications() { // Add conduit specifications _specs = new TestSpecifications(_loggerFactory, _commandDispatcher, _queryDispatcher).Run().Value; }
public Task InitializeAsync(TestSpecifications testSpecifications) { this.testExecutor = new TestExecutor(); return(this.testExecutor.InitializeAsync(testSpecifications)); }