public void OpenFileStream_Throws_Exception_With_Filepath()
        {
            var fakePath = Guid.NewGuid().ToString();

            var opener = new RetryableFileOpener();

            var ex = Assert.Throws<IOException>(() => opener.OpenFileStream(fakePath, 0, FileMode.Open, FileAccess.ReadWrite, FileShare.None));

            Assert.True(ex.Message.Contains(fakePath));
        }
        public void OpenTextStreamReader_Throws_Exception_With_Filepath()
        {
            var fakePath = Guid.NewGuid().ToString();

            var opener = new RetryableFileOpener();

            var ex = Assert.Throws<IOException>(() => opener.OpenTextStreamReader(fakePath, 0));

            Assert.True(ex.Message.Contains(fakePath));
        }
        public void OpenFileStream_Directory_DoesNotExists_ShouldCreate()
        {

            var folder = TestUtilities.PreparePath(Path.Combine(Environment.CurrentDirectory, Guid.NewGuid().ToString(), Guid.NewGuid().ToString()));
            try
            {

                var opener = new RetryableFileOpener();

                var filePath = Path.Combine(folder, "file.js");
                using (opener.OpenFileStream(filePath, 2, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
                {
                }

                Assert.True(File.Exists(filePath));
            }
            finally
            {
                Directory.Delete(folder, true);
            }
        }
        public void OpenTextStreamWriter_Directory_Exists()
        {

            var folder = TestUtilities.PreparePath(Path.Combine(Environment.CurrentDirectory, Guid.NewGuid().ToString()));
            try
            {

                Directory.CreateDirectory(folder);

                var opener = new RetryableFileOpener();

                var filePath = Path.Combine(folder, "file.js");
                using (opener.OpenTextStreamWriter(filePath, 2, false))
                {
                }

                Assert.True(File.Exists(filePath));
            }
            finally
            {
                Directory.Delete(folder, true);
            }
        }
Exemplo n.º 5
0
 public void Setup()
 {
     cssBundleFactory = new CSSBundleFactory();
     var retryableFileOpener = new RetryableFileOpener();
     hasher = new Hasher(retryableFileOpener);
 }
Exemplo n.º 6
0
        public void Setup()
        {
            var nonDebugStatusReader = new StubDebugStatusReader(false);
            var debugStatusReader = new StubDebugStatusReader(true);
            fileWriterFactory = new StubFileWriterFactory();
            fileReaderFactory = new StubFileReaderFactory();
            currentDirectoryWrapper = new StubCurrentDirectoryWrapper();

            var retryableFileOpener = new RetryableFileOpener();
            hasher = new Hasher(retryableFileOpener);

            fileReaderFactory.SetContents(javaScript);

            javaScriptBundle = new JavaScriptBundle(nonDebugStatusReader,
                                                                                            fileWriterFactory,
                                                                                            fileReaderFactory,
                                                                                            currentDirectoryWrapper,
                                                                                            hasher);

            javaScriptBundle2 = new JavaScriptBundle(nonDebugStatusReader,
                                                                                            fileWriterFactory,
                                                                                            fileReaderFactory,
                                                                                            currentDirectoryWrapper,
                                                                                            hasher);

            debugJavaScriptBundle = new JavaScriptBundle(debugStatusReader,
                                                                                                    fileWriterFactory,
                                                                                                    fileReaderFactory,
                                                                                                    currentDirectoryWrapper,
                                                                                                    hasher);

            debugJavaScriptBundle2 = new JavaScriptBundle(debugStatusReader,
                                                                                                    fileWriterFactory,
                                                                                                    fileReaderFactory,
                                                                                                    currentDirectoryWrapper,
                                                                                                    hasher);
        }
Exemplo n.º 7
0
 public void Setup()
 {
     javaScriptBundleFactory = new JavaScriptBundleFactory()
         .WithDebuggingEnabled(false);
     javaScriptBundleFactory.FileReaderFactory.SetContents(javaScript);
     var retryableFileOpener = new RetryableFileOpener();
     hasher = new Hasher(retryableFileOpener);
 }
 public void Setup()
 {
     javaScriptBundleFactory = new JavaScriptBundleFactory();
     var retryableFileOpener = new RetryableFileOpener();
     hasher = new Hasher(retryableFileOpener);
 }
Exemplo n.º 9
0
        public void Setup()
        {
            var nonDebugStatusReader = new StubDebugStatusReader(false);
            var debugStatusReader = new StubDebugStatusReader(true);
            currentDirectoryWrapper = new StubCurrentDirectoryWrapper();
            stubBundleCache = new ApplicationCache();

            var retryableFileOpener = new RetryableFileOpener();
            hasher = new Hasher(retryableFileOpener);

            //fileReaderFactory.SetContents(javaScript);

            javaScriptBundle = new JavaScriptBundle(nonDebugStatusReader,
                                                        fileWriterFactory,
                                                        fileReaderFactory,
                                                        currentDirectoryWrapper,
                                                        hasher,
                                                        stubBundleCache);

            javaScriptBundle2 = new JavaScriptBundle(nonDebugStatusReader,
                                                        fileWriterFactory,
                                                        fileReaderFactory,
                                                        currentDirectoryWrapper,
                                                        hasher,
                                                        stubBundleCache);

            debugJavaScriptBundle = new JavaScriptBundle(debugStatusReader,
                                                        fileWriterFactory,
                                                        fileReaderFactory,
                                                        currentDirectoryWrapper,
                                                        hasher,
                                                        stubBundleCache);

            debugJavaScriptBundle2 = new JavaScriptBundle(debugStatusReader,
                                                        fileWriterFactory,
                                                        fileReaderFactory,
                                                        currentDirectoryWrapper,
                                                        hasher,
                                                        stubBundleCache);

            outputFileNumber += 1;
            currentOutputFile = outputFileRoot + outputFileNumber + ".js";
        }