コード例 #1
0
        public async Task CreateDigitizedEvent_ShouldReturnInvalidRouteSegmentOperation_OnEndRouteNodeCountBeingTwoOrMore()
        {
            var applicationSettings   = A.Fake <IOptions <ApplicationSetting> >();
            var routeSegmentValidator = A.Fake <IRouteSegmentValidator>();
            var geoDatabase           = A.Fake <IGeoDatabase>();
            var routeNodeFactory      = A.Fake <IRouteNodeFactory>();
            var routeSegment          = A.Fake <RouteSegment>();

            A.CallTo(() => applicationSettings.Value)
            .Returns(new ApplicationSetting {
                ApplicationName = "GDB_INTEGRATOR"
            });

            A.CallTo(() => routeSegmentValidator.LineIsValid(routeSegment.GetLineString())).Returns(true);
            A.CallTo(() => geoDatabase.GetIntersectingEndRouteNodes(routeSegment)).Returns(new List <RouteNode> {
                A.Fake <RouteNode>(), A.Fake <RouteNode>()
            });

            var factory = new RouteSegmentCommandFactory(applicationSettings, routeSegmentValidator, geoDatabase, routeNodeFactory);

            var result = await factory.CreateDigitizedEvent(routeSegment);

            using (var scope = new AssertionScope())
            {
                result.Count().Should().Be(1);
                result.First().Should().BeOfType(typeof(InvalidRouteSegmentOperation));
            }
        }
コード例 #2
0
        public async Task CreateDigitizedEvent_ShouldCallInsertRouteSegmentIntegrator_OnPassingMethodValidationChecks()
        {
            var applicationSettings    = A.Fake <IOptions <ApplicationSetting> >();
            var routeSegmentValidator  = A.Fake <IRouteSegmentValidator>();
            var geoDatabase            = A.Fake <IGeoDatabase>();
            var routeNodeFactory       = A.Fake <IRouteNodeFactory>();
            var routeSegment           = A.Fake <RouteSegment>();
            var lineString             = A.Fake <LineString>();
            var intersectingStartNodes = new List <RouteNode> {
                A.Fake <RouteNode>()
            };
            var intersectingEndNodes = new List <RouteNode> {
                A.Fake <RouteNode>()
            };

            A.CallTo(() => applicationSettings.Value)
            .Returns(new ApplicationSetting {
                ApplicationName = "GDB_INTEGRATOR"
            });

            A.CallTo(() => routeSegment.GetLineString()).Returns(lineString);
            A.CallTo(() => routeSegmentValidator.LineIsValid(lineString)).Returns(true);

            var factory = new RouteSegmentCommandFactory(applicationSettings, routeSegmentValidator, geoDatabase, routeNodeFactory);

            var result = (NewRouteSegmentDigitized)(await factory.CreateDigitizedEvent(routeSegment)).First();

            using (var scope = new AssertionScope())
            {
                A.CallTo(() => geoDatabase.InsertRouteSegmentShadowTable(routeSegment));
            }
        }
コード例 #3
0
        public async Task CreateDigitizedEvent_ShouldReturnInvalidRouteSegmentOperation_OnRouteSegmentLineStringBeingInvalid()
        {
            var applicationSettings   = A.Fake <IOptions <ApplicationSetting> >();
            var routeSegmentValidator = A.Fake <IRouteSegmentValidator>();
            var geoDatabase           = A.Fake <IGeoDatabase>();
            var routeNodeFactory      = A.Fake <IRouteNodeFactory>();
            var routeSegment          = A.Fake <RouteSegment>();
            var lineString            = A.Fake <LineString>();

            A.CallTo(() => applicationSettings.Value)
            .Returns(new ApplicationSetting {
                ApplicationName = "GDB_INTEGRATOR"
            });

            A.CallTo(() => routeSegment.GetLineString()).Returns(lineString);
            A.CallTo(() => routeSegmentValidator.LineIsValid(lineString)).Returns(false);

            var factory = new RouteSegmentCommandFactory(applicationSettings, routeSegmentValidator, geoDatabase, routeNodeFactory);

            var result = (InvalidRouteSegmentOperation)(await factory.CreateDigitizedEvent(routeSegment)).First();

            using (var scope = new AssertionScope())
            {
                result.Should().BeOfType <InvalidRouteSegmentOperation>();
                result.RouteSegment.Should().Be(routeSegment);
            }
        }
