Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting");
            Lambo    lambo    = new Lambo();
            GeoMetro geometro = new GeoMetro();

            List <Vehicle> vehicles = new List <Vehicle>();

            vehicles.Add(lambo);
            vehicles.Add(geometro);

            //Here we see PolyMorphism at work, it enables being able to call the honk/revEngine
            //functions on multiple
            foreach (Vehicle car in vehicles)
            {
                Console.WriteLine(car.honk());
                Console.WriteLine(car.revEngine());
            }
        }
        public async Task GetGeoMetro_ShouldReturnGeoMetroDetails()
        {
            // Arrange
            var id       = 1;
            var geoMetro = new GeoMetro {
                MetroName = "Belrose"
            };

            Mock.Mock <IGeoLocationService>().Setup(x => x.GetGeoMetro(id)).ReturnsAsync(geoMetro);

            // Act
            var results = await Controller.GetGeoMetro(id);

            // Assert
            Assert.That(results, Is.Not.Null);
            Assert.That(results, Is.TypeOf <OkNegotiatedContentResult <GeoMetroViewModel> >());
            var content = ((OkNegotiatedContentResult <GeoMetroViewModel>)results).Content;

            Assert.That(content.MetroName, Is.EqualTo(geoMetro.MetroName));
        }