Beispiel #1
0
        private XDocument GenerateFishTankXml()
        {
            if (_tank == null || _tank.GetFishList() == null)
            {
                return(null);
            }

            XDocument fishTankXDoc = new XDocument(
                new XElement("FishTank",
                             new XElement("RequiredFoodInGram", _tank.Feed()),
                             new XElement("Fishes")
                             )
                );

            var fishesXml = fishTankXDoc.Descendants("Fishes").FirstOrDefault();

            if (fishesXml != null && _tank.GetFishList() != null)
            {
                foreach (var fish in _tank.GetFishList())
                {
                    fishesXml.Add(new XElement(nameof(Fish),
                                               new XAttribute(nameof(fish.FishType), fish.FishType.ToString()),
                                               new XElement(nameof(fish.Name), fish.Name),
                                               new XElement(nameof(fish.FoodRequired), fish.FoodRequired)
                                               )
                                  );
                }
            }
            fishTankXDoc.Declaration = new XDeclaration("1.0", "utf-8", "true");
            return(fishTankXDoc);
        }
        public void Should_Add_To_The_sut_Gold_Fish()
        {
            var goldFish = new GoldFish("Test Gold Fish");

            var actal = _sut.AddFish(goldFish);

            Assert.IsTrue(actal);
            Assert.AreEqual(0.1, _sut.Feed());
        }