public void RenameItem_Execute_ExpectRename() { //------------Setup for test-------------------------- var renameItemService = new RenameItemService(); ServerExplorerItem item = new ServerExplorerItem("a", Guid.NewGuid(), "Folder", null, Permissions.DeployFrom, ""); var repo = new Mock <IExplorerServerResourceRepository>(); var ws = new Mock <IWorkspace>(); repo.Setup(a => a.RenameItem(It.IsAny <IExplorerItem>(), It.IsAny <string>(), It.IsAny <Guid>())).Returns(new ExplorerRepositoryResult(ExecStatus.Success, "")).Verifiable(); var inputs = new Dictionary <string, StringBuilder> { { "itemToRename", new StringBuilder(item.ResourceId.ToString()) }, { "newName", new StringBuilder("bob") } }; ws.Setup(a => a.ID).Returns(Guid.Empty); repo.Setup(repository => repository.Find(It.IsAny <Guid>())).Returns(item); renameItemService.ServerExplorerRepo = repo.Object; //------------Execute Test--------------------------- renameItemService.Execute(inputs, ws.Object); //------------Assert Results------------------------- repo.Verify(a => a.RenameItem(It.IsAny <IExplorerItem>(), It.IsAny <string>(), It.IsAny <Guid>())); }
public void RenameItem_Execute_NullValues_ErrorResult() { //------------Setup for test-------------------------- var renameItemService = new RenameItemService(); var serializer = new Dev2JsonSerializer(); //------------Execute Test--------------------------- StringBuilder jsonResult = renameItemService.Execute(null, null); IExplorerRepositoryResult result = serializer.Deserialize <IExplorerRepositoryResult>(jsonResult); //------------Assert Results------------------------- Assert.AreEqual(ExecStatus.Fail, result.Status); }
public void RenameItem_Execute_ItemToRenameNotInValues_ErrorResult() { //------------Setup for test-------------------------- var values = new Dictionary <string, StringBuilder> { { "item", new StringBuilder() } }; var renameItemService = new RenameItemService(); var serializer = new Dev2JsonSerializer(); //------------Execute Test--------------------------- StringBuilder jsonResult = renameItemService.Execute(values, null); IExplorerRepositoryResult result = serializer.Deserialize <IExplorerRepositoryResult>(jsonResult); //------------Assert Results------------------------- Assert.AreEqual(ExecStatus.Fail, result.Status); }