コード例 #4
0
        public async Task CreateDigitizedEvent_ShouldContainEndCreateExistingRouteSegmentSplittedForStartNode_OnEndSegmentCountBeingOneAndStartNodesCountBeingZero()
        {
            var applicationSettings   = A.Fake <IOptions <ApplicationSetting> >();
            var routeSegmentValidator = A.Fake <IRouteSegmentValidator>();
            var geoDatabase           = A.Fake <IGeoDatabase>();
            var routeSegment          = A.Fake <RouteSegment>();
            var routeNodeFactory      = A.Fake <IRouteNodeFactory>();
            var endNode                   = A.Fake <RouteNode>();
            var lineString                = A.Fake <LineString>();
            var intersectingStartNodes    = new List <RouteNode>();
            var intersectingEndNodes      = new List <RouteNode>();
            var intersectingStartSegments = new List <RouteSegment>();
            var intersectingEndSegments   = new List <RouteSegment> {
                A.Fake <RouteSegment>()
            };
            var endPoint = A.Fake <Point>();

            A.CallTo(() => applicationSettings.Value)
            .Returns(new ApplicationSetting {
                ApplicationName = "GDB_INTEGRATOR"
            });

            A.CallTo(() => routeSegment.GetLineString()).Returns(lineString);
            A.CallTo(() => routeSegmentValidator.LineIsValid(lineString)).Returns(true);

            A.CallTo(() => geoDatabase.GetIntersectingStartRouteNodes(routeSegment))
            .Returns(intersectingStartNodes);
            A.CallTo(() => geoDatabase.GetIntersectingEndRouteNodes(routeSegment))
            .Returns(intersectingEndNodes);

            A.CallTo(() => geoDatabase.GetIntersectingStartRouteSegments(routeSegment))
            .Returns(intersectingStartSegments);
            A.CallTo(() => geoDatabase.GetIntersectingEndRouteSegments(routeSegment))
            .Returns(intersectingEndSegments);

            A.CallTo(() => routeSegment.FindEndPoint()).Returns(endPoint);
            A.CallTo(() => routeNodeFactory.Create(endPoint)).Returns(endNode);

            var factory = new RouteSegmentCommandFactory(applicationSettings, routeSegmentValidator, geoDatabase, routeNodeFactory);

            var result = await factory.CreateDigitizedEvent(routeSegment);

            var existingRouteSegmentSplitted = (ExistingRouteSegmentSplitted)result.ToList()[0];
            var newRouteSegmentDigitized     = (NewRouteSegmentDigitized)result.ToList()[1];

            using (var scope = new AssertionScope())
            {
                existingRouteSegmentSplitted.RouteNode.Should().Be(endNode);
                existingRouteSegmentSplitted.RouteSegmentDigitizedByUser.Should().Be(routeSegment);

                newRouteSegmentDigitized.RouteSegment.Should().Be(routeSegment);
            }
        }
コード例 #5
0
        public async Task CreateDigitizedEvent_ShouldThrowArgumentNullException_OnBeingPassedNullRouteSegment()
        {
            var applicationSettings   = A.Fake <IOptions <ApplicationSetting> >();
            var routeSegmentValidator = A.Fake <IRouteSegmentValidator>();
            var geoDatabase           = A.Fake <IGeoDatabase>();
            var routeNodeFactory      = A.Fake <IRouteNodeFactory>();

            var factory = new RouteSegmentCommandFactory(applicationSettings, routeSegmentValidator, geoDatabase, routeNodeFactory);

            Func <Task> act = async() => await factory.CreateDigitizedEvent(null);

            await act.Should().ThrowExactlyAsync <ArgumentNullException>();
        }
