Пример #1
0
 public void DriverConstructorThrowException()
 {
     UnitCar car = new UnitCar("CZ", 100, 5.5);
    
     Assert.That(() => new UnitDriver(null, car), Throws.ArgumentNullException);
     
 }
Пример #2
0
        public void Is_Calculate_Average_Horse_Power_Returns_Correct_Result(
            string model, int horsePower, double cubicCentimeters,
            string model1, int horsePower1, double cubicCentimeters1,
            string model2, int horsePower2, double cubicCentimeters2,
            string name, string name1, string name2)
        {
            //Arrange
            UnitCar unitCar  = new UnitCar(model, horsePower, cubicCentimeters);
            UnitCar unitCar1 = new UnitCar(model1, horsePower1, cubicCentimeters1);
            UnitCar unitCar2 = new UnitCar(model2, horsePower2, cubicCentimeters2);

            UnitDriver unitDriver  = new UnitDriver(name, unitCar);
            UnitDriver unitDriver1 = new UnitDriver(name1, unitCar1);
            UnitDriver unitDriver2 = new UnitDriver(name2, unitCar2);

            //Act
            RaceEntry raceEntry = new RaceEntry();

            raceEntry.AddDriver(unitDriver);
            raceEntry.AddDriver(unitDriver1);
            raceEntry.AddDriver(unitDriver2);

            //Assert
            Double expectedResult = (double)(horsePower + horsePower1 + horsePower2) / 3;

            Assert.AreEqual(expectedResult, raceEntry.CalculateAverageHorsePower());
        }
Пример #3
0
        public void DriverCreatedWhenDataIsValidShouldWork(string name)
        {
            var validCar = new UnitCar("BMW", 100, 250);
            var driver   = new UnitDriver(name, validCar);

            Assert.AreEqual(name, driver.Name);
        }
Пример #4
0
 public void Setup()
 {
     this.raceEntry      = new RaceEntry();
     this.unitCar        = new UnitCar("Test", 1, 1);
     this.unitDriver     = new UnitDriver("Test", unitCar);
     this.fakeUnitDriver = new UnitDriver("Does Not Exist", unitCar);
 }
Пример #5
0
        public void DriverCreatedWhenNameIsInvalidShouldThrow(string name)
        {
            var validCar = new UnitCar("BMW", 100, 250);

            Assert.Throws <ArgumentNullException>(() => new UnitDriver(name, validCar))
            .Message.Equals("Name cannot be null!");
        }
Пример #6
0
        public void CountShouldBeZeroWhenCreatingEmptyRaceEntry()
        {
            var validCar  = new UnitCar("BMW", 100, 250);
            var raceEntry = new RaceEntry();

            Assert.AreEqual(0, raceEntry.Counter);
        }
Пример #7
0
        public void Setup()
        {
            this.unitCar    = new UnitCar("Opel", 90, 1400);
            this.unitDriver = new UnitDriver("Pesho", this.unitCar);

            this.raceEntry = new RaceEntry();
        }
Пример #8
0
 public void Setup()
 {
     dict   = new Dictionary <string, UnitDriver>();
     car    = new UnitCar("Bokol", 100, 1000);
     driver = new UnitDriver("Koko", car);
     re     = new RaceEntry();
 }
Пример #9
0
 public void DriverConstructorTest()
 {
     UnitCar car = new UnitCar("CZ", 100, 5.5);
     UnitDriver driver = new UnitDriver("A", car);
     Assert.That(driver.Name, Is.EqualTo("A"));
     Assert.That(driver.Car, Is.EqualTo(car));
 }
Пример #10
0
 public void Setup()
 {
     car          = new UnitCar("XXX", 200, 200);
     firstDriver  = new UnitDriver("AAA", car);
     secondDriver = new UnitDriver("BBB", car);
     race         = new RaceEntry();
 }
Пример #11
0
 public void Setup()
 {
     this.race       = new RaceEntry();
     this.driver     = new Dictionary <string, UnitDriver>();
     this.unitCar    = new UnitCar(Model, HorsePower, CubicCentimeters);
     this.unitDriver = new UnitDriver(Name, unitCar);
 }
Пример #12
0
        public void Setup()
        {
            raceEntry = new RaceEntry();

            car    = new UnitCar("Nissan GT-R", 600, 3800);
            driver = new UnitDriver("n1claren", car);
        }
Пример #13
0
 public void Setup()
 {
     this.unitCar     = new UnitCar("OP", 100, 100);
     this.unitDriver  = new UnitDriver("Pesho", unitCar);
     this.unitDriver1 = new UnitDriver("Niki", unitCar);
     this.raceEntry   = new RaceEntry();
 }
 public void UniDriverCtorNotWork()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         UnitCar car       = new UnitCar("golf", 100, 2000);
         UnitDriver driver = new UnitDriver(null, car);
     });
 }
        public void UniDriverCtorWork()
        {
            UnitCar    car    = new UnitCar("golf", 100, 2000);
            UnitDriver driver = new UnitDriver("gosho", car);

            Assert.AreEqual("gosho", driver.Name);
            Assert.AreEqual(car, driver.Car);
        }
        public void UniCarCtorWork()
        {
            UnitCar car = new UnitCar("golf", 100, 2000);

            Assert.AreEqual("golf", car.Model);
            Assert.AreEqual(100, car.HorsePower);
            Assert.AreEqual(2000, car.CubicCentimeters);
        }
Пример #17
0
        public void AddDriver_ThrowsException_WhenDriverExists()
        {
            UnitCar    car    = new UnitCar("Model", 100, 500);
            UnitDriver driver = new UnitDriver("Name", car);

            raceEntry.AddDriver(driver);
            Assert.Throws <InvalidOperationException>(() => raceEntry.AddDriver(driver));
        }
Пример #18
0
        public void NameShouldWork()
        {
            UnitCar unitCar = new UnitCar("Unit", 150, 2000.0d);

            UnitDriver unitDriver = new UnitDriver("Driver", unitCar);

            Assert.AreEqual("Driver", unitDriver.Name);
        }
        public void TestConstructorOfUnitCar()
        {
            UnitCar car = new UnitCar("bmw", 200, 20.5);

            Assert.AreEqual("bmw", car.Model);
            Assert.AreEqual(200, car.HorsePower);
            Assert.AreEqual(20.5, car.CubicCentimeters);
        }
Пример #20
0
        public void CalculateAverageHorsePower_ThrowsException_WhenDriversAreLessThanMinimum()
        {
            UnitCar    car    = new UnitCar("Model", 100, 500);
            UnitDriver driver = new UnitDriver("Name", car);

            raceEntry.AddDriver(driver);
            Assert.Throws <InvalidOperationException>(() => raceEntry.CalculateAverageHorsePower());
        }
Пример #21
0
        public void AddDriver_IncreasesCount_WhenDriverIsValid()
        {
            UnitCar    car    = new UnitCar("Model", 100, 500);
            UnitDriver driver = new UnitDriver("Name", car);

            raceEntry.AddDriver(driver);
            Assert.That(raceEntry.Counter, Is.EqualTo(1));
        }
Пример #22
0
        public void Setup()
        {
            testCar = new UnitCar("Testy", 100, 250.50);

            testDriver = new UnitDriver("Bo", testCar);

            testEntry = new RaceEntry();
        }
Пример #23
0
        public void NullName()
        {
            UnitCar car = new UnitCar("model", 3000, 250);

            //UnitDriver driver = new UnitDriver(null, car);

            Assert.Throws <ArgumentNullException>(() => new UnitDriver(null, car));
        }
Пример #24
0
        public void ConstructorShouldWork()
        {
            UnitCar unitCar = new UnitCar("Unit", 150, 2000.0d);

            Assert.AreEqual("Unit", unitCar.Model);
            Assert.AreEqual(150, unitCar.HorsePower);
            Assert.AreEqual(2000.0, unitCar.CubicCentimeters);
        }
Пример #25
0
 public void CarConstructorTest()
 {
     UnitCar car = new UnitCar("CZ", 100, 5.5);
     
     Assert.That(car.Model, Is.EqualTo("CZ"));
     Assert.That(car.HorsePower, Is.EqualTo(100));
     Assert.That(car.CubicCentimeters, Is.EqualTo(5.5));
 }
Пример #26
0
        public void Is_Name_Null_Should_Throw_Null_Argument_Exception(string model, int horsePower, double cubicCentimeters, string name)
        {
            //Arrange - Act
            UnitCar unitCar = new UnitCar(model, horsePower, cubicCentimeters);

            //Assert
            Assert.Throws <ArgumentNullException>(() => new UnitDriver(name, unitCar));
        }
Пример #27
0
        public void UnitCar_Set_With_Incorrect_Values_NO_Throw()
        {
            UnitCar testIncorrect = new UnitCar("   ", -5000, 0);

            Assert.AreEqual(testIncorrect.Model, "   ");
            Assert.AreEqual(testIncorrect.HorsePower, -5000);
            Assert.AreEqual(testIncorrect.CubicCentimeters, 0);
        }
Пример #28
0
        public void ShouldSetCorrectly_WhenAddDriver()
        {
            var car    = new UnitCar("model", 100, 1000);
            var driver = new UnitDriver("Sena", car);

            race.AddDriver(driver);
            Assert.That(driver.Name, Is.EqualTo("Sena"));
        }
        public void TestConstructorUnitCarShouldCreateCarCorectly()
        {
            UnitCar car = new UnitCar("A", 10, 10.5);

            Assert.AreEqual("A", car.Model);
            Assert.AreEqual(10, car.HorsePower);
            Assert.AreEqual(10.5, car.CubicCentimeters);
        }
Пример #30
0
        public void Calculate_ThrowException_OneParticipants()
        {
            var        name   = "ivan";
            var        car    = new UnitCar("model", 10, 10);
            UnitDriver driver = new UnitDriver(name, car);

            race.AddDriver(driver);
            Assert.Throws <InvalidOperationException>(() => race.CalculateAverageHorsePower());
        }