public void GetFileDataAsyncThrowsNotFoundExceptionIfEntityDoesNotExistTest()
        {
            var mockUnitOfWork = new Mock<IUnitOfWork>();
            var mockLoggerService = new Mock<ILoggerService>();

            mockUnitOfWork.Setup(x => x.Repository<FileBlob>().GetAsync(It.IsAny<Expression<Func<FileBlob, bool>>>()))
                .Returns(() => Task.FromResult<FileBlob>(null));
            var persistenceService = new FilesPersistenceService(mockUnitOfWork.Object, mockLoggerService.Object);

            Assert.Throws<NotFoundException>(async () => await persistenceService.GetFileDataAsync(It.IsAny<Guid>()));
        }
        public async Task GetFileDataAsyncCallsCorrectUnitOfWorkMethodTest()
        {
            var entity = new FileBlob();

            var mockUnitOfWork = new Mock<IUnitOfWork>();
            var mockLoggerService = new Mock<ILoggerService>();

            mockUnitOfWork.Setup(x => x.Repository<FileBlob>().GetAsync(It.IsAny<Expression<Func<FileBlob, bool>>>()))
                .Returns(() => Task.FromResult(entity));

            var persistenceService = new FilesPersistenceService(mockUnitOfWork.Object, mockLoggerService.Object);

            await persistenceService.GetFileDataAsync(It.IsAny<Guid>());
            mockUnitOfWork.Verify(m => m.Repository<FileBlob>().GetAsync(It.IsAny<Expression<Func<FileBlob, bool>>>()), Times.Once);
        }
        public async Task SaveFileDataAsyncCallsCorrectUnitOfWorkMethodsIfNewTest()
        {      
            var mockUnitOfWork = new Mock<IUnitOfWork>();
            var mockLoggerService = new Mock<ILoggerService>();

            mockUnitOfWork.Setup(x => x.Repository<FileBlob>().GetAllAsync(It.IsAny<Expression<Func<FileBlob, bool>>>()))
                .Returns(() => Task.FromResult<IEnumerable<FileBlob>>(null));

            var persistenceService = new FilesPersistenceService(mockUnitOfWork.Object, mockLoggerService.Object);
            var byteArray = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
            await persistenceService.SaveFileDataAsync(byteArray, "img", "MyTest.img");

            mockUnitOfWork.Verify(m => m.Repository<FileBlob>().Add(It.IsAny<FileBlob>()), Times.Once);
            mockUnitOfWork.Verify(m => m.SaveChanges(), Times.Once);
        }