コード例 #6
0
        public async Task CreateDigitizedEvent_ShouldReturnNewSegmentAndSplittedRouteSegments_OnRouteSegmentIntersectingWithRouteNodesInGeometry()
        {
            var applicationSettings       = A.Fake <IOptions <ApplicationSetting> >();
            var routeSegmentValidator     = A.Fake <IRouteSegmentValidator>();
            var geoDatabase               = A.Fake <IGeoDatabase>();
            var routeNodeFactory          = A.Fake <IRouteNodeFactory>();
            var validationService         = A.Fake <IValidationService>();
            var routeSegment              = A.Fake <RouteSegment>();
            var lineString                = A.Fake <LineString>();
            var allIntersectingRouteNodes = new List <RouteNode>
            {
                A.Fake <RouteNode>(),
                A.Fake <RouteNode>()
            };

            A.CallTo(() => applicationSettings.Value)
            .Returns(new ApplicationSetting {
                ApplicationName = "GDB_INTEGRATOR"
            });

            A.CallTo(() => routeSegment.GetLineString()).Returns(lineString);
            A.CallTo(() => routeSegmentValidator.LineIsValid(lineString)).Returns(true);

            A.CallTo(() => geoDatabase.GetAllIntersectingRouteNodesNotIncludingEdges(routeSegment))
            .Returns(allIntersectingRouteNodes);

            var factory = new RouteSegmentCommandFactory(applicationSettings, routeSegmentValidator, geoDatabase, routeNodeFactory);

            var result = (await factory.CreateDigitizedEvent(routeSegment)).ToList();

            var newSegmentNotification = (NewRouteSegmentDigitized)result[0];
            var splittedRouteSegmentNotificationOne = (ExistingRouteSegmentSplitted)result[1];
            var splittedRouteSegmentNotificationTwo = (ExistingRouteSegmentSplitted)result[2];

            using (var scope = new AssertionScope())
            {
                result.Count().Should().Be(3);
                newSegmentNotification.RouteSegment.Should().BeEquivalentTo(routeSegment);

                splittedRouteSegmentNotificationOne.RouteNode.Should().BeEquivalentTo(allIntersectingRouteNodes[0]);
                splittedRouteSegmentNotificationOne.RouteSegmentDigitizedByUser.Should().BeNull();

                splittedRouteSegmentNotificationTwo.RouteNode.Should().BeEquivalentTo(allIntersectingRouteNodes[1]);
                splittedRouteSegmentNotificationTwo.RouteSegmentDigitizedByUser.Should().BeNull();
            }
        }
コード例 #7
0
        public async Task CreateDigitizedEvent_ShouldReturnNewRouteSegmentDigitized_OnIntersectingStartAndEndNodeCountBeingOne()
        {
            var applicationSettings    = A.Fake <IOptions <ApplicationSetting> >();
            var routeSegmentValidator  = A.Fake <IRouteSegmentValidator>();
            var geoDatabase            = A.Fake <IGeoDatabase>();
            var routeNodeFactory       = A.Fake <IRouteNodeFactory>();
            var routeSegment           = A.Fake <RouteSegment>();
            var lineString             = A.Fake <LineString>();
            var intersectingStartNodes = new List <RouteNode> {
                A.Fake <RouteNode>()
            };
            var intersectingEndNodes = new List <RouteNode> {
                A.Fake <RouteNode>()
            };
            var allIntersectingRouteNodes = new List <RouteNode>();

            A.CallTo(() => geoDatabase.GetAllIntersectingRouteNodesNotIncludingEdges(routeSegment))
            .Returns(allIntersectingRouteNodes);

            A.CallTo(() => applicationSettings.Value)
            .Returns(new ApplicationSetting {
                ApplicationName = "GDB_INTEGRATOR"
            });

            A.CallTo(() => routeSegment.GetLineString()).Returns(lineString);
            A.CallTo(() => routeSegmentValidator.LineIsValid(lineString)).Returns(true);

            A.CallTo(() => geoDatabase.GetIntersectingStartRouteNodes(routeSegment))
            .Returns(intersectingStartNodes);
            A.CallTo(() => geoDatabase.GetIntersectingEndRouteNodes(routeSegment))
            .Returns(intersectingEndNodes);

            var factory = new RouteSegmentCommandFactory(applicationSettings, routeSegmentValidator, geoDatabase, routeNodeFactory);

            var result = await factory.CreateDigitizedEvent(routeSegment);

            var newRouteSegmentDigitized = (NewRouteSegmentDigitized)result.ToList()[0];

            using (var scope = new AssertionScope())
            {
                result.Count().Should().Be(1);
                newRouteSegmentDigitized.Should().BeOfType <NewRouteSegmentDigitized>();
                newRouteSegmentDigitized.RouteSegment.Should().Be(routeSegment);
            }
        }
コード例 #8
0
        public async Task CreateDigitizedEvent_ShouldReturnNull_OnRouteSegmentApplicationNameBeingEqualToSettingsApplicationName()
        {
            var applicationSettings   = A.Fake <IOptions <ApplicationSetting> >();
            var routeSegmentValidator = A.Fake <IRouteSegmentValidator>();
            var geoDatabase           = A.Fake <IGeoDatabase>();
            var routeNodeFactory      = A.Fake <IRouteNodeFactory>();
            var routeSegment          = new RouteSegment {
                ApplicationName = "GDB_INTEGRATOR"
            };

            A.CallTo(() => applicationSettings.Value)
            .Returns(new ApplicationSetting {
                ApplicationName = "GDB_INTEGRATOR"
            });

            var factory = new RouteSegmentCommandFactory(applicationSettings, routeSegmentValidator, geoDatabase, routeNodeFactory);

            var result = await factory.CreateDigitizedEvent(routeSegment);

            result.Should().BeEmpty();
        }