private static void Main(string[] args) { try { //for this execise I tried to implement S.O.L.I.D IRepositoryTank tank = new Tank(); IWaterAnimal fish = TankFactory.Create<AngelFish>(); fish.Name = String.Empty; fish.PortionFood = 0; tank.Add<AngelFish>((AngelFish)fish); fish = TankFactory.Create<GoalFish>(); fish.Name = "GoalFish"; fish.PortionFood = 0.1; tank.Add<GoalFish>((GoalFish)fish); fish = TankFactory.Create<BabelFish>(); fish.Name = "GoalFish"; fish.PortionFood = 0.3; tank.Add<BabelFish>((BabelFish)fish); Console.WriteLine("Added 3 new type of fish in the tank"); double foodNeeded = Math.Round(tank.Feed(), 4); Console.WriteLine("Tank Need {0} g of food for this fish ", foodNeeded); tank.AddToXmlAndSaveChanges(); Console.WriteLine("Tank has saved this irformation to an xml document. "); } catch (Exception ex) { //loger.log(String.Format("Error. {0}", ex.Message)). Console.WriteLine(ex.Message); } Console.ReadLine(); }
public void Add_Adds_FishToTheTank() { //Arrange var tank = new Tank(); var fish = new GoldFish { Name = "gold" }; //Act tank.Add(fish); //Assert Assert.That(tank.Count, Is.EqualTo(1)); Assert.That(tank.Fish.First(), Is.SameAs(fish)); }
public void Add_Adds_ManyFishToTheTank() { //Arrange var tank = new Tank(); //Act tank.Add(new GoldFish { Name = "gold1" }) .Add(new BabelFish { Name = "babel1" }) .Add(new AngelFish { Name = "angel1" }) .Add(new GoldFish { Name = "gold2" }) .Add(new BabelFish { Name = "babel2" }) .Add(new AngelFish { Name = "angel2" }); //Assert Assert.That(tank.Count, Is.EqualTo(6)); Assert.That(tank.Fish.ElementAt(0), Is.InstanceOf <GoldFish>()); Assert.That(tank.Fish.ElementAt(0).Name, Is.EqualTo("gold1")); Assert.That(tank.Fish.ElementAt(1), Is.InstanceOf <BabelFish>()); Assert.That(tank.Fish.ElementAt(1).Name, Is.EqualTo("babel1")); Assert.That(tank.Fish.ElementAt(2), Is.InstanceOf <AngelFish>()); Assert.That(tank.Fish.ElementAt(2).Name, Is.EqualTo("angel1")); Assert.That(tank.Fish.ElementAt(3), Is.InstanceOf <GoldFish>()); Assert.That(tank.Fish.ElementAt(3).Name, Is.EqualTo("gold2")); Assert.That(tank.Fish.ElementAt(4), Is.InstanceOf <BabelFish>()); Assert.That(tank.Fish.ElementAt(4).Name, Is.EqualTo("babel2")); Assert.That(tank.Fish.ElementAt(5), Is.InstanceOf <AngelFish>()); Assert.That(tank.Fish.ElementAt(5).Name, Is.EqualTo("angel2")); }
void LuoTankki() { tankki = new Tank(100, 40); tankki.Y = maa.Y + (0.5 * maa.Height) + tankki.Height; tankki.Mass = 20; tankki.Cannon.Power.MaxValue = double.PositiveInfinity; tankki.Cannon.ProjectileCollision += tykkiOsui; tankki.Cannon.Image = tykinKuva; tankki.Cannon.Ammo.Value = int.MaxValue; kk = new AssaultRifle(50, 20); kk.X += 25; kk.TimeBetweenUse = new TimeSpan(0, 0, 0, 0, 300); kk.Ammo.Value = int.MaxValue; kk.ProjectileCollision += luotiOsui; tankki.Add(kk); Add(tankki); }
public void Feed_Returns_TheSumOfTheFishFoodRequired() { //Arrange var tank = new Tank(); //Act tank.Add(new GoldFish { Name = "gold1" }) .Add(new BabelFish { Name = "babel1" }) .Add(new AngelFish { Name = "angel1" }); //Act var amount = tank.Feed(); //Assert Assert.That(amount, Is.EqualTo(0.6)); }