public void Execute_ShouldCallGetFilesToBePurged()
        {
            bool getFilesToBePurgedWasCalled = false;
            FSI.IFileService fileservice = new StubIFileService()
            {
                GetFilesToBePurgedDouble = validStorageDays =>
                {
                    getFilesToBePurgedWasCalled = true;
                    return new List<File>();
                }
            };

            IUnityContainer unityContainer = new UnityContainer();

            using (ShimsContext.Create())
            {
                ShimDiagnosticsProvider.ConstructorType = (dp, type) => { };
                Constants.ShimConstants.UploadedFilesExpirationDurationInHoursGet = () => 3;
                ShimDiagnosticsProvider.AllInstances.WriteInformationTraceTraceEventIdStringObjectArray = (diagnosticsProvider, traceEventId, message, args) => { };
                IFileService filePurgeService = new FilePurgeService(fileservice, unityContainer);
                filePurgeService.Execute();
            }

            Assert.IsTrue(getFilesToBePurgedWasCalled);
        }
        public void Execute_ShouldCallDeleteFileForEachFileReturnedByGetFilesToBePurged()
        {
            int numberOfCallsToDeleteFile = 0;
            FSI.IFileService fileservice = new StubIFileService()
            {
                GetFilesToBePurgedDouble = validStorageDays => GetFiles(),
                DeleteFileInt32Int32 = (userId, fileId) =>
                {
                    numberOfCallsToDeleteFile++;
                    return true;
                }
            };

            IUnityContainer unityContainer = new UnityContainer();

            using (ShimsContext.Create())
            {
                ShimDiagnosticsProvider.ConstructorType = (dp, type) => { };
                Constants.ShimConstants.UploadedFilesExpirationDurationInHoursGet = () => 3;
                ShimDiagnosticsProvider.AllInstances.WriteInformationTraceTraceEventIdStringObjectArray = (diagnosticsProvider, traceEventId, message, args) => { };
                FilePurgeService filePurgeService = new FilePurgeService(fileservice, unityContainer);
                filePurgeService.Execute();
            }

            Assert.AreEqual(4, numberOfCallsToDeleteFile);
        }
        public void Execute_UnhandledExceptionShouldWriteErrorTrace()
        {
            bool writeErrorTraceWasCalled = false;
            FSI.IFileService fileservice = new StubIFileService()
            {
                GetFilesToBePurgedDouble = validStorageDays => { throw new Exception(); }
            };

            IUnityContainer unityContainer = new UnityContainer();

            using (ShimsContext.Create())
            {
                ShimDiagnosticsProvider.ConstructorType = (dp, type) => { };
                Constants.ShimConstants.UploadedFilesExpirationDurationInHoursGet = () => 3;
                ShimDiagnosticsProvider.AllInstances.WriteErrorTraceTraceEventIdStringObjectArray = (diagnosticsProvider, traceEventId, message, args) => { writeErrorTraceWasCalled = true; };
                FilePurgeService filePurgeService = new FilePurgeService(fileservice, unityContainer);
                filePurgeService.Execute();
            }

            Assert.IsTrue(writeErrorTraceWasCalled);
        }