public void OneLocationIsFoundReturnsNoError()
        {
            // Arrange
            var locationResult      = new Mock <Location>();
            var expectedResult      = ValidationResult.Success;
            var locationId          = "good location";
            var locationPersistence = new Mock <IAsyncQueryHandler <LocationRetrievalByIdQuery, Location> >();

            locationPersistence
            .Setup(persistence => persistence.Handle(It.Is <LocationRetrievalByIdQuery>(o => o.LocationId == "good location")))
            .Returns(Task.FromResult(locationResult.Object));

            var serviceProvider = new Mock <IServiceProvider>();

            serviceProvider.Setup(context => context.GetService(It.IsAny <Type>()))
            .Returns(locationPersistence.Object);
            var sut = new ValidLocation();

            // Act
            var result = sut.GetValidationResult(
                locationId,
                new ValidationContext(new object(), serviceProvider.Object, new Dictionary <object, object>()));

            // Assert
            Assert.Equal(expectedResult, result);
        }
        public void NullLocationIdSuppliedReturnsError()
        {
            // Arrange
            object locationId     = null;
            var    expectedResult = nameof(SystemValidationErrors.Required);

            var locationPersistence = new Mock <IAsyncQueryHandler <LocationRetrievalByIdQuery, Location> >();

            locationPersistence
            .Setup(persistence => persistence.Handle(It.Is <LocationRetrievalByIdQuery>(o => o.LocationId == string.Empty)))
            .Returns(Task.FromResult <Location>(null));

            var serviceProvider = new Mock <IServiceProvider>();

            serviceProvider.Setup(context => context.GetService(It.IsAny <Type>()))
            .Returns(locationPersistence.Object);
            var sut = new ValidLocation();

            // Act
            var result = sut.GetValidationResult(locationId,
                                                 new ValidationContext(new object(), serviceProvider.Object, new Dictionary <object, object>()));

            // Assert
            Assert.Equal(expectedResult, result.ErrorMessage);
        }