public void TestLoadMethod()
        {
            Stream stream = File.OpenRead(TEST_FILE);

            stream.Seek(0, SeekOrigin.End);
            long fileSize = stream.Position;
            stream.Seek(0, SeekOrigin.Begin);

            ArtificialIntelligenceFile artificialIntelligenceFile = new ArtificialIntelligenceFile();
            artificialIntelligenceFile.Load(stream);

            long streamPosition = stream.Position;
            stream.Close();

            Assert.AreEqual(fileSize, streamPosition, "Not all of the file was read");
        }
        public void TestSaveMethod()
        {
            ArtificialIntelligenceFile artificialIntelligenceFile = new ArtificialIntelligenceFile();
            artificialIntelligenceFile.Load(TEST_FILE);

            MemoryStream savedStream = new MemoryStream();
            artificialIntelligenceFile.Save(savedStream);

            savedStream.Seek(0, SeekOrigin.Begin);

            ArtificialIntelligenceFile savedArtificialIntelligenceFile = new ArtificialIntelligenceFile();
            savedArtificialIntelligenceFile.Load(savedStream);

            savedStream.Close();

            Assert.AreEqual(artificialIntelligenceFile.Name, savedArtificialIntelligenceFile.Name, "Names do not match");
            Assert.AreEqual(artificialIntelligenceFile.IdleInterval, savedArtificialIntelligenceFile.IdleInterval, "Idle interval values do not match");
            Assert.AreEqual(artificialIntelligenceFile.DamageRate, savedArtificialIntelligenceFile.DamageRate, "Damage rate values do not match");

            Assert.AreEqual(artificialIntelligenceFile.Patterns.Count, savedArtificialIntelligenceFile.Patterns.Count, "Pattern counts do not match");

            for (int i = 0; i < artificialIntelligenceFile.Patterns.Count; i++) {
                Assert.AreEqual(artificialIntelligenceFile.Patterns[i].Name, savedArtificialIntelligenceFile.Patterns[i].Name, "Pattern names do not match");

                Assert.AreEqual(artificialIntelligenceFile.Patterns[i].Events.Count, savedArtificialIntelligenceFile.Patterns[i].Events.Count, "Event counts do not match");

                for (int j = 0; j < artificialIntelligenceFile.Patterns[i].Events.Count; j++) {
                    Assert.AreEqual(artificialIntelligenceFile.Patterns[i].Events[j].Name, savedArtificialIntelligenceFile.Patterns[i].Events[j].Name, "Event names do not match");

                    Assert.AreEqual(artificialIntelligenceFile.Patterns[i].Events[j].Conditions.Count, savedArtificialIntelligenceFile.Patterns[i].Events[j].Conditions.Count, "Condition counts do not match");
                    Assert.AreEqual(artificialIntelligenceFile.Patterns[i].Events[j].Actions.Count, savedArtificialIntelligenceFile.Patterns[i].Events[j].Actions.Count, "Action counts do not match");

                    for (int k = 0; k < artificialIntelligenceFile.Patterns[i].Events[j].Conditions.Count; k++) {
                        Assert.AreEqual(artificialIntelligenceFile.Patterns[i].Events[j].Conditions[k].GetType(), artificialIntelligenceFile.Patterns[i].Events[j].Conditions[k].GetType(), "Condition types do not match");
                    }

                    for (int k = 0; k < artificialIntelligenceFile.Patterns[i].Events[j].Actions.Count; k++) {
                        Assert.AreEqual(artificialIntelligenceFile.Patterns[i].Events[j].Actions[k].GetType(), artificialIntelligenceFile.Patterns[i].Events[j].Actions[k].GetType(), "Action types do not match");
                    }
                }
            }
        }