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); } }
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); }
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); }
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); }
public void NewDeviceGroup_ShouldBeEmpty() { var g1 = new DeviceGroup(); Assert.Equal(0,g1.Children.Count); }