public void ShouldGetRobotsCustom() { ContentResult expectedResult = new ContentResult() { StatusCode = StatusCodes.Status200OK, ContentType = MediaTypeNames.Text.Plain, Content = "Custom Content", }; string key = "robots.txt"; string robotsContent = expectedResult.Content; var myConfiguration = new Dictionary <string, string> { { key, robotsContent }, }; var configuration = new ConfigurationBuilder() .AddInMemoryCollection(myConfiguration) .Build(); RobotsController controller = new RobotsController(configuration); IActionResult actualResult = controller.Robots(); Assert.IsType <ContentResult>(actualResult); Assert.True(actualResult.IsDeepEqual(expectedResult)); }
public void TestInitializeRobot() { Planet planet = new Planet(5, 3); RobotsController controller = new RobotsController(planet); Robot robot = controller.InitializeRobot("1 2 E"); Assert.Equal("1 2 E", robot.GetPosition()); }
public void TestMoveRobot(string position, string movementsString, string expected) { List <IMovement> movements = InputParser.parseMovementList(movementsString); Planet planet = new Planet(5, 3); RobotsController controller = new RobotsController(planet); Robot robot = controller.InitializeRobot(position); controller.MoveRobot(robot, movements); Assert.Equal(expected, robot.GetPosition()); }
public void TestScentProtection() { Planet planet = new Planet(5, 3); RobotsController controller = new RobotsController(planet); Robot robot = controller.InitializeRobot("3 2 N"); controller.MoveRobot(robot, InputParser.parseMovementList("FRRFLLFFRRFLL")); Robot robot2 = controller.InitializeRobot("0 3 W"); controller.MoveRobot(robot2, InputParser.parseMovementList("LLFFFLFLFL")); Assert.Equal("2 3 S", robot2.GetPosition()); }
public void CheckItWorks() { var options = new DbContextOptionsBuilder <DataContext>() .UseInMemoryDatabase(databaseName: "techtestdb-test") .Options; var context = new DataContext(options); //We're initializing an in memory database here, but it's empty //If you want to add any entity you can do it in the context object var controller = new RobotsController(context); var result = controller.GetAvailable("Bloaty Head"); Assert.IsInstanceOfType(result, typeof(OkObjectResult)); context.Database.EnsureDeleted(); context.Dispose(); }
public void ShouldGetRobotsTxtDefaultConfig() { ContentResult expectedResult = new ContentResult() { StatusCode = StatusCodes.Status200OK, ContentType = MediaTypeNames.Text.Plain, Content = RobotsController.DefaultRobotsContent, }; var myConfiguration = new Dictionary <string, string> { }; var configuration = new ConfigurationBuilder() .AddInMemoryCollection(myConfiguration) .Build(); RobotsController controller = new RobotsController(configuration); IActionResult actualResult = controller.Robots(); Assert.IsType <ContentResult>(actualResult); Assert.True(actualResult.IsDeepEqual(expectedResult)); }
public void ShouldGetRobotsTxtDefaultConfig() { ContentResult expectedResult = new ContentResult() { StatusCode = StatusCodes.Status200OK, ContentType = MediaTypeNames.Text.Plain, Content = string.Empty, }; var myConfiguration = new Dictionary <string, string> { }; var configuration = new ConfigurationBuilder() .AddInMemoryCollection(myConfiguration) .Build(); RobotsController controller = new RobotsController(configuration); ContentResult actualResult = (ContentResult)controller.Robots(); Assert.Equal(actualResult.StatusCode, expectedResult.StatusCode); Assert.NotEmpty(actualResult.Content); }
public void WriteRobots() { try { System.IO.StreamWriter objStreamWriter = new System.IO.StreamWriter(HttpRuntime.AppDomainAppPath + "\\robots.txt"); objStreamWriter.WriteLine("User-agent: Googlebot\n"); List <RobotsInfo> lstGooglebot = RobotsController.GenerateRobots("Googlebot"); foreach (RobotsInfo objinfo in lstGooglebot) { objStreamWriter.WriteLine("Disallow: " + objinfo.PagePath + "/" + "\n"); } objStreamWriter.WriteLine("User-agent: Slurp\n"); List <RobotsInfo> lstSlurp = RobotsController.GenerateRobots("Slurp"); foreach (RobotsInfo objinfo in lstSlurp) { objStreamWriter.WriteLine("Disallow: " + objinfo.PagePath + "/" + "\n"); } objStreamWriter.WriteLine("User-agent: msnbot\n"); List <RobotsInfo> lstmsnbot = RobotsController.GenerateRobots("msnbot"); foreach (RobotsInfo objinfo in lstmsnbot) { objStreamWriter.WriteLine("Disallow: " + objinfo.PagePath + "/" + "\n"); } objStreamWriter.WriteLine("User-agent: bingbot\n"); List <RobotsInfo> lstbingbot = RobotsController.GenerateRobots("bingbot"); foreach (RobotsInfo objinfo in lstbingbot) { objStreamWriter.WriteLine("Disallow: " + objinfo.PagePath + "/" + "\n"); } objStreamWriter.Close(); } catch (Exception) { throw; } }
private void generateRobots() { RobotsController.DeleteExistingRobots(GetPortalID); List <RobotsInfo> items = RobotsController.GetRobots(GetPortalID); int flag = 0; string TabPath = string.Empty; foreach (ListItem chkitem in chkChoice.Items) { if (chkitem.Selected == false) { flag++; } else if (chkitem.Selected == true && chkitem.Text == "Google") { foreach (GridViewRow gvRow in gdvRobots.Rows) { CheckBox chk = (CheckBox)gvRow.FindControl("chkPath"); if (chk.Checked) { Label lblTabPath = (Label)gvRow.FindControl("lblTabPath"); TabPath = lblTabPath.Text; if (!IsParent) { TabPath = "/portal/" + GetPortalSEOName + TabPath; } RobotsController.SaveRobotsPage(GetPortalID, "Googlebot", TabPath); } } } else if (chkitem.Selected == true && chkitem.Text == "Yahoo") { foreach (GridViewRow gvRow in gdvRobots.Rows) { CheckBox chk = (CheckBox)gvRow.FindControl("chkPath"); if (chk.Checked) { Label lblTabPath = (Label)gvRow.FindControl("lblTabPath"); TabPath = lblTabPath.Text; if (!IsParent) { TabPath = "/portal/" + GetPortalSEOName + TabPath; } RobotsController.SaveRobotsPage(GetPortalID, "Slurp", TabPath); } } } else if (chkitem.Selected == true && chkitem.Text == "Msn") { foreach (GridViewRow gvRow in gdvRobots.Rows) { CheckBox chk = (CheckBox)gvRow.FindControl("chkPath"); if (chk.Checked) { Label lblTabPath = (Label)gvRow.FindControl("lblTabPath"); TabPath = lblTabPath.Text; if (!IsParent) { TabPath = "/portal/" + GetPortalSEOName + TabPath; } RobotsController.SaveRobotsPage(GetPortalID, "msnbot", TabPath); } } } else if (chkitem.Selected == true && chkitem.Text == "Bing") { foreach (GridViewRow gvRow in gdvRobots.Rows) { CheckBox chk = (CheckBox)gvRow.FindControl("chkPath"); if (chk.Checked) { Label lblTabPath = (Label)gvRow.FindControl("lblTabPath"); TabPath = lblTabPath.Text; if (!IsParent) { TabPath = "/portal/" + GetPortalSEOName + TabPath; } RobotsController.SaveRobotsPage(GetPortalID, "bingbot", TabPath); } } } if (flag == chkChoice.Items.Count) { string message = "Select Searchengine"; ShowMessage("", message, "", SageMessageType.Alert); } else { WriteRobots(); string message = "Robots Generated Successfully"; ShowMessage("", message, "", SageMessageType.Success); } } }
private void LoadGrid() { gdvRobots.DataSource = RobotsController.GetRobots(GetPortalID); gdvRobots.DataBind(); }
private void generateRobots() { RobotsController.DeleteExistingRobots(GetPortalID); List <RobotsInfo> items = RobotsController.GetRobots(GetStoreID, GetPortalID); int flag = 0; string TabPath = string.Empty; foreach (ListItem chkitem in chkChoice.Items) { if (chkitem.Selected == false) { flag++; } if (chkitem.Selected == true && chkitem.Text == "Google") { foreach (GridViewRow gvRow in gdvRobots.Rows) { CheckBox chk = (CheckBox)gvRow.FindControl("chkPath"); if (chk.Checked) { Label lblTabPath = (Label)gvRow.FindControl("lblTabPath"); TabPath = lblTabPath.Text; if (GetPortalID > 1) { TabPath = "/portal/" + GetPortalSEOName + TabPath; } RobotsController.SaveRobotsPage(GetPortalID, "Googlebot", TabPath); } } } if (chkitem.Selected == true && chkitem.Text == "Yahoo") { foreach (GridViewRow gvRow in gdvRobots.Rows) { CheckBox chk = (CheckBox)gvRow.FindControl("chkPath"); if (chk.Checked) { Label lblTabPath = (Label)gvRow.FindControl("lblTabPath"); TabPath = lblTabPath.Text; if (GetPortalID > 1) { TabPath = "/portal/" + GetPortalSEOName + TabPath; } RobotsController.SaveRobotsPage(GetPortalID, "Slurp", TabPath); } } } if (chkitem.Selected == true && chkitem.Text == "Msn") { foreach (GridViewRow gvRow in gdvRobots.Rows) { CheckBox chk = (CheckBox)gvRow.FindControl("chkPath"); if (chk.Checked) { Label lblTabPath = (Label)gvRow.FindControl("lblTabPath"); TabPath = lblTabPath.Text; if (GetPortalID > 1) { TabPath = "/portal/" + GetPortalSEOName + TabPath; } RobotsController.SaveRobotsPage(GetPortalID, "msnbot", TabPath); } } } if (chkitem.Selected == true && chkitem.Text == "Bing") { foreach (GridViewRow gvRow in gdvRobots.Rows) { CheckBox chk = (CheckBox)gvRow.FindControl("chkPath"); if (chk.Checked) { Label lblTabPath = (Label)gvRow.FindControl("lblTabPath"); TabPath = lblTabPath.Text; if (GetPortalID > 1) { TabPath = "/portal/" + GetPortalSEOName + TabPath; } RobotsController.SaveRobotsPage(GetPortalID, "bingbot", TabPath); } } } if (flag == chkChoice.Items.Count) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "globalVariables", " alert('Select Searchengine'); ", true); } else { WriteRobots(); } } }