using System; using System.Collections.Generic; using System.Linq; using ArchieSolution.Models; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace ArchieSolution.Tests { [TestClass] public class UnitTest1 { [TestMethod] public void Test_WingboneIsZero() { Dimension dimension = new Dimension(); dimension.Uom = Uom.Inches; dimension.Height = 420.25m; dimension.Width = 515.25m; dimension.Length = 600.00m; dimension.Girth = 100m; dimension.WingHandValue = 0m; var dimensionErrorList = dimension.Validate(); Skeleton skeleton = new Skeleton(); skeleton.Wingbone = 0; skeleton.HandThing = 2; skeleton.Skull = 1; skeleton.Teeth = 200; skeleton.Feet = 2; skeleton.Tail = 1; skeleton.Spine = 1; var skeletonErrorList = skeleton.Validate(); if (dimensionErrorList.Count > 0 || skeletonErrorList.Count > 0) { dimensionErrorList.AddRange(skeletonErrorList); throw new Exception("Input Error:\n" + string.Join("\n", dimensionErrorList.ToArray())); } Location location = new Location(); location.Latitude = 52.5243700m; location.Longitude = 13.4105300m; Archie archie = new Archie(dimension, skeleton, location, "Castello"); Console.WriteLine($"Test_WingboneIsZero: -1 = {archie.TotalWingSpan}"); Assert.AreEqual(-1, archie.TotalWingSpan); } [TestMethod] public void Test_WingboneIsOne() { Dimension dimension = new Dimension(); dimension.Uom = Uom.Inches; dimension.Height = 420.25m; dimension.Width = 515.25m; dimension.Length = 600.00m; dimension.Girth = 100m; dimension.WingHandValue = 75m; var dimensionErrorList = dimension.Validate(); Skeleton skeleton = new Skeleton(); skeleton.Wingbone = 1; skeleton.HandThing = 2; skeleton.Skull = 1; skeleton.Teeth = 200; skeleton.Feet = 2; skeleton.Tail = 1; skeleton.Spine = 1; var skeletonErrorList = skeleton.Validate(); if (dimensionErrorList.Count > 0 || skeletonErrorList.Count > 0) { dimensionErrorList.AddRange(skeletonErrorList); throw new Exception("Input Error:\n" + string.Join("\n", dimensionErrorList.ToArray())); } Location location = new Location(); location.Latitude = 52.5243700m; location.Longitude = 13.4105300m; Archie archie = new Archie(dimension, skeleton, location, "Angry Bird"); Console.WriteLine($"Test_WingboneIsOne: 250 = {archie.TotalWingSpan}"); Assert.AreEqual(250, archie.TotalWingSpan); } [TestMethod] public void Test_WingboneIsTwo() { Dimension dimension = new Dimension(); dimension.Uom = Uom.Inches; dimension.Height = 400.25m; dimension.Width = 505.25m; dimension.Length = 600.50m; dimension.Girth = 100m; dimension.WingHandValue = 200m; var dimensionErrorList = dimension.Validate(); Skeleton skeleton = new Skeleton(); skeleton.Wingbone = 2; skeleton.HandThing = 2; skeleton.Skull = 1; skeleton.Teeth = 200; skeleton.Feet = 2; skeleton.Tail = 1; skeleton.Spine = 1; var skeletonErrorList = skeleton.Validate(); if (dimensionErrorList.Count > 0 || skeletonErrorList.Count > 0) { dimensionErrorList.AddRange(skeletonErrorList); throw new Exception("Input Error:\n" + string.Join("\n", dimensionErrorList.ToArray())); } Location location = new Location(); location.Latitude = 52.5243700m; location.Longitude = 13.4105300m; Archie archie = new Archie(dimension, skeleton, location, "Charlie"); Console.WriteLine($"Test_WingboneIsTwo: 500 = {archie.TotalWingSpan}"); Assert.AreEqual(500, archie.TotalWingSpan); } [TestMethod] [ExpectedException(typeof(Exception))] public void Test_ValidateInput() { Dimension dimension = new Dimension(); dimension.Uom = Uom.Inches; dimension.Height = -400.25m; dimension.Width = -505.25m; dimension.Length = -600.50m; dimension.Girth = -100m; dimension.WingHandValue = -200m; var dimensionErrorList = dimension.Validate(); Skeleton skeleton = new Skeleton(); skeleton.Wingbone = 4; skeleton.HandThing = 4; skeleton.Skull = 2; skeleton.Teeth = 400; skeleton.Feet = 3; skeleton.Tail = 2; skeleton.Spine = 2; var skeletonErrorList = skeleton.Validate(); if (dimensionErrorList.Count > 0 || skeletonErrorList.Count > 0) { dimensionErrorList.AddRange(skeletonErrorList); throw new Exception("Input Error:\n" + string.Join("\n", dimensionErrorList.ToArray())); } Location location = new Location(); location.Latitude = 52.5243700m; location.Longitude = 13.4105300m; Archie archie = new Archie(dimension, skeleton, location, "Charlie"); Console.WriteLine($"Test_ValidateInput: 500 = {archie.TotalWingSpan}"); Assert.AreEqual(500, archie.TotalWingSpan); } } }