Ejemplo n.º 1
0
        public void Execute_UnhandledExceptionShouldWriteErrorTrace()
        {
            bool writeErrorTraceWasCalled = false;
            FSI.IFileService fileservice = new StubIFileService()
            {
                GetUploadedFiles = () => { throw new Exception(); }
            };

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

            Assert.IsTrue(writeErrorTraceWasCalled);
        }
Ejemplo n.º 2
0
        public void Execute_ShouldCallGetUploadedFiles()
        {
            bool getUploadedFilesWasCalled = false;
            FSI.IFileService fileservice = new StubIFileService()
            {
                GetUploadedFiles = () => {
                    getUploadedFilesWasCalled = true;
                    return new List<File>();
                }
            };

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

            Assert.IsTrue(getUploadedFilesWasCalled);
        }
Ejemplo n.º 3
0
        public void Execute_ShouldCallUpdateFileForEachFileReturnedByGetUploadedFiles()
        {
            int numberOfCallsToUpdateFile = 0;
            FSI.IFileService fileservice = new StubIFileService()
            {
                GetUploadedFiles = () => GetFiles(),
                UpdateFileFile = (file) => {
                    numberOfCallsToUpdateFile++;
                    return true;
                }
            };

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

            Assert.AreEqual(4, numberOfCallsToUpdateFile);
        }