public void TestCrossPattern() { using (var inputReader = new StreamReader(Console.OpenStandardInput())) { using (var consoleWriter = new StreamWriter(Console.OpenStandardOutput())) { consoleWriter.AutoFlush = true; Console.SetOut(consoleWriter); Console.SetIn(inputReader); IInputHandler inputHandler = new InputHandler(); string inputTest = null; Assert.AreEqual(inputHandler.IsInputValid(inputTest), false); var boundaries = new Rectangle(0, 0, Console.WindowWidth, Console.WindowHeight); var shapeTemplate = new CrossTemplate('*', boundaries); // Point is to test algorithm, so avoid using another algorithm to test with. var shape = shapeTemplate.Print(1); String checkString = "*\n"; Assert.AreEqual(shape, checkString); shape = shapeTemplate.Print(2); checkString = "**\n"; checkString += "**\n"; Assert.AreEqual(shape, checkString); shape = shapeTemplate.Print(5); checkString = "* *\n"; checkString += " * * \n"; checkString += " * \n"; checkString += " * * \n"; checkString += "* *\n"; Assert.AreEqual(shape, checkString); shape = shapeTemplate.Print(10); checkString = "* *\n"; checkString += " * * \n"; checkString += " * * \n"; checkString += " * * \n"; checkString += " ** \n"; checkString += " ** \n"; checkString += " * * \n"; checkString += " * * \n"; checkString += " * * \n"; checkString += "* *\n"; Assert.AreEqual(shape, checkString); // Check the truncation message is displayed. shape = shapeTemplate.Print(100000); Assert.AreNotEqual(shape.IndexOf("The rest of this shape is too large to display properly."), 0); } } }
protected void ConstructorButton_Click(object sender, EventArgs e) { //Не открываем конструктор если не выбран Entity if (string.IsNullOrEmpty(EntityList.SelectedValue)) { return; } var userID = Convert.ToInt32(Session["SystemUser.objID"]); CrossTemplate.userID = userID; if (TemplateList.SelectedIndex == 0) { if (!AuthorizationRules.TemplateResolution(ActionType.create, Session["SystemUser.objID"].ToString())) { WarningMessageBox.Show(); return; } } else { if (!AuthorizationRules.TemplateResolution( ActionType.read, Session["SystemUser.objID"].ToString(), TemplateList.SelectedValue)) { WarningMessageBox.Show(); return; } } multiView.ActiveViewIndex = 1; CrossTemplate.template = null; if (TemplateList.SelectedValue != "-1") { CrossTemplate.TemplateID = TemplateList.SelectedValue; } CrossTemplate.EntityID = EntityList.SelectedValue; CrossTemplate.DataBind(); }