Example #1
0
        public void OpenRace_WitSetRace_ShoulThrowRaceAlreadyExistsException()
        {
            IRace race = new Race(this.distance, this.windSpeed, this.oceanCurrenSpeed, this.allowMotorBoats);

            this.Controller = new BoatSimulatorController(new BoatSimulatorDatabase(), race);
            this.Controller.OpenRace(this.distance, this.windSpeed, this.oceanCurrenSpeed, this.allowMotorBoats);
        }
Example #2
0
        public void OpenRace_WithoustSetRace_ShoulCreateANewRace()
        {
           
            IRace race = new Race(this.distance, this.windSpeed, this.oceanCurrenSpeed, this.allowMotorBoats);

            this.Controller.OpenRace(this.distance, this.windSpeed, this.oceanCurrenSpeed, this.allowMotorBoats);
            Assert.AreEqual(race.Distance, this.Controller.CurrentRace.Distance);
            Assert.AreEqual(race.AllowsMotorboats, this.Controller.CurrentRace.AllowsMotorboats);
            Assert.AreEqual(race.OceanCurrentSpeed, this.Controller.CurrentRace.OceanCurrentSpeed);
            Assert.AreEqual(race.WindSpeed, this.Controller.CurrentRace.WindSpeed);
        }
Example #3
0
        public void SignUp_HavingTheBoatInDatabase_ShouldSignUpSuccessfully()
        {
            var repository = new Mock<IRepository<IBoat>>();
            repository.Setup(s => s.GetItem("Luxury101")).Returns(new SailBoat("Luxury101", 50, 90));
            
            var database = new Mock<BoatSimulatorDatabase>();
            database.SetupGet(m => m.Boats).Returns(repository.Object);

            IRace race = new Race(this.distance, this.windSpeed, this.oceanCurrenSpeed, this.allowMotorBoats);
            this.Controller = new BoatSimulatorController(database.Object, race);

            this.Controller.SignUpBoat("Luxury101");

           int participantsCount =  this.Controller.CurrentRace.GetParticipants().Count;
            Assert.AreEqual(1, participantsCount);
        }
Example #4
0
        public string OpenRace(int distance, int windSpeed, int oceanCurrentSpeed, bool allowsMotorboats)
        {
            IRace race = new Race(distance, windSpeed, oceanCurrentSpeed, allowsMotorboats);
            Validator.ValidateRaceIsEmpty(this.CurrentRace);
            this.CurrentRace = race;

            return
                string.Format(
                    "A new race with distance {0} meters, wind speed {1} m/s and ocean current speed {2} m/s has been set.",
                    distance,
                    windSpeed,
                    oceanCurrentSpeed);
        }
Example #5
0
 public void Initialize()
 {
     IRace race = new Race(this.distance, this.windSpeed, this.oceanCurrenSpeed, this.allowMotorBoats);
     this.Controller = new BoatSimulatorController(new BoatSimulatorDatabase(), race);
 }