예제 #1
0
        public void TestRemoveJediEventHandling()
        {
            JediCouncil jc = new JediCouncil();

            jc.Add(new Jedi("LitleLuke", 4000));
            jc.Add(new Jedi("Luke", 30000));
            jc.CouncilChanged +=
                delegate(string message)
            {
                Assert.AreEqual(String.Format("Zavart érzek az Erőben"), message);
            };
            jc.Remove();
        }
예제 #2
0
        public void TestCountIf()
        {
            JediCouncil jc = new JediCouncil();

            jc.Add(new Jedi("LitleLuke", 4000));
            jc.Add(new Jedi("Yoda", 300000));
            jc.Add(new Jedi("LitleAnakin", 3000));

            int ci = jc.CountIf(
                delegate(Jedi j)
            {
                return(j.MidiChlorianCount > 3002);
            });

            Assert.AreEqual(2, ci);
        }
예제 #3
0
        public void TestAddJedi()
        {
            JediCouncil jc = new JediCouncil();

            jc.Add(new Jedi("Luke", 5000));

            Assert.AreEqual(1, jc.Count);
        }
예제 #4
0
        public void TestRemoveJedi()
        {
            JediCouncil jc = new JediCouncil();

            jc.Add(new Jedi("Luke", 5000));

            jc.Remove();
            Assert.AreEqual(0, jc.Count);
        }
예제 #5
0
        public void TestGetBeginners()
        {
            JediCouncil jc = new JediCouncil();

            jc.Add(new Jedi("LitleLuke", 4000));
            jc.Add(new Jedi("Yoda", 300000));
            jc.Add(new Jedi("LitleAnakin", 3000));

            List <Jedi> beginners = jc.GetBeginners();

            foreach (var j in beginners)
            {
                if (j.MidiChlorianCount > 5000)
                {
                    Assert.Fail("I have a beginner who is not beginner");
                }
            }
            Assert.Pass("They are just beginners");
        }
예제 #6
0
        public void TestAddNewJediEventHandling()
        {
            JediCouncil jc = new JediCouncil();
            Jedi        j  = new Jedi("Luke", 30000);

            jc.CouncilChanged +=
                delegate(string message)
            {
                Assert.AreEqual(String.Format("Új taggal ({0}) bővültünk", j.Name), message);
            };
            jc.Add(j);
        }
예제 #7
0
        public void TestTheCouncilHasFallenEventHandling()
        {
            JediCouncil jc = new JediCouncil();

            jc.Add(new Jedi("LitleLuke", 4000));
            jc.CouncilChanged +=
                delegate(string message)
            {
                Assert.AreEqual(String.Format("A tanács elesett!"), message);
            };
            jc.Remove();
        }
예제 #8
0
        static void Main(string[] args)
        {
            // Tanács létrehozása
            JediCouncil council = new JediCouncil();

            council.CouncilChanged += MessageReceived;

            Jedi jedi0 = new Jedi();

            jedi0.Name = "Luke";
            jedi0.MidiChlorianCount = 15000;
            council.Add(jedi0);

            XmlSerializer serializer    = new XmlSerializer(typeof(Jedi));
            FileStream    fileStreamOut = new FileStream("jedi.txt", FileMode.Create);

            serializer.Serialize(fileStreamOut, jedi0);
            fileStreamOut.Close();

            // Tanács feltöltése 2 taggal
            Jedi jedi1 = new Jedi();

            jedi1.Name = "Yoda";
            jedi1.MidiChlorianCount = 17000;
            council.Add(jedi1);
            council.Add(new Jedi("Jedi baby", 200));
            council.Add(new Jedi("Jedi boy", 2800));

            council.Remove();

            int sth = council.CountIf(delegate(Jedi j) { return(j.MidiChlorianCount > 2); });

            Console.WriteLine(" ## {0} ##", sth);

            Jedi jedi2 = new Jedi();

            jedi2.Name = "Anakin Skywalker";
            jedi2.MidiChlorianCount = 27000;
            council.Add(jedi2);

            foreach (var j in council.GetBeginners())
            {
                Console.WriteLine("{0} : {1}", j.Name, j.MidiChlorianCount);
            }

            council.Remove();
            council.Remove();
            council.Remove();
            council.Remove();
            //
            //j.MidiChlorianCount = 0;



            //Process.Start("jedi.txt");

            serializer = new XmlSerializer(typeof(Jedi));
            FileStream fileStreamIn = new FileStream("jedi.txt", FileMode.Open);
            Jedi       clone        = (Jedi)serializer.Deserialize(fileStreamIn);

            fileStreamIn.Close();
            Console.WriteLine("{0} : {1}", clone.Name, clone.MidiChlorianCount);

            Console.ReadKey();
        }