Ejemplo n.º 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.lstFolder.SelectedItems.Count <= 0)
            {
                return;
            }

            ClassFolder f = FolderController.getFolder(lstFolder.Items[lstFolder.SelectedIndex].ToString());

            FolderController.DeleteFolder(f);
            BindingSource source = new BindingSource();

            source.DataSource         = FolderController.getListFolder();
            this.lstFolder.DataSource = source;
        }
Ejemplo n.º 2
0
        //Xóa folder trên database
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.lstFolder.SelectedItems.Count <= 0)
            {
                return;
            }
            ClassFolder f = new ClassFolder();

            f = listfolder.Where(x => x.namefolder == txtNameFolder.Text).Single();
            for (int i = 0; i < lstFileName.Items.Count; i++)
            {
                FolderController.DeleteFile(txtNameFolder.Text, int.Parse(lstFileName.Items[i].SubItems[3].Text));
                if (!(FolderController.Containfif(FileController.getFile(int.Parse(lstFileName.Items[i].SubItems[3].Text)))))
                {
                    FileController.DeleteFile(int.Parse(lstFileName.Items[i].SubItems[3].Text));
                }
            }
            FolderController.DeleteFolder(f);
            displayFolder();
            lstFileName.Items.Clear();
        }
        public async Task GetById_ReturnsAIActionResult_WithARemovedFolderFromDatabase()
        {
            // Arrange
            var expected = "Test One";//Name of folder

            //SignalRHubMock
            var mockHub     = new Mock <IHubContext <FolderHub> >();
            var mockClients = new Mock <IHubClients>();
            Mock <IClientProxy> mockClientProxy = new Mock <IClientProxy>();

            mockClients.Setup(clients => clients.All).Returns(mockClientProxy.Object);
            mockHub.Setup(repo => repo.Clients).Returns(mockClients.Object);

            //EF database Mock
            var mockDb = new Mock <IEFFileFolderContext>();

            mockDb.Setup(repo => repo.GetFolderByIdAsync(1))
            .ReturnsAsync(GetOneTestSessions());

            var controller = new FolderController(mockDb.Object, mockHub.Object);
            // Act
            var result = await controller.DeleteFolder(1);

            // Assert
            //var okObjectResult = result as OkObjectResult;
            var okObjectResult = Assert.IsType <OkObjectResult>(result);

            Assert.NotNull(okObjectResult);

            var model = okObjectResult.Value as Folder;

            Assert.NotNull(model);

            var actual = model.Name;

            Assert.Equal(expected, actual);
        }