//[Test]
        public void SingleUpdate_RecievedGetAllPercepts_PickUpPerceptsAndReturnThemThroughWriter()
        {
            ActionManager manager = new ActionManager(new EventManager());
            TileWorldBuilder worldBuilder = new TileWorldBuilder(new Size(4, 4));

            Agent agent = new Agent("testagent");
            worldBuilder.AddEntity(() => agent, new TileSpawnInformation(new TilePosition(new Point(0, 0))));

            XmasFactory fact = new XmasFactory(manager);
            TileWorld world = (TileWorld)worldBuilder.Build();
            agent.ActionManager = manager;
            agent.World = world;
            agent.Factory = fact;

            Thread thread1 = new Thread(test2);
            thread1.Name = "TCP Server";
            thread1.Start();

            while (lock1)
            {
            }
            TcpClient client = new TcpClient("localhost", 6661);
            Stream stream = client.GetStream();

            StringBuilder sb = new StringBuilder();

            EisConversionTool ctool = new EisConversionTool();
            ctool.AddConverter(new GetAllPerceptsActionConverter());
            ctool.AddConverter(new EISPerceptCollectionSerializer());
            ctool.AddConverter(new EisTileVisionSerializer());
            ctool.AddConverter(new EISSingleNumeralSerializer());

            IILActionParser parser = new IILActionParser();

            XmlReaderSettings set = new XmlReaderSettings();
            set.ConformanceLevel = ConformanceLevel.Fragment;
            XmlReader xreader = XmlReader.Create(new StreamReader(stream, Encoding.UTF8));
            XmlWriterSettings wset = new XmlWriterSettings();
            wset.OmitXmlDeclaration = true;
            XmlWriter xwriter = XmlWriter.Create(sb, wset);
            controller = new EISAgentController(agent, client, manager, new PacketStream(stream), new StreamReader(stream), new StreamWriter(stream), ctool, parser);

            Thread thread2 = new Thread(test1);
            thread2.Name = "Controller";
            thread2.Start();

            while (manager.ExecuteActions() == 0) ;
            string returned = null;
            do
            {
                try
                {
                    returned = sb.ToString();
                }
                catch
                {
                }
            } while (String.IsNullOrEmpty(returned));
        }
Esempio n. 2
0
 public EngineTest(TileWorldBuilder wb)
 {
     this.EventManager = new EventManager();
     this.ActionManager = new ActionManager(this.EventManager);
     this.Factory = new XmasFactory(this.ActionManager);
     this.Engine = new XmasModel(wb, this.ActionManager, this.EventManager, this.Factory);
     this.World = this.Engine.World;
 }