MoveItem() public method

public MoveItem ( IExplorerItemModel model, string newPath ) : void
model IExplorerItemModel
newPath string
return void
コード例 #1
0
        public void StudioResourceRepository_MoveItem_Version_ExpectNothing()
        {

            //------------Setup for test--------------------------
            var mockExplorerResourceRepository = new Mock<IClientExplorerResourceRepository>();
            mockExplorerResourceRepository.Setup(m => m.RenameFolder(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<Guid>()))
                                          .Returns(new ExplorerRepositoryResult(ExecStatus.Success, "Success"))
                                          .Verifiable();

            var environmentId = Guid.NewGuid();
            var workflowId = Guid.NewGuid();
            var mockResourceRepository = new Mock<IResourceRepository>();
            Mock<IResourceModel> mockResourceModel = new Mock<IResourceModel>();
            mockResourceModel.SetupProperty(model => model.Category);
            mockResourceModel.SetupProperty(model => model.ResourceName);
            mockResourceModel.Object.Category = "MyCat";
            mockResourceModel.Object.ResourceName = "MyResName";
            mockResourceRepository.Setup(resourceRepository => resourceRepository.Find(It.IsAny<Expression<Func<IResourceModel, bool>>>())).Returns(new List<IResourceModel> { mockResourceModel.Object });
            Mock<IEnvironmentModel> mockEnvironment = EnviromentRepositoryTest.CreateMockEnvironment(mockResourceRepository.Object, "localhost");
            mockEnvironment.Setup(model => model.ID).Returns(environmentId);
            GetEnvironmentRepository(mockEnvironment);
            var mockVersionRepository = new Mock<IVersionRepository>();
            var repository = new StudioResourceRepository(GetTestData(workflowId.ToString()), environmentId, _invoke)
            {
                GetVersionProxy = id => mockVersionRepository.Object,
                GetExplorerProxy = id => mockExplorerResourceRepository.Object
            };
            //------------Execute Test---------------------------

            var explorerItemModel = repository.ExplorerItemModels[0].Children[0];
            explorerItemModel.ResourceType = ResourceType.Version;
            explorerItemModel.Children[0].ResourcePath = "\\folder1\\bob\\dave";
            explorerItemModel.ResourcePath = "\\folder1\\bob";
            repository.MoveItem(explorerItemModel, "New Name");
            //------------Assert Results-------------------------
            mockExplorerResourceRepository.Verify(m => m.RenameFolder("\\folder1\\bob", "New Name\\folder1", It.IsAny<Guid>()), Times.Never());

            //------------Execute Test---------------------------

        }
コード例 #2
0
 public void StudioResourceRepository_MoveItem_RenameFail_PublishesDisplayMessage()
 {
     //------------Setup for test--------------------------
     var mockExplorerResourceRepository = new Mock<IClientExplorerResourceRepository>();
     mockExplorerResourceRepository.Setup(m => m.RenameFolder(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<Guid>()))
                                   .Returns(new ExplorerRepositoryResult(ExecStatus.Fail, "Success"))
                                   .Verifiable();
     Mock<IEventAggregator> aggregator = new Mock<IEventAggregator>();
     DisplayMessageBoxMessage actualMessage = null;
     aggregator.Setup(a => a.Publish(It.IsAny<DisplayMessageBoxMessage>())).Callback<object>(msg =>
     {
         actualMessage = msg as DisplayMessageBoxMessage;
     });
     EventPublishers.Aggregator = aggregator.Object;
     var environmentId = Guid.NewGuid();
     var workflowId = Guid.NewGuid();
     var mockResourceRepository = new Mock<IResourceRepository>();
     Mock<IResourceModel> mockResourceModel = new Mock<IResourceModel>();
     mockResourceModel.SetupProperty(model => model.Category);
     mockResourceModel.SetupProperty(model => model.ResourceName);
     mockResourceModel.Object.Category = "MyCat";
     mockResourceModel.Object.ResourceName = "MyResName";
     mockResourceRepository.Setup(resourceRepository => resourceRepository.Find(It.IsAny<Expression<Func<IResourceModel, bool>>>())).Returns(new List<IResourceModel> { mockResourceModel.Object });
     Mock<IEnvironmentModel> mockEnvironment = EnviromentRepositoryTest.CreateMockEnvironment(mockResourceRepository.Object, "localhost");
     mockEnvironment.Setup(model => model.ID).Returns(environmentId);
     GetEnvironmentRepository(mockEnvironment);
     var mockVersionRepository = new Mock<IVersionRepository>();
     var repository = new StudioResourceRepository(GetTestData(workflowId.ToString()), environmentId, _invoke)
     {
         GetVersionProxy = id => mockVersionRepository.Object,
         GetExplorerProxy = id => mockExplorerResourceRepository.Object
     };
     //------------Execute Test---------------------------
     var explorerItemModel = repository.ExplorerItemModels[0].Children[0];
     explorerItemModel.ResourcePath = "folder1";
     repository.MoveItem(explorerItemModel, "New Name");
     //------------Assert Results-------------------------
     Assert.IsNotNull(actualMessage);
     Assert.AreEqual("Error Renaming Folder", actualMessage.Heading);
     Assert.AreEqual("Conflicting resources found in destination folder.", actualMessage.Message);
     Assert.AreEqual(MessageBoxImage.Warning, actualMessage.MessageBoxImage);
 }
コード例 #3
0
 public void StudioResourceRepository_MoveItem_NewPathIsNull_ThrowsException()
 {
     //------------Setup for test--------------------------
     var repository = new StudioResourceRepository(null, Guid.Empty, _invoke);
     //------------Execute Test---------------------------
     repository.MoveItem(new ExplorerItemModel(), null);
 }