public async Task Create_ShouldReturnRouteSegmentInfoUpdated_OnUpdatedSegmentInfo()
        {
            var geoDatabase = A.Fake <IGeoDatabase>();
            var before      = new RouteSegment();
            var after       = new RouteSegment
            {
                RouteSegmentInfo = new RouteSegmentInfo
                {
                    Height = "10",
                    Kind   = RouteSegmentKindEnum.Indoor,
                    Width  = "20"
                }
            };

            var factory = new RouteSegmentInfoCommandFactory(geoDatabase);
            var result  = await factory.Create(before, after);

            var infoUpdated = (RouteSegmentInfoUpdated)result.First();

            using (var scope = new AssertionScope())
            {
                result.Count().Should().Be(1);
                infoUpdated.RouteSegment.Should().BeEquivalentTo(after);
            }
        }
        public async Task Create_ShouldReturnDoNothingEvent_OnBeforeBeingNull()
        {
            var          geoDatabase = A.Fake <IGeoDatabase>();
            RouteSegment before      = null;
            var          after       = new RouteSegment();

            var factory = new RouteSegmentInfoCommandFactory(geoDatabase);

            var result = await factory.Create(before, after);

            var doNothingEvent = (DoNothing)result.First();

            using (var scope = new AssertionScope())
            {
                result.Count().Should().Be(1);
                doNothingEvent.Should().BeOfType(typeof(DoNothing));
            }
        }
        public async Task Create_ShouldReturnDoNothingEvent_ReturnedGetRouteSegmentShadowTableBeingNull()
        {
            var          geoDatabase = A.Fake <IGeoDatabase>();
            RouteSegment before      = new RouteSegment();
            var          after       = new RouteSegment();

            A.CallTo(() => geoDatabase.GetRouteSegmentShadowTable(after.Mrid, true)).Returns <RouteSegment>(null);

            var factory = new RouteSegmentInfoCommandFactory(geoDatabase);
            var result  = await factory.Create(before, after);

            var doNothingEvent = (DoNothing)result.First();

            using (var scope = new AssertionScope())
            {
                result.Count().Should().Be(1);
                doNothingEvent.Should().BeOfType(typeof(DoNothing));
            }
        }
        public async Task Create_ShouldReturnDoNothing_OnShadowTableRouteSegmentBeingEqToAfter()
        {
            var routeSegmentId = Guid.NewGuid();
            var geoDatabase    = A.Fake <IGeoDatabase>();
            var before         = new RouteSegment
            {
                Mrid             = routeSegmentId,
                RouteSegmentInfo = new RouteSegmentInfo
                {
                    Height = "10"
                }
            };
            var after = new RouteSegment
            {
                Mrid             = routeSegmentId,
                RouteSegmentInfo = new RouteSegmentInfo
                {
                    Height = "10"
                }
            };
            var shadowTableSegment = new RouteSegment
            {
                Mrid             = routeSegmentId,
                RouteSegmentInfo = new RouteSegmentInfo
                {
                    Height = "10"
                }
            };

            A.CallTo(() => geoDatabase.GetRouteSegmentShadowTable(after.Mrid, true)).Returns(shadowTableSegment);

            var factory = new RouteSegmentInfoCommandFactory(geoDatabase);
            var result  = await factory.Create(before, after);

            var doNothingEvent = (DoNothing)result.First();

            using (var scope = new AssertionScope())
            {
                result.Count().Should().Be(1);
                doNothingEvent.Should().BeOfType(typeof(DoNothing));
            }
        }
        public async Task Create_ShouldReturnSafetyInfoUpdated_OnUpdatedSafetyInfo()
        {
            var geoDatabase = A.Fake <IGeoDatabase>();
            var before      = new RouteSegment();
            var after       = new RouteSegment
            {
                SafetyInfo = new SafetyInfo
                {
                    Classification = "My test classification"
                }
            };

            var factory = new RouteSegmentInfoCommandFactory(geoDatabase);
            var result  = await factory.Create(before, after);

            var infoUpdated = (RouteSegmentSafetyInfoUpdated)result.First();

            using (var scope = new AssertionScope())
            {
                result.Count().Should().Be(1);
                infoUpdated.RouteSegment.Should().BeEquivalentTo(after);
            }
        }
        public async Task Create_ShouldReturnMappingInfoUpdated_OnUpdatedMappingInfo()
        {
            var geoDatabase = A.Fake <IGeoDatabase>();
            var before      = new RouteSegment();
            var after       = new RouteSegment
            {
                MappingInfo = new MappingInfo
                {
                    HorizontalAccuracy = "10"
                }
            };

            var factory = new RouteSegmentInfoCommandFactory(geoDatabase);
            var result  = await factory.Create(before, after);

            var infoUpdated = (RouteSegmentMappingInfoUpdated)result.First();

            using (var scope = new AssertionScope())
            {
                result.Count().Should().Be(1);
                infoUpdated.RouteSegment.Should().BeEquivalentTo(after);
            }
        }
        public async Task Create_ShouldReturnLifecycleInfoUpdated_OnUpdatedLifecycleInfo()
        {
            var geoDatabase = A.Fake <IGeoDatabase>();
            var before      = new RouteSegment();
            var after       = new RouteSegment
            {
                LifeCycleInfo = new LifecycleInfo
                {
                    DeploymentState = DeploymentStateEnum.Installed
                }
            };

            var factory = new RouteSegmentInfoCommandFactory(geoDatabase);
            var result  = await factory.Create(before, after);

            var infoUpdated = (RouteSegmentLifecycleInfoUpdated)result.First();

            using (var scope = new AssertionScope())
            {
                result.Count().Should().Be(1);
                infoUpdated.RouteSegment.Should().BeEquivalentTo(after);
            }
        }