示例#1
0
        public void Then_The_Fields_Are_Correctly_Mapped_From_GetLocationQueryResult(GetLocationQueryResult source)
        {
            var location = source.Location;

            var actual = (GetLocationsListItem)location;

            actual.Should().BeEquivalentTo(location, options => options.ExcludingMissingMembers());
            actual.Location.Coordinates.FirstOrDefault().Should().Be(location.Lat);
            actual.Location.Coordinates.LastOrDefault().Should().Be(location.Long);
            GetLocationsListItem.Geometry.Type.Should().Be("Point");
        }
        public async Task Then_Gets_Location_From_Mediator(
            string authorityName,
            string locationName,
            GetLocationQueryResult queryResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] LocationsController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetLocationQuery>(request =>
                                                request.LocationName == locationName &&
                                                request.AuthorityName == authorityName),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(queryResult);

            var controllerResult = await controller.Index(locationName, authorityName) as ObjectResult;

            var model = controllerResult.Value as GetLocationsListItem;

            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
            model.Should().BeEquivalentTo(queryResult.Location, options => options.ExcludingMissingMembers());
        }