示例#1
0
        public void correctToStringPrints()
        {
            string expectedOut = "Vessel: Vessel name: ThugBoat, Year built: 2001, Vessels max force: 2003";
            var    tugboat     = new Tugboat("ThugBoat", "2001", "30", 2003);

            Assert.Equal(expectedOut, tugboat.ToString());
        }
        public void TestMethod3()
        {
            Vessel ship = new Tugboat("Tug", "2013", 65.0, "20");

            var result = ship.GetVesselInfo();

            Assert.AreEqual("Tugboat Tug 2013 20", result);
        }
示例#3
0
        public void TugboatMaxForceTest()
        {
            Tugboat testMaxForce = new Tugboat("Test Tugboat", "2007", "Submarine", new Speed(78), maxForce: 3050);

            int expectedNumber = 3050;

            int actualNumber = testMaxForce.GetMaxForce;

            Assert.Equal(expectedNumber, actualNumber);
        }
示例#4
0
        static void Main(string[] args)
        {
            var cessna = new Cessna();
            var ufo    = new UFO();

            var delorean = new DeLorean();
            var ducati   = new Ducati();

            var jetski  = new JetSki();
            var tugboat = new Tugboat();


            // Build a collection of all vehicles that fly
            var flyingStuff = new List <IFly> {
                cessna, ufo
            };

            // With a single `foreach`, have each vehicle Fly()
            foreach (var vehicle in flyingStuff)
            {
                vehicle.Fly();
            }


            // Build a collection of all vehicles that operate on roads
            var roadRunners = new List <IDriver> {
                delorean, ducati
            };

            // With a single `foreach`, have each road vehicle Drive()
            foreach (var roadHog in roadRunners)
            {
                roadHog.Drive();
            }


            // Build a collection of all vehicles that operate on water
            var waveracers = new List <ISwimmer> {
                jetski, tugboat
            };

            // With a single `foreach`, have each water vehicle Drive()
            foreach (var boat in waveracers)
            {
                boat.Drive();
            }
        }