Beispiel #1
0
        public async Task Read_minimal_location_by_route_with_related_returns_basic_fields()
        {
            var routeNormaliser = new Mock <IRouteNormaliser>();

            routeNormaliser.Setup(x => x.NormaliseRouteToEntity(_databaseFixture.MatchLocationWithMinimalDetails.MatchLocationRoute, "locations")).Returns(_databaseFixture.MatchLocationWithMinimalDetails.MatchLocationRoute);
            var locationDataSource = new SqlServerMatchLocationDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);

            var result = await locationDataSource.ReadMatchLocationByRoute(_databaseFixture.MatchLocationWithMinimalDetails.MatchLocationRoute, true).ConfigureAwait(false);

            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.MatchLocationId, result.MatchLocationId);
            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.MatchLocationRoute, result.MatchLocationRoute);
            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.SecondaryAddressableObjectName, result.SecondaryAddressableObjectName);
            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.PrimaryAddressableObjectName, result.PrimaryAddressableObjectName);
            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.StreetDescription, result.StreetDescription);
            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.Locality, result.Locality);
            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.Town, result.Town);
            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.AdministrativeArea, result.AdministrativeArea);
            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.Postcode, result.Postcode);
            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.Latitude, result.Latitude);
            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.Longitude, result.Longitude);
            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.GeoPrecision, result.GeoPrecision);
            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.MatchLocationNotes, result.MatchLocationNotes);
            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.MemberGroupKey, result.MemberGroupKey);
            Assert.Equal(_databaseFixture.MatchLocationWithMinimalDetails.MemberGroupName, result.MemberGroupName);
        }
Beispiel #2
0
        public async Task Read_location_by_route_excludes_transient_teams()
        {
            var routeNormaliser = new Mock <IRouteNormaliser>();

            routeNormaliser.Setup(x => x.NormaliseRouteToEntity(_databaseFixture.MatchLocationWithFullDetails.MatchLocationRoute, "locations")).Returns(_databaseFixture.MatchLocationWithFullDetails.MatchLocationRoute);
            var locationDataSource = new SqlServerMatchLocationDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);

            var result = await locationDataSource.ReadMatchLocationByRoute(_databaseFixture.MatchLocationWithFullDetails.MatchLocationRoute, true).ConfigureAwait(false);

            foreach (var team in _databaseFixture.MatchLocationWithFullDetails.Teams.Where(x => x.TeamType == TeamType.Transient))
            {
                Assert.Null(result.Teams.SingleOrDefault(x => x.TeamId == team.TeamId));
            }
        }
Beispiel #3
0
        public async Task Read_location_by_route_sorts_active_teams_first()
        {
            var routeNormaliser = new Mock <IRouteNormaliser>();

            routeNormaliser.Setup(x => x.NormaliseRouteToEntity(_databaseFixture.MatchLocationWithFullDetails.MatchLocationRoute, "locations")).Returns(_databaseFixture.MatchLocationWithFullDetails.MatchLocationRoute);
            var locationDataSource = new SqlServerMatchLocationDataSource(_databaseFixture.ConnectionFactory, routeNormaliser.Object);

            var result = await locationDataSource.ReadMatchLocationByRoute(_databaseFixture.MatchLocationWithFullDetails.MatchLocationRoute, true).ConfigureAwait(false);

            var expectedActiveStatus = true;

            foreach (var team in result.Teams)
            {
                // The first time an inactive team is seen, set a flag to say they must all be inactive
                if (expectedActiveStatus && team.UntilYear.HasValue)
                {
                    expectedActiveStatus = false;
                }
                Assert.Equal(expectedActiveStatus, !team.UntilYear.HasValue);
            }
            Assert.False(expectedActiveStatus);
        }