public void GetPhysicalFile_ThrowsExceptionWhenNotFoundRemoteFile()
 {
     const string content = "JavaScript2.js";
     string remoteFileAddress = "{0}/{1}".FormatWith(BASE_ADDRESS, content);
     HttpResourceReader httpResourceReader = new HttpResourceReader(null, null);
     string fileName;
     string fileContent;
     Assert.Throws<HttpResourceReaderException>(() => httpResourceReader.GetPhysicalFile(remoteFileAddress, out fileName, out fileContent));
 }
        public void GetPhysicalFile()
        {
            Mock<IRemoteFileTempFolderProvider> remoteFileTempFolderProviderMock = new Mock<IRemoteFileTempFolderProvider>();
            
            const string content = "JavaScript1.js";
            string remoteFileAddress = "{0}/{1}".FormatWith(BASE_ADDRESS, content);
            string tempFile = Path.Combine(GetContentsFolder(), "JavaScript1.temp.js");
            remoteFileTempFolderProviderMock.Setup(x => x.GetTempFilePath(remoteFileAddress)).Returns(tempFile);

            HttpResourceReader httpResourceReader = new HttpResourceReader(remoteFileTempFolderProviderMock.Object, null);
            string fileName;
            string fileContent;
            httpResourceReader.GetPhysicalFile(remoteFileAddress, out fileName, out fileContent);

            Assert.IsTrue(File.Exists(fileName));
            Assert.AreEqual(tempFile, fileName);
            Assert.AreEqual(File.ReadAllText(Path.Combine(GetContentsFolder(), content)), fileContent);
            Assert.AreEqual(File.ReadAllText(tempFile), fileContent);
        }
 public void GetPhysicalFile_ThrowsExceptionWhenPathIsNull()
 {
     HttpResourceReader httpResourceReader = new HttpResourceReader(null, null);
     string fileName;
     string fileContent;
     Assert.Throws<ArgumentNullException>(() => httpResourceReader.GetPhysicalFile(null, out fileName, out fileContent));
 }