public async Task CreateDigitizedEvent_ShouldThrowArgumentNullException_OnBeingPassedNullRouteNode()
        {
            var applicationSetting = A.Fake <IOptions <ApplicationSetting> >();
            var geoDatabase        = A.Fake <IGeoDatabase>();

            var factory = new RouteNodeCommandFactory(applicationSetting, geoDatabase);

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

            await act.Should().ThrowExactlyAsync <ArgumentNullException>();
        }
        public async Task CreateDigitizedEvent_ShouldReturnDoNothing_OnRouteNodeApplicationNameBeingSettingsApplicationName()
        {
            var applicationSetting = A.Fake <IOptions <ApplicationSetting> >();
            var geoDatabase        = A.Fake <IGeoDatabase>();

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

            var factory = new RouteNodeCommandFactory(applicationSetting, geoDatabase);

            var routeNode = new RouteNode(Guid.Empty, null, Guid.Empty, String.Empty, "GDB_INTEGRATOR");
            var result    = (DoNothing)((await factory.CreateDigitizedEvent(routeNode)).First());

            result.Should().BeOfType <DoNothing>();
        }
        public async Task CreateDigitizedEvent_ShouldReturnRouteNodeAdded_OnIntersectingRouteSegmentsCountBeingZero()
        {
            var applicationSetting = A.Fake <IOptions <ApplicationSetting> >();
            var geoDatabase        = A.Fake <IGeoDatabase>();
            var routeNode          = A.Fake <RouteNode>();

            A.CallTo(() => geoDatabase.GetIntersectingRouteSegments(routeNode))
            .Returns(new List <RouteSegment>());

            var factory = new RouteNodeCommandFactory(applicationSetting, geoDatabase);

            var result = (NewRouteNodeDigitized)((await factory.CreateDigitizedEvent(routeNode)).First());

            using (new AssertionScope())
            {
                result.RouteNode.Should().BeEquivalentTo(routeNode);
            }
        }
        public async Task CreateDigitizedEvent_ShouldReturnInvalidRouteNodeOperation_OnIntersectingRouteNodeCountBeingGreaterThanZero()
        {
            var applicationSetting     = A.Fake <IOptions <ApplicationSetting> >();
            var geoDatabase            = A.Fake <IGeoDatabase>();
            var routeNode              = A.Fake <RouteNode>();
            var intersectingRouteNodes = new List <RouteNode> {
                A.Fake <RouteNode>()
            };

            A.CallTo(() => geoDatabase.GetIntersectingRouteNodes(routeNode))
            .Returns(intersectingRouteNodes);

            var factory = new RouteNodeCommandFactory(applicationSetting, geoDatabase);

            var result = (InvalidRouteNodeOperation)((await factory.CreateDigitizedEvent(routeNode)).First());

            using (new AssertionScope())
            {
                result.RouteNode.Should().BeEquivalentTo(routeNode);
            }
        }
        public async Task CreateDigitizedEvent_ShouldReturnExistingRouteSegmentSplitted_OnIntersectingRouteSegmentsCountBeingOne()
        {
            var applicationSetting = A.Fake <IOptions <ApplicationSetting> >();
            var geoDatabase        = A.Fake <IGeoDatabase>();
            var routeNode          = A.Fake <RouteNode>();
            var routeSegments      = new List <RouteSegment> {
                new RouteSegment()
            };

            A.CallTo(() => geoDatabase.GetIntersectingRouteSegments(routeNode))
            .Returns(routeSegments);

            var factory = new RouteNodeCommandFactory(applicationSetting, geoDatabase);

            var result = await factory.CreateDigitizedEvent(routeNode);

            var firstEvent = (ExistingRouteSegmentSplitted)result[0];

            using (new AssertionScope())
            {
                firstEvent.RouteNode.Should().BeEquivalentTo(routeNode);
            }
        }