Пример #1
0
        public Rover(ILocationValidator locationValidator)
        {
            this.locationValidator   = locationValidator;
            movementMethodDictionary = new Dictionary <Movement, Action>
            {
                { Movement.Left, () => leftMoveDictionary[Direction].Invoke() },
                { Movement.Right, () => rightMoveDictionary[Direction].Invoke() },
                { Movement.Forward, () => forwardMoveDictionary[Direction].Invoke() }
            };

            leftMoveDictionary = new Dictionary <Direction, Action>
            {
                { Direction.North, () => Direction = Direction.West },
                { Direction.East, () => Direction = Direction.North },
                { Direction.South, () => Direction = Direction.East },
                { Direction.West, () => Direction = Direction.South }
            };

            rightMoveDictionary = new Dictionary <Direction, Action>
            {
                { Direction.North, () => Direction = Direction.East },
                { Direction.East, () => Direction = Direction.South },
                { Direction.South, () => Direction = Direction.West },
                { Direction.West, () => Direction = Direction.North }
            };

            forwardMoveDictionary = new Dictionary <Direction, Action>
            {
                { Direction.North, () => { preLocation = new Location(Location.X, Location.Y + 1); } },
                { Direction.East, () => { preLocation = new Location(Location.X + 1, Location.Y); } },
                { Direction.South, () => { preLocation = new Location(Location.X, Location.Y - 1); } },
                { Direction.West, () => { preLocation = new Location(Location.X - 1, Location.Y); } }
            };
        }
Пример #2
0
        public void CreateNewLocationServiceOfTypeILocationService_WithNullAsILocationValidator_ThrowsNullReferenceException()
        {
            ILocationRepository locationRepository = new Mock <ILocationRepository>().Object;
            ILocationValidator  validator          = null as LocationValidator;
            Action action = () => new LocationService(locationRepository, validator);

            action.Should().Throw <ParameterCannotBeNullException>().WithMessage("LocationValidator Parameter Can't be null");
        }
Пример #3
0
        public Location CreateVerify(
            ILocationRepository locationRepository = null,
            ILocationValidator validator           = null)
        {
            locationRepository ??= new Mock <ILocationRepository>().Object;
            validator ??= new Mock <ILocationValidator>().Object;

            var service  = new LocationService(locationRepository, validator) as ILocationService;
            var location = _locationEntityTestHelper.ValidLocation();

            service.Create(location);
            return(location);
        }
Пример #4
0
        public void CreateInvalid <T>(
            ILocationRepository repository = null,
            ILocationValidator validator   = null,
            Location location = null,
            string message    = null) where T : Exception
        {
            Action action = () => LocationService(repository, validator).Create(location);

            if (message != null)
            {
                action.Should().Throw <T>()
                .And.Message.Should().Be(message);
            }
            else
            {
                action.Should().Throw <T>();
            }
        }
Пример #5
0
 public CommandFactory(ILocationValidator locationValidator)
 {
     this.locationValidator = locationValidator;
 }
 public GeolocationController(IGeolocationDetailsManager detailsManager, ILocationValidator locationValidator)
 {
     this.detailsManager    = detailsManager;
     this.locationValidator = locationValidator;
 }
Пример #7
0
 public LocationService(ILocationQuery locationQuery, ILocationRepository locationRepository, ILocationValidator locationValidator)
 {
     _locationQuery      = locationQuery;
     _locationRepository = locationRepository;
     _locationValidator  = locationValidator;
 }
Пример #8
0
 public LandingCommand(ILocationValidator locationValidator, Location location, Direction direction)
 {
     this.locationValidator = locationValidator;
     this.Location          = location;
     this.Direction         = direction;
 }
Пример #9
0
 public LocationService(ILocationRepository locationRepository, ILocationValidator locationValidator)
 {
     _locationRepository = locationRepository ?? throw new ParameterCannotBeNullException("LocationRepository");
     _locationValidator  = locationValidator ?? throw new ParameterCannotBeNullException("LocationValidator");
 }
Пример #10
0
 private ILocationService LocationService(
     ILocationRepository repository = null,
     ILocationValidator validator   = null)
 {
     return(new LocationService(repository, validator));
 }