Beispiel #1
0
        public async Task RestoreFile_RestoringRemovedFile_Successful()
        {
            var nodes = TestData.CreateFiles();

            // Arrange
            var fakeUnitOfWork = MockingManager.GetFakeUnitOfWork();


            fakeUnitOfWork.Setup(t => t.NodeRepository.GetAllNodesForUserWithPredicate(It.IsAny <string>(), false)).ReturnsAsync(nodes);

            var fakeBlobService = MockingManager.GetBlobService(fakeUnitOfWork.Object);
            var fileService     = MockingManager.GetFileService(fakeUnitOfWork.Object, fakeBlobService);

            // Act

            // Remove
            var removeRequest = await fileService.RemoveFileAsync(new Guid("37e32a9e-bd72-48e2-9a7b-5c4fdbda6be1"), fakeEmail);

            Assert.Equal(fileService.State.TypeOfError, TypeOfServiceError.Success);
            // Restore
            var restoreRequest = await fileService.RestoreRemovedFileAsync(new Guid("37e32a9e-bd72-48e2-9a7b-5c4fdbda6be1"),
                                                                           fakeEmail);

            // Assert
            Assert.NotNull(restoreRequest);
        }
Beispiel #2
0
        public async Task ReplaceFile_ReplacingFileAndPlacingInRequestedFolder_Successful()
        {
            var nodes = TestData.CreateFiles();


            // Arrange
            var fakeUnitOfWork = MockingManager.GetFakeUnitOfWork();


            fakeUnitOfWork.Setup(t => t.NodeRepository.GetAllNodesForUserWithPredicate(It.IsAny <string>(), false)).ReturnsAsync(nodes);

            var fakeBlobService = MockingManager.GetBlobService(fakeUnitOfWork.Object);
            var fileService     = MockingManager.GetFileService(fakeUnitOfWork.Object, fakeBlobService);

            // Act
            var replaceRequest = await fileService.ReplaceFileAsync(fakeEmail, new Guid("37e32a9e-bd72-48e2-9a7b-5c4fdbda6be1"),
                                                                    new ReplaceRequest()
            {
                DestanationFolderId = new Guid("37e32a9e-bd72-48e2-9a7b-5c4fdbda3xj5"),
            });


            // Assert
            Assert.Equal(fileService.State.TypeOfError, TypeOfServiceError.Success);
            Assert.Equal(replaceRequest.DirectoryId, new Guid("37e32a9e-bd72-48e2-9a7b-5c4fdbda3xj5"));
        }
Beispiel #3
0
        public async Task GetUserFile_WhenRequestedFromAnonymousReturnError_Successful()
        {
            // Arrange
            var fakeUnitOfWork  = MockingManager.GetFakeUnitOfWork();
            var fakeBlobService = MockingManager.GetBlobService(fakeUnitOfWork.Object);
            var fileService     = MockingManager.GetFileService(fakeUnitOfWork.Object, fakeBlobService);

            // Act
            var result = await fileService.GetFileAsync(new Guid(), fakeEmail, 1);

            // Assert
            Assert.Equal(fileService.State.TypeOfError, TypeOfServiceError.Forbidden);
        }
Beispiel #4
0
        public async Task GetUserFile_WhenRequestedExistedFileReturnFileStream_Successful()
        {
            var nodes = TestData.CreateFiles();

            // Arrange
            var fakeUnitOfWork = MockingManager.GetFakeUnitOfWork();


            fakeUnitOfWork.Setup(t => t.NodeRepository.GetAllNodesForUserWithPredicate(It.IsAny <string>(), false)).ReturnsAsync(nodes);

            var fakeBlobService = MockingManager.GetBlobService(fakeUnitOfWork.Object);
            var fileService     = MockingManager.GetFileService(fakeUnitOfWork.Object, fakeBlobService);
            // Act
            var result = await fileService.GetFileAsync(new Guid("37e32a9e-bd72-48e2-9a7b-5c4fdbda6be1"), fakeEmail, 1);

            // Assert
            Assert.NotNull(result.Item1);
        }
Beispiel #5
0
        public async Task RenameFile_ReturnOkWhenFileRenamed_Successful()
        {
            var nodes = TestData.CreateFiles();

            // Arrange
            var fakeUnitOfWork = MockingManager.GetFakeUnitOfWork();


            fakeUnitOfWork.Setup(t => t.NodeRepository.GetAllNodesForUserWithPredicate(It.IsAny <string>(), false)).ReturnsAsync(nodes);

            var fakeBlobService = MockingManager.GetBlobService(fakeUnitOfWork.Object);
            var fileService     = MockingManager.GetFileService(fakeUnitOfWork.Object, fakeBlobService);

            // Act
            var result = await fileService.RenameFileAsync(new Guid("37e32a9e-bd72-48e2-9a7b-5c4fdbda6be1"), "new-name", fakeEmail);

            // Assert
            Assert.Equal(result.Name, "new-name");
        }
Beispiel #6
0
        public async Task GetUserFile_WhenRequestedFileNotExistReturnNotFound_Successful()
        {
            var nodes = TestData.CreateFiles();

            // Arrange
            var fakeUnitOfWork = MockingManager.GetFakeUnitOfWork();


            fakeUnitOfWork.Setup(t => t.NodeRepository.GetAllNodesForUserWithPredicate(It.IsAny <string>(), false)).ReturnsAsync(nodes);

            var fakeBlobService = MockingManager.GetBlobService(fakeUnitOfWork.Object);
            var fileService     = MockingManager.GetFileService(fakeUnitOfWork.Object, fakeBlobService);

            // Act
            var result = await fileService.GetFileAsync(new Guid(), fakeEmail, 1);

            // Assert
            Assert.Equal(fileService.State.TypeOfError, TypeOfServiceError.NotFound);
            Assert.NotNull(result.Item2);
        }