public void MoveItem_Execute_ExpectRename() { //------------Setup for test-------------------------- var moveItemService = new MoveItemService(); var item = new ServerExplorerItem("a", Guid.NewGuid(), "Folder", null, Permissions.DeployFrom, ""); var repo = new Mock <IExplorerServerResourceRepository>(); var ws = new Mock <IWorkspace>(); repo.Setup(a => a.MoveItem(It.IsAny <IExplorerItem>(), It.IsAny <string>(), It.IsAny <Guid>())).Returns(new ExplorerRepositoryResult(ExecStatus.Success, "")).Verifiable(); var inputs = new Dictionary <string, StringBuilder> { { "itemToMove", new StringBuilder(item.ResourceId.ToString()) }, { "newPath", new StringBuilder("bob") }, { "itemToBeRenamedPath", new StringBuilder(item.ResourcePath) } }; ws.Setup(a => a.ID).Returns(Guid.Empty); repo.Setup(repository => repository.Find(It.IsAny <Guid>())).Returns(item); moveItemService.ServerExplorerRepo = repo.Object; //------------Execute Test--------------------------- moveItemService.Execute(inputs, ws.Object); //------------Assert Results------------------------- repo.Verify(a => a.MoveItem(It.IsAny <IExplorerItem>(), It.IsAny <string>(), It.IsAny <Guid>())); }
public void MoveItem_Execute_NullValues_ErrorResult() { //------------Setup for test-------------------------- var MoveItemService = new MoveItemService(); var serializer = new Dev2JsonSerializer(); //------------Execute Test--------------------------- StringBuilder jsonResult = MoveItemService.Execute(null, null); IExplorerRepositoryResult result = serializer.Deserialize<IExplorerRepositoryResult>(jsonResult); //------------Assert Results------------------------- Assert.AreEqual(ExecStatus.Fail, result.Status); }
public void MoveItem_Execute_NewNameNotInDictionary_ErrorResult() { //------------Setup for test-------------------------- var values = new Dictionary<string, StringBuilder> { { "itemToRename", new StringBuilder("This is not deserializable to ServerExplorerItem") } }; var MoveItemService = new MoveItemService(); var serializer = new Dev2JsonSerializer(); //------------Execute Test--------------------------- StringBuilder jsonResult = MoveItemService.Execute(values, null); IExplorerRepositoryResult result = serializer.Deserialize<IExplorerRepositoryResult>(jsonResult); //------------Assert Results------------------------- Assert.AreEqual(ExecStatus.Fail, result.Status); }