<commit_before>﻿using NSubstitute;
using PoshGit2;
using System;
using System.IO;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Xunit;

namespace PoshGit.Tests
{
    public class GitFolderWatcherTests
    {
        private const int DelayTime = 10;

        private static string CreateTempGitDirectory()
        {
            var testFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(testFolder);
            Directory.CreateDirectory(Path.Combine(testFolder, ".git"));

            Console.WriteLine(testFolder);

            return testFolder;
        }

        [Fact]
        public async Task WatchFolder()
        {
            var directory = CreateTempGitDirectory();
            var watcher = new GitFolderWatcher(directory);
            var observer = Substitute.For<IObserver<string>>();

            var observable = Observable.FromEvent<string>(a => watcher.OnNext += a, a => watcher.OnNext -= a);
            observable.Subscribe(observer);

            var newFile = Path.Combine(directory, "rewrite-file.tmp");
            File.WriteAllText(newFile, "test");
            File.WriteAllText(newFile, "something");<commit_msg>Increase delay time in tests<commit_after>﻿using NSubstitute;
using PoshGit2;
using System;
using System.IO;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Xunit;

namespace PoshGit.Tests
{
    public class GitFolderWatcherTests
    {
        private const int DelayTime = 30;

        private static string CreateTempGitDirectory()
        {
            var testFolder = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(testFolder);
            Directory.CreateDirectory(Path.Combine(testFolder, ".git"));

            Console.WriteLine(testFolder);

            return testFolder;
        }

        [Fact]
        public async Task WatchFolder()
        {
            var directory = CreateTempGitDirectory();
            var watcher = new GitFolderWatcher(directory);
            var observer = Substitute.For<IObserver<string>>();

            var observable = Observable.FromEvent<string>(a => watcher.OnNext += a, a => watcher.OnNext -= a);
            observable.Subscribe(observer);

            var newFile = Path.Combine(directory, "rewrite-file.tmp");
            File.WriteAllText(newFile, "test");
            File.WriteAllText(newFile, "something");
{'fraction_non_alphanumeric': 0.10453246222948143, 'fraction_numerical': 0.002449979583503471, 'mean_word_length': 2.5871156661786237, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2477034', 'n_tokens_mistral': 679, 'n_tokens_neox': 639, 'n_words': 143}