AddItem() public méthode

public AddItem ( IExplorerItemModel item ) : void
item IExplorerItemModel
Résultat void
 public void StudioResourceRepository_AddItem_ServiceThrowsAnException_ReThrowsAnException()
 {
     //------------Setup for test--------------------------
     var mockExplorerResourceRepository = new Mock<IClientExplorerResourceRepository>();
     mockExplorerResourceRepository.Setup(m => m.AddItem(It.IsAny<IExplorerItem>(), It.IsAny<Guid>()))
                                   .Throws(new Exception("Something really bad happened, reboot your PC or risk a Harddrive crash"));
     SetupEnvironmentRepo(Guid.Empty);
     var mockVersionRepository = new Mock<IVersionRepository>();
     var repository = new StudioResourceRepository(null, Guid.Empty, _invoke)
     {
         GetVersionProxy = id => mockVersionRepository.Object,
         GetExplorerProxy = id => mockExplorerResourceRepository.Object
     };
     //------------Execute Test---------------------------
     repository.AddItem(new ExplorerItemModel { Parent = new ExplorerItemModel() });
 }
 public void StudioResourceRepository_AddItem_ServiceReturnsAndError_ThrowsAnException()
 {
     //------------Setup for test--------------------------
     var mockExplorerResourceRepository = new Mock<IClientExplorerResourceRepository>();
     mockExplorerResourceRepository.Setup(m => m.AddItem(It.IsAny<IExplorerItem>(), It.IsAny<Guid>()))
                                   .Returns(new ExplorerRepositoryResult(ExecStatus.Fail, "Just Failed"));
     SetupEnvironmentRepo(Guid.Empty);
     var mockVersionRepository = new Mock<IVersionRepository>();
     var repository = new StudioResourceRepository(null, Guid.Empty, _invoke)
     {
         GetVersionProxy = id => mockVersionRepository.Object,
         GetExplorerProxy = id => mockExplorerResourceRepository.Object
     };
     //------------Execute Test---------------------------
     repository.AddItem(new ExplorerItemModel { Parent = new ExplorerItemModel() });
 }
 public void StudioResourceRepository_AddItem_CallsServiceAddItem()
 {
     //------------Setup for test--------------------------
     var mockExplorerResourceRepository = new Mock<IClientExplorerResourceRepository>();
     mockExplorerResourceRepository.Setup(m => m.AddItem(It.IsAny<IExplorerItem>(), It.IsAny<Guid>()))
                                   .Returns(new ExplorerRepositoryResult(ExecStatus.Success, "Success"))
                                   .Verifiable();
     SetupEnvironmentRepo(Guid.Empty);
     var mockVersionRepository = new Mock<IVersionRepository>();
     var repository = new StudioResourceRepository(null, Guid.Empty, _invoke)
         {
             GetVersionProxy = id => mockVersionRepository.Object,
             GetExplorerProxy = id => mockExplorerResourceRepository.Object
         };
     //------------Execute Test---------------------------
     repository.AddItem(new ExplorerItemModel { Parent = new ExplorerItemModel() });
     //------------Assert Results-------------------------
     mockExplorerResourceRepository.Verify(m => m.AddItem(It.IsAny<IExplorerItem>(), It.IsAny<Guid>()), Times.Once());
 }
        public void StudioResourceRepository_AddItem_AttachedToParent_AddCalledOnServer()
        {
            //------------Setup for test--------------------------
            var mockExplorerResourceRepository = new Mock<IClientExplorerResourceRepository>();
            mockExplorerResourceRepository.Setup(m => m.AddItem(It.IsAny<IExplorerItem>(), It.IsAny<Guid>()))
                                .Returns(new ExplorerRepositoryResult(ExecStatus.Success, "Success"));
            var mockVersionRepository = new Mock<IVersionRepository>();
            SetupEnvironmentRepo(Guid.Empty);

            var repository = new StudioResourceRepository(GetTestData(), Guid.Empty, _invoke)
                {
                    GetVersionProxy = id => mockVersionRepository.Object,
                    GetExplorerProxy = id => mockExplorerResourceRepository.Object
                };
            var parent = repository.ExplorerItemModels[0].Children[0];

            var environmentId = Guid.NewGuid();
            var folderId = Guid.NewGuid();

            var folder1 = new ExplorerItemModel
            {
                Parent = parent,
                DisplayName = "subFolder 1",
                EnvironmentId = environmentId,
                Permissions = Permissions.Contribute,
                ResourceId = folderId,
            };
            //------------Execute Test---------------------------
            repository.AddItem(folder1);
            //------------Assert Results-------------------------
            mockExplorerResourceRepository.Verify(m => m.AddItem(It.IsAny<IExplorerItem>(), It.IsAny<Guid>()), Times.Once());
        }
        public void StudioResourceRepository_AddItem_ItemNotAttachedToParent_ThrowsException()
        {
            //------------Setup for test--------------------------
            var mockExplorerResourceRepository = new Mock<IClientExplorerResourceRepository>();
            SetupEnvironmentRepo(Guid.Empty);
            var mockVersionRepository = new Mock<IVersionRepository>();
            var repository = new StudioResourceRepository(null, Guid.Empty, _invoke)
                {
                    GetVersionProxy = id => mockVersionRepository.Object,
                    GetExplorerProxy = id => mockExplorerResourceRepository.Object
                };

            var environmentId = Guid.NewGuid();
            var folderId = Guid.NewGuid();
            var explorerItemModel = new ExplorerItemModel
            {
                DisplayName = "FOLDER 1",
                EnvironmentId = environmentId,
                Permissions = Permissions.Contribute,
                ResourceId = folderId,
            };
            //------------Execute Test---------------------------
            repository.AddItem(explorerItemModel);
        }
 public void StudioResourceRepository_AddItem_ItemIsNull_ThrowsException()
 {
     //------------Setup for test--------------------------
     var mockExplorerResourceRepository = new Mock<IClientExplorerResourceRepository>();
     var mockVersionRepository = new Mock<IVersionRepository>();
     SetupEnvironmentRepo(Guid.Empty);
     var repository = new StudioResourceRepository(GetTestData(), Guid.Empty, _invoke)
         {
             GetVersionProxy = id => mockVersionRepository.Object,
             GetExplorerProxy = id => mockExplorerResourceRepository.Object
         };
     //------------Execute Test---------------------------
     repository.AddItem(null);
 }