Example #1
0
    public void MissingNameAndConstructor()
    {
      var cmd = new Cmd.CreateItem();
      InitCommand(cmd);

      _context.CurrentItem = _testRoot;

      var result = cmd.Run();
      Assert.That(result.Status, Is.EqualTo(CommandStatus.Failure));
    }
Example #2
0
    public void MissingName()
    {
      var cmd = new Cmd.CreateItem();
      InitCommand(cmd);

      _context.CurrentItem = _testRoot;
      cmd.Template = Constants.Paths.DocTemplate;

      var result = cmd.Run();
      Assert.That(result.Status, Is.EqualTo(CommandStatus.Failure));
    }
Example #3
0
    public void ByValidTemplateName()
    {
      var cmd = new Cmd.CreateItem();
      InitCommand(cmd);

      var itemName = "newitem-" + DateUtil.IsoNow;

      _context.CurrentItem = _testRoot;
      cmd.Template = Constants.Paths.DocTemplate;
      cmd.Name = itemName;

      var result = cmd.Run();

      _testRoot.Reload();
      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(_testRoot.Children.Count, Is.EqualTo(1));
      Assert.That(_testRoot.Children[0].Name, Is.EqualTo(itemName));
    }
Example #4
0
    public void NewVersionRelative()
    {
      var cmd = new Cmd.CreateItem();
      InitCommand(cmd);

      var itemName = "newitem-" + DateUtil.IsoNow;
      var testItem = _testRoot.Add(itemName, _testRoot.Database.Templates[Constants.Paths.DocTemplate]);

      _context.CurrentItem = _testRoot;
      cmd.NewVersion = true;
      cmd.Path = testItem.Name;

      var result = cmd.Run();

      testItem.Reload();
      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(testItem.Versions.Count, Is.EqualTo(2));
    }
Example #5
0
    public void ByValidTemplateNameDifferentDB()
    {
      var cmd = new Cmd.CreateItem();
      InitCommand(cmd);

      var itemName = "newitem-" + DateUtil.IsoNow;

      _context.CurrentItem = Factory.GetDatabase("master").GetRootItem();
      cmd.Template = Constants.Paths.DocTemplate;
      cmd.Name = itemName;
      cmd.Path = "/web/" + _testRoot.Paths.FullPath;

      var result = cmd.Run();

      _testRoot.Reload();
      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(_testRoot.Children.Count, Is.EqualTo(1));
      Assert.That(_testRoot.Children[0].Name, Is.EqualTo(itemName));
    }
Example #6
0
    public void FromXMLChangeIds()
    {
      var cmd = new Cmd.CreateItem();
      InitCommand(cmd);

      _context.CurrentItem = _testRoot;
      cmd.Xml = File.ReadAllText(HttpContext.Current.Server.MapPath("TestResources\\single item.xml"));
      cmd.ChangeIds = true;

      var result = cmd.Run();

      _testRoot.Reload();
      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(_testRoot.Children.Count, Is.EqualTo(1));
      Assert.That(_testRoot.Children[0].Name, Is.EqualTo("newitem"));
      Assert.That(_testRoot.Children[0]["title"], Is.EqualTo("lorem"));
      Assert.That(_testRoot.Children[0].ID.ToString(), Is.Not.EqualTo("{F961C321-63A7-49F0-8041-B04DFC442827}"));
    }
Example #7
0
    public void ByInvalidXML()
    {
      var cmd = new Cmd.CreateItem();
      InitCommand(cmd);

      _context.CurrentItem = _testRoot;
      cmd.Xml = "<notvalid name=\"newitem\"></notvalid>";

      var result = cmd.Run();

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Failure));
    }
Example #8
0
    public void ByInvalidBranch()
    {
      var cmd = new Cmd.CreateItem();
      InitCommand(cmd);

      var itemName = "newitem-" + DateUtil.IsoNow;

      _context.CurrentItem = _testRoot;
      cmd.Branch = "not a real branch";
      cmd.Name = itemName;

      var result = cmd.Run();

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Failure));
    }
Example #9
0
    public void ByValidBranchID()
    {
      var cmd = new Cmd.CreateItem();
      InitCommand(cmd);

      var itemName = "newitem-" + DateUtil.IsoNow;

      var branchItem = _context.CurrentDatabase.Branches[Constants.Paths.Branch];

      _context.CurrentItem = _testRoot;
      cmd.Branch = branchItem.ID.ToString();
      cmd.Name = itemName;

      var result = cmd.Run();

      _testRoot.Reload();
      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(_testRoot.Children.Count, Is.EqualTo(1));
      Assert.That(_testRoot.Children[0].Name, Is.EqualTo(itemName));
      Assert.That(_testRoot.Children[0].Children.Count, Is.EqualTo(2));
    }