public void CreateLogger_UsesSameFileWriter_ForSameFile()
        {
            var options = new ScriptJobHostOptions
            {
                RootLogPath = Path.GetTempPath()
            };
            var fileStatus    = new Mock <IFileLoggingStatusManager>();
            var primaryStatus = new Mock <IPrimaryHostStateProvider>();

            using (var provider = new FunctionFileLoggerProvider(new OptionsWrapper <ScriptJobHostOptions>(options), fileStatus.Object, primaryStatus.Object))
            {
                provider.CreateLogger(LogCategories.CreateFunctionCategory("Test1"));
                provider.CreateLogger(LogCategories.CreateFunctionUserCategory("Test1"));
                provider.CreateLogger(LogCategories.CreateFunctionCategory("Test1"));

                Assert.Single(provider.FileWriterCache);

                // This creates a new entry.
                provider.CreateLogger(LogCategories.CreateFunctionCategory("Test2"));

                Assert.Equal(2, provider.FileWriterCache.Count);
                Assert.NotSame(
                    provider.FileWriterCache[Path.Combine("Function", "Test1")],
                    provider.FileWriterCache[Path.Combine("Function", "Test2")]);
            }
        }
        public void CreateLogger_UsesSameFileWriter_ForSameFile()
        {
            var rootPath = Path.GetTempPath();

            using (var provider = new FunctionFileLoggerProvider(Guid.NewGuid().ToString(), rootPath, () => true, () => true))
            {
                provider.CreateLogger(LogCategories.CreateFunctionCategory("Test1"));
                provider.CreateLogger(LogCategories.CreateFunctionUserCategory("Test1"));
                provider.CreateLogger(LogCategories.CreateFunctionCategory("Test1"));

                Assert.Single(provider.FileWriterCache);

                // This creates a new entry.
                provider.CreateLogger(LogCategories.CreateFunctionCategory("Test2"));

                Assert.Equal(2, provider.FileWriterCache.Count);
                Assert.NotSame(
                    provider.FileWriterCache[Path.Combine("Function", "Test1")],
                    provider.FileWriterCache[Path.Combine("Function", "Test2")]);
            }
        }
 public void CreateLogger_GetsCorrectPath(string category, string expectedPath)
 {
     Assert.Equal(expectedPath, FunctionFileLoggerProvider.GetFilePath(category));
 }