public void ParseCommand_IlegalUrlPart_InvalidCommand() { const string inFile = "D:\\Programing\\Cs_Programming_I\\04\\nezarka_store\\test_files\\CommandParsingTests\\IlegalUrlPartTest.in"; const string correctFile = "D:\\Programing\\Cs_Programming_I\\04\\nezarka_store\\test_files\\CommandParsingTests\\IlegalUrlPartExpected.out"; const string outFile = "D:\\Programing\\Cs_Programming_I\\04\\nezarka_store\\test_files\\CommandParsingTests\\IlegalUrlPartTest.out"; Reader = File.OpenText(inFile); Heimdal = new SupremeCommander(); Writer = new StreamWriter(new FileStream(outFile, FileMode.OpenOrCreate, FileAccess.ReadWrite)); Overseer = new StoreViewer(Writer); Heimdal.GetData(Reader, out bool wrongInput); Heimdal.InititateCommandProcessing(Reader, Overseer); Heimdal.DisposeStore(); Writer.Close(); bool areEqual = Utils.FileDiff(outFile, correctFile); Assert.IsTrue(areEqual); }
static void Main(string[] args) { TextReader reader = default(TextReader); TextWriter writer = default(TextWriter); SupremeCommander Thor = default(SupremeCommander); if (args.Length != 2) { Console.WriteLine("Argument Error"); return; } try { reader = File.OpenText(args[0]); writer = File.CreateText(args[1]); } catch (Exception) { Console.WriteLine("File Error"); return; } Thor = SupremeCommander.Initialize(reader, writer); Thor.WriteAndSolve(); Thor.Dispose(); }
public void RunAll_CorrectInput_CreatesFile() { StreamWriter wrt = new StreamWriter(new FileStream("D:\\Programing\\Cs_Programming_I\\04\\nezarka_store\\test_files\\CompleteTests\\NezarkaTest.out", FileMode.OpenOrCreate, FileAccess.ReadWrite)); StoreViewer storeViewer = new StoreViewer(wrt); SupremeCommander Thor = new SupremeCommander(); bool wrongStoreInput; TextReader myReader = File.OpenText("D:\\Programing\\Cs_Programming_I\\04\\nezarka_store\\test_files\\CompleteTests\\NezarkaTest.in"); Thor.GetData(myReader, out wrongStoreInput); if (wrongStoreInput) { Thor.PrintDataError(); return; } Thor.InititateCommandProcessing(myReader, storeViewer); wrt.Close(); bool identical = Utils.FileDiff("D:\\Programing\\Cs_Programming_I\\04\\nezarka_store\\test_files\\CompleteTests\\NezarkaTest.out", "D:\\Programing\\Cs_Programming_I\\04\\nezarka_store\\test_files\\CompleteTests\\NezarkaExpected.out"); Assert.IsTrue(identical); }
void Start() { //Create resources GameObject resources = new GameObject(); resources.name = "Resources"; resources.layer = 9; GameObject prefab = (GameObject)Instantiate(Resources.Load(("Prefabs/Resource"), typeof(GameObject))); prefab.transform.position = new Vector3(0, 0, 15); //Create Red resources prefab.transform.parent = resources.transform; foreach (Transform child in prefab.transform) { child.renderer.material.color = Color.red; } prefab.tag = "RedSource"; //Create Blue resources prefab = (GameObject)Instantiate(Resources.Load(("Prefabs/Resource"), typeof(GameObject))); prefab.transform.position = new Vector3(0, 0, -15); prefab.transform.parent = resources.transform; foreach (Transform child in prefab.transform) { child.renderer.material.color = Color.blue; } prefab.tag = "BlueSource"; //Create Yellow resources prefab = (GameObject)Instantiate(Resources.Load(("Prefabs/Resource"), typeof(GameObject))); prefab.transform.position = new Vector3(15, 0, 0); prefab.transform.parent = resources.transform; foreach (Transform child in prefab.transform) { child.renderer.material.color = Color.yellow; } prefab.tag = "YellowSource"; //update the gridgraph (pathfinding) with the positions of the resources foreach (Transform child in resources.transform) { AstarPath.active.UpdateGraphs(child.collider.bounds); } //create a new clan GameObject clan = new GameObject(); clan.name = BlackBoard.Instance.GetClan(); //get an available name for the clan (3 available) clan.transform.position = new Vector3(-20 + Random.Range(-5, 5), 0, -20 + Random.Range(-5, 5)); //Create a group for the commanders and place it in the clan GameObject commanderGroup = new GameObject(); commanderGroup.name = "Commanders"; commanderGroup.transform.parent = clan.transform; commanderGroup.transform.position = clan.transform.position; //Create a supremecommander for the clan SupremeCommander prefab2 = (SupremeCommander)Instantiate(Resources.Load(("Prefabs/SupremeCommander"), typeof(SupremeCommander))); prefab2.transform.position = commanderGroup.transform.position; prefab2.transform.parent = commanderGroup.transform; prefab2.SetClan(clan.name); }