예제 #1
0
 private void listItem(DeviceGroup g)
 {
     foreach (var d in g.Children.OfType<DeviceItem>())
     {
       output.WriteLine("{0} {1} watts x {2} hours = {3} units", d.Name, d.Watts, d.HoursPerDay, d.UnitsPerMonth);
     }
 }
예제 #2
0
            public void AllowToAddSameObjectMultipleTimesInTheGroup()
            {
                var g = new DeviceGroup();
                var d = new DeviceItem();
                d.Watts = 65;
                d.HoursPerDay = 10;
                d.DaysPerMonth = 20;

                g.Children.Add(d);
                g.Children.Add(d);  // second notebook

                Assert.Equal(2,g.Children.Count);
                Assert.Equal(26.0,g.UnitsPerMonth);
            }
예제 #3
0
            public void OneDeviceInTheGroup()
            {
                var g = new DeviceGroup();
                var d = new DeviceItem();

                d.Watts = 65;
                d.HoursPerDay = 10;
                d.DaysPerMonth = 20;

                g.Children.Add(d);

                listItems(g);

                Assert.Equal(13.0, g.UnitsPerMonth);
            }
예제 #4
0
            public void AllowToAddSameObjectMutipleTimesInTherGroup()
            {
                var g = new DeviceGroup();
                var d = new DeviceItem();

                d.Name = "Notebook";
                d.Watts = 65;
                d.HoursPerDay = 10;
                d.DaysPerMonth = 20;

                g.Children.Add(d);

                g.Children.Add(d);
                listItem(g);
                Assert.Equal(26.0, g.UnitsPerMonth);
            }
예제 #5
0
            public void NewDeviceGroup_ShouldBeEmpty()
            {
                var g1 = new DeviceGroup();

                Assert.Equal(0,g1.Children.Count);
            }