public void TestRainBarrelCapacity() { #region Sub testmethod 'TestIsIllegal' System.Func <int, bool> TestIsIllegal = (capacity) => { try { var barrel = new RainBarrel(0, (BucketOOP.Buckets.Enums.CapacityOption)capacity); } catch { return(true); } return(false); }; #endregion int[] allowedCapacities = new int[] { 80, 120, 160 }; foreach (var capacity in allowedCapacities) { Assert.IsFalse(TestIsIllegal(capacity)); } Assert.IsTrue(TestIsIllegal(0)); }
private void bCreateRainBarrel_Click(object sender, RoutedEventArgs e) { try { double content = tbRainBarrelContent.Text.Length == 0 ? 0 : double.Parse(tbRainBarrelContent.Text); RainBarrel rainBarrel; if (rbRainBarrelSmall.IsChecked == true) { rainBarrel = RainBarrel.GetSmall(content); } else if (rbRainBarrelLarge.IsChecked == true) { rainBarrel = RainBarrel.GetLarge(content); } else { rainBarrel = RainBarrel.Get(content); } AddContainer(new RainBarrelViewModel(rainBarrel)); } catch (Exception ex) { MessageBox.Show(ex.Message, Title, MessageBoxButton.OK, MessageBoxImage.Error); } }
public void HaveRequestedCapacityOf160() { RainBarrel sut; int requestedCapacity = 160; sut = new RainBarrel(0, 121); Assert.Equal(requestedCapacity, sut.Capacity); }
public void HaveRequestedContentOf100() { RainBarrel sut; int requestedContent = 100; sut = new RainBarrel(requestedContent); Assert.Equal(requestedContent, sut.Content); }
public void HaveDefaultContentOfZero() { RainBarrel sut; int defaultContent = 0; sut = new RainBarrel(); Assert.Equal(defaultContent, sut.Content); }
public void HaveDefaultCapacityOf120() { RainBarrel sut; int defaultCapacity = 120; sut = new RainBarrel(); Assert.Equal(defaultCapacity, sut.Capacity); }
public void TestInheritance() { var bucket = new Bucket(); var rainBarrel = new RainBarrel(); var oilBarrel = new OilBarrel(); Assert.IsTrue(bucket is BucketBase); Assert.IsTrue(rainBarrel is BucketBase); Assert.IsTrue(oilBarrel is BucketBase); }
public void CreateContainers() { Container container; // Test whether default containers have the correct capacity and content. container = Bucket.GetDefault(); Assert.Equal(12, container.Capacity); Assert.Equal(0, container.Content); container = RainBarrel.Get(); Assert.Equal(100, container.Capacity); Assert.Equal(0, container.Content); container = RainBarrel.GetSmall(); Assert.Equal(80, container.Capacity); Assert.Equal(0, container.Content); container = RainBarrel.GetLarge(); Assert.Equal(120, container.Capacity); Assert.Equal(0, container.Content); container = OilBarrel.Get(); Assert.Equal(159, container.Capacity); Assert.Equal(0, container.Content); // Test whether or not an exception is thrown when creating valid/invalid conainers. Bucket.GetDefault(11); Bucket.GetDefault(12); Assert.Throws <ArgumentOutOfRangeException>(() => Bucket.GetDefault(13)); Bucket.Get(11); Bucket.Get(10); Assert.Throws <ArgumentOutOfRangeException>(() => Bucket.Get(9)); Bucket.Get(16, 15); Bucket.Get(16, 16); Assert.Throws <ArgumentOutOfRangeException>(() => Bucket.Get(16, 17)); RainBarrel.Get(99); RainBarrel.Get(100); Assert.Throws <ArgumentOutOfRangeException>(() => RainBarrel.Get(101)); RainBarrel.GetSmall(79); RainBarrel.GetSmall(80); Assert.Throws <ArgumentOutOfRangeException>(() => RainBarrel.GetSmall(81)); RainBarrel.GetLarge(119); RainBarrel.GetLarge(120); Assert.Throws <ArgumentOutOfRangeException>(() => RainBarrel.GetLarge(121)); OilBarrel.Get(158); OilBarrel.Get(159); Assert.Throws <ArgumentOutOfRangeException>(() => OilBarrel.Get(160)); }
public RainBarrelViewModel(RainBarrel rainBarrel) : base(rainBarrel) { }