Inheritance: SimTelemetry.Domain.Entities.Wheel
Esempio n. 1
0
        public void TestWheels()
        {
            var hasException = false;
            var WheelLF      = new CarTestWheel(WheelLocation.FRONTLEFT, 0.6f, 1000, new Range(90, 110, 97),
                                                new Range(85, 90, 85), new Range(140, 170, 155));
            var WheelRF = new CarTestWheel(WheelLocation.FRONTRIGHT, 0.6f, 1000, new Range(90, 110, 97),
                                           new Range(85, 90, 85), new Range(140, 170, 155));
            var WheelLR = new CarTestWheel(WheelLocation.REARLEFT, 0.6f, 1000, new Range(90, 110, 97),
                                           new Range(85, 90, 85), new Range(140, 170, 155));
            var WheelRR = new CarTestWheel(WheelLocation.REARRIGHT, 0.6f, 1000, new Range(90, 110, 97),
                                           new Range(85, 90, 85), new Range(140, 170, 155));

            // Left - front
            car.Assign(WheelLF);

            Assert.IsNotNull(car.Wheels);
            Assert.AreEqual(1, car.Wheels.Count());
            Assert.IsNotNull(car.Wheels.FirstOrDefault());
            Assert.IsNotNull(car.Wheels.Where(x => x.Location == WheelLF.Location).FirstOrDefault());
            try
            {
                car.Assign(WheelLF);
            }
            catch (CarAlreadyHasWheelException ex)
            {
                // good
                hasException = true;
            }
            catch (Exception ex)
            {
                // Bad
                Assert.Fail();
            }
            Assert.True(hasException);

            // Right - front
            hasException = false;
            car.Assign(WheelRF);

            Assert.AreEqual(2, car.Wheels.Count());
            Assert.IsNotNull(car.Wheels.Where(x => x.Location == WheelRF.Location).FirstOrDefault());
            try
            {
                car.Assign(WheelRF);
            }
            catch (CarAlreadyHasWheelException ex)
            {
                // good
                hasException = true;
            }
            catch (Exception ex)
            {
                // Bad
                Assert.Fail();
            }
            Assert.True(hasException);

            // Left - rear
            hasException = false;
            car.Assign(WheelLR);

            Assert.AreEqual(3, car.Wheels.Count());
            Assert.IsNotNull(car.Wheels.Where(x => x.Location == WheelLR.Location).FirstOrDefault());
            try
            {
                car.Assign(WheelLR);
            }
            catch (CarAlreadyHasWheelException ex)
            {
                // good
                hasException = true;
            }
            catch (Exception ex)
            {
                // Bad
                Assert.Fail();
            }
            Assert.True(hasException);

            // Right - rear
            hasException = false;
            car.Assign(WheelRR);

            Assert.AreEqual(4, car.Wheels.Count());
            Assert.IsNotNull(car.Wheels.Where(x => x.Location == WheelRR.Location).FirstOrDefault());
            try
            {
                car.Assign(WheelRR);
            }
            catch (CarAlreadyHasWheelException ex)
            {
                // good
                hasException = true;
            }
            catch (Exception ex)
            {
                // Bad
                Assert.Fail();
            }
            Assert.True(hasException);

            Assert.AreEqual(car.Wheels.ElementAt(0), WheelLF);
            Assert.AreEqual(car.Wheels.ElementAt(1), WheelRF);
            Assert.AreEqual(car.Wheels.ElementAt(2), WheelLR);
            Assert.AreEqual(car.Wheels.ElementAt(3), WheelRR);
        }
Esempio n. 2
0
        public void TestWheels()
        {
            var hasException = false;
            var WheelLF = new CarTestWheel(WheelLocation.FRONTLEFT, 0.6f, 1000, new Range(90, 110, 97),
                                             new Range(85, 90, 85), new Range(140, 170, 155));
            var WheelRF = new CarTestWheel(WheelLocation.FRONTRIGHT, 0.6f, 1000, new Range(90, 110, 97),
                                             new Range(85, 90, 85), new Range(140, 170, 155));
            var WheelLR = new CarTestWheel(WheelLocation.REARLEFT, 0.6f, 1000, new Range(90, 110, 97),
                                             new Range(85, 90, 85), new Range(140, 170, 155));
            var WheelRR = new CarTestWheel(WheelLocation.REARRIGHT, 0.6f, 1000, new Range(90, 110, 97),
                                             new Range(85, 90, 85), new Range(140, 170, 155));

            // Left - front
            car.Assign(WheelLF);

            Assert.IsNotNull(car.Wheels);
            Assert.AreEqual(1, car.Wheels.Count());
            Assert.IsNotNull(car.Wheels.FirstOrDefault());
            Assert.IsNotNull(car.Wheels.Where(x => x.Location == WheelLF.Location).FirstOrDefault());
            try
            {
                car.Assign(WheelLF);
            }
            catch (CarAlreadyHasWheelException ex)
            {
                // good
                hasException = true;
            }
            catch (Exception ex)
            {
                // Bad
                Assert.Fail();
            }
            Assert.True(hasException);

            // Right - front
            hasException = false;
            car.Assign(WheelRF);

            Assert.AreEqual(2, car.Wheels.Count());
            Assert.IsNotNull(car.Wheels.Where(x => x.Location == WheelRF.Location).FirstOrDefault());
            try
            {
                car.Assign(WheelRF);
            }
            catch (CarAlreadyHasWheelException ex)
            {
                // good
                hasException = true;
            }
            catch (Exception ex)
            {
                // Bad
                Assert.Fail();
            }
            Assert.True(hasException);

            // Left - rear
            hasException = false;
            car.Assign(WheelLR);

            Assert.AreEqual(3, car.Wheels.Count());
            Assert.IsNotNull(car.Wheels.Where(x => x.Location == WheelLR.Location).FirstOrDefault());
            try
            {
                car.Assign(WheelLR);
            }
            catch (CarAlreadyHasWheelException ex)
            {
                // good
                hasException = true;
            }
            catch (Exception ex)
            {
                // Bad
                Assert.Fail();
            }
            Assert.True(hasException);

            // Right - rear
            hasException = false;
            car.Assign(WheelRR);

            Assert.AreEqual(4, car.Wheels.Count());
            Assert.IsNotNull(car.Wheels.Where(x => x.Location == WheelRR.Location).FirstOrDefault());
            try
            {
                car.Assign(WheelRR);
            }
            catch (CarAlreadyHasWheelException ex)
            {
                // good
                hasException = true;
            }
            catch (Exception ex)
            {
                // Bad
                Assert.Fail();
            }
            Assert.True(hasException);

            Assert.AreEqual(car.Wheels.ElementAt(0), WheelLF);
            Assert.AreEqual(car.Wheels.ElementAt(1), WheelRF);
            Assert.AreEqual(car.Wheels.ElementAt(2), WheelLR);
            Assert.AreEqual(car.Wheels.ElementAt(3), WheelRR);
        }