Inheritance: Microsoft.AspNetCore.Mvc.Controller
 public void ControllerHasRouteAtttributeWithTheCorrectTemplate()
 {
     var sut = new ClosestLocationsController(null);
     var attribute = sut.GetAttributes().OfType<RouteAttribute>().SingleOrDefault();
     Assert.NotNull(attribute);
     Assert.Equal(attribute.Template, "api/closest");
 }
 public void GetHasHttpGetAttributeWithCorrectTemplate()
 {
     var sut = new ClosestLocationsController(null);
     var attribute = sut.GetAttributesOn(x => x.Get(It.IsAny<double>(), It.IsAny<double>(), It.IsAny<int>(), It.IsAny<int>())).OfType<HttpGetAttribute>().SingleOrDefault();
     Assert.NotNull(attribute);
     Assert.Equal(attribute.Template, "{lat}/{lon}/{distance}/{count}");
 }
        public void GetReturnsCorrectModel()
        {
            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.Send(It.IsAny<ClosestLocationsQuery>())).Returns(new List<ClosestLocation>());

            var sut = new ClosestLocationsController(mediator.Object);
            var results = sut.Get(It.IsAny<double>(), It.IsAny<double>(), It.IsAny<int>(), It.IsAny<int>()).ToList();

            Assert.IsType<List<ClosestLocation>>(results);
        }
        public void GetSendsClosestLocationsQueryWithCorrectLocationQuery()
        {
            const double latitude = 1;
            const double longitude = 1;
            const int distance = 1;
            const int count = 1;

            var mediator = new Mock<IMediator>();

            var sut = new ClosestLocationsController(mediator.Object);
            sut.Get(latitude, longitude, distance, count);

            mediator.Verify(x => x.Send(It.Is<ClosestLocationsQuery>(y =>
                y.LocationQuery.Longitude == longitude &&
                y.LocationQuery.Latitude == latitude &&
                y.LocationQuery.Distance == distance &&
                y.LocationQuery.MaxRecordsToReturn == count)));
        }