Esempio n. 1
0
        public void ButTheyAreStillFarms()
        {
            var windFarm = new WindFarm(); // 'WindFarm' INHERITS from 'Farm'

            // TODO Please remove the incorrect assertion.
            Assert.That(windFarm, Is.AssignableTo <Farm>());
            Assert.That(windFarm, Is.Not.AssignableTo <Farm>());
        }
        public void ButTheyAreStillFarms()
        {
            var windFarm = new WindFarm(); // 'WindFarm' INHERITS from 'Farm'

            // TODO Please remove the incorrect assertion.
            Assert.That(windFarm, Is.AssignableTo<Farm>());
            Assert.That(windFarm, Is.Not.AssignableTo<Farm>());
        }
Esempio n. 3
0
        public void OrWeCanHaveMoreSpecificFarms()
        {
            var hilltopFarm = new WindFarm();   // 'WindFarm' INHERITS from 'Farm'
            var manorFarm   = new AnimalFarm(); // 'AnimalFarm' INHERITS from 'Farm'

            // TODO Please remove the incorrect assertion.
            Assert.That(hilltopFarm.GetType(), Is.EqualTo(manorFarm.GetType()));
            Assert.That(hilltopFarm.GetType(), Is.Not.EqualTo(manorFarm.GetType()));
        }
        public void OrWeCanHaveMoreSpecificFarms()
        {
            var hilltopFarm = new WindFarm(); // 'WindFarm' INHERITS from 'Farm'
            var manorFarm = new AnimalFarm(); // 'AnimalFarm' INHERITS from 'Farm'

            // TODO Please remove the incorrect assertion.
            Assert.That(hilltopFarm.GetType(), Is.EqualTo(manorFarm.GetType()));
            Assert.That(hilltopFarm.GetType(), Is.Not.EqualTo(manorFarm.GetType()));
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            WindFarm windFarm = new WindFarm
            {
                Location = new Location {
                    Latitude = 51.453, Longitude = 2.6
                },
                Turbines = new[] {
                    new Turbine
                    {
                        Id          = Guid.NewGuid(),
                        TowerHeight = 80,
                        BladeLength = 60,
                        Location    = new Location {
                            Latitude = 51.454, Longitude = 2.6
                        }
                    },
                    new Turbine
                    {
                        TowerHeight = 80,
                        BladeLength = 100, // Blade will hit the ground
                        Location    = new Location {
                            Latitude = 51.452, Longitude = 2.6
                        }
                    }
                }
            };

            var calculation = new HeightCalculation();

            Console.WriteLine($"Average turbine height: {calculation.AverageTurbineHeight(windFarm)}m");

            try
            {
                WindFarm emptyFarm = new WindFarm();
                // Throws ArgumentNull because the turbine list is null
                Console.WriteLine($"Average turbine height in empty windfarm: {calculation.AverageTurbineHeight(emptyFarm)}m");
            }
            catch (Exception e)
            {
                Console.WriteLine($"Caught {e.GetType().Name}");
            }

            try
            {
                WindFarm emptyFarm = new WindFarm {
                    Turbines = Array.Empty <Turbine>()
                };
                // Returns NaN because the turbine list is empty
                Console.WriteLine($"Average turbine height in empty windfarm: {calculation.AverageTurbineHeight(emptyFarm)}m");
            }
            catch (Exception e)
            {
                Console.WriteLine($"Caught {e.GetType().Name}");
            }
        }
Esempio n. 6
0
        public void SoTheyMayShareSomeBehavour()
        {
            var animalFarm = new AnimalFarm();

            // The default 'Farm' location is outdoors.
            Assert.That(animalFarm.GetLocation(), Is.EqualTo("outdoors"));

            var windFarm = new WindFarm();

            // TODO Please remove the incorrect assertion.
            Assert.That(windFarm.GetLocation(), Is.EqualTo("indoors"));
            Assert.That(windFarm.GetLocation(), Is.EqualTo("outdoors"));
        }
        public void SoTheyMayShareSomeBehavour()
        {
            var animalFarm = new AnimalFarm();
            // The default 'Farm' location is outdoors.
            Assert.That(animalFarm.GetLocation(), Is.EqualTo("outdoors"));

            var windFarm = new WindFarm();

            // TODO Please remove the incorrect assertion.
            Assert.That(windFarm.GetLocation(), Is.EqualTo("indoors"));
            Assert.That(windFarm.GetLocation(), Is.EqualTo("outdoors"));

        }
Esempio n. 8
0
        public void ButTheyMayAlsoHaveVeryDifferentBehavour()
        {
            var sunnydaleFarm = new Farm();
            var manorFarm     = new AnimalFarm();
            var windFarm      = new WindFarm();

            // You can feed animals on these two farms
            Assert.That(() => FeedTheAnimalsAt(sunnydaleFarm), Throws.Nothing);
            Assert.That(() => FeedTheAnimalsAt(manorFarm), Throws.Nothing);

            // TODO Please remove the incorrect assertion.
            Assert.That(() => FeedTheAnimalsAt(windFarm), Throws.Nothing);
            Assert.That(() => FeedTheAnimalsAt(windFarm), Throws.InstanceOf <FarmContainsNoAnimalsException>());
        }
        public void ButTheyMayAlsoHaveVeryDifferentBehavour()
        {
            var sunnydaleFarm = new Farm();
            var manorFarm = new AnimalFarm();
            var windFarm = new WindFarm();

            // You can feed animals on these two farms
            Assert.That(() => FeedTheAnimalsAt(sunnydaleFarm), Throws.Nothing);
            Assert.That(() => FeedTheAnimalsAt(manorFarm), Throws.Nothing);

            // TODO Please remove the incorrect assertion.
            Assert.That(() => FeedTheAnimalsAt(windFarm), Throws.Nothing);
            Assert.That(() => FeedTheAnimalsAt(windFarm), Throws.InstanceOf<FarmContainsNoAnimalsException>());
        }
Esempio n. 10
0
        public WindFarmViewModel()
        {
            WindFarm = new WindFarm(WindFarmAssistant.windFarmName);

            ListWindTurbines = new List <WindTurbine>();

            for (int i = 0; i < WindFarmAssistant.numberOfWindTurbines; i++)
            {
                ListWindTurbines.Add(new WindTurbine(i, "Wind Turbine"));
            }

            TabItems = new ObservableCollection <WindTurbineViewModel>();

            for (int i = 0; i < WindFarmAssistant.numberOfWindTurbines; i++)
            {
                TabItems.Add(new WindTurbineViewModel(ListWindTurbines[i]));
            }

            SelectedTab = TabItems[0];
        }
Esempio n. 11
0
 public void Init()
 {
     windFarm = new WindFarm("theWindName");
 }
Esempio n. 12
0
        public double AverageTurbineHeight(WindFarm windFarm)
        {
            double totalHeight = windFarm.Turbines.Sum(t => t.TowerHeight + t.BladeLength);

            return(totalHeight / windFarm.Turbines.Count);
        }