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); }
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); }
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); }
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); }
public void Initialize() { IRace race = new Race(this.distance, this.windSpeed, this.oceanCurrenSpeed, this.allowMotorBoats); this.Controller = new BoatSimulatorController(new BoatSimulatorDatabase(), race); }