Ejemplo n.º 1
0
        public async Task TestTFileListExist(bool enabled, int nbreOfFile, bool deleting)
        {
            CleanFiles();
            GenerateFiles(nbreOfFile);
            Assert.AreEqual(nbreOfFile, Directory.EnumerateFiles(path).Count());

            bool hasfile = false;
            int  counterExist = 0, counterDeleted = 0;

            TFileList <FilenameSchema> liste = ctx.GetService <TFileList <FilenameSchema> >();

            Assert.IsNotNull(liste);
            RegisterComponentForEvents(liste);
            liste.Path    = path;
            liste.Enabled = enabled;
            liste.OnOutput.SubscribeOn(scheduler).Subscribe(e =>
            {
                Debug.WriteLine(e.Filename);
                hasfile = true;
                ++counterExist;
            });

            liste.AddToJob(job);


            TFileDelete <FilenameSchema, FilenameSchema> delete = ctx.GetService <TFileDelete <FilenameSchema, FilenameSchema> >();

            Assert.IsNotNull(delete);
            RegisterComponentForEvents(delete);
            delete.OnOutput.SubscribeOn(scheduler).Subscribe(e =>
            {
                ++counterDeleted;
            });
            delete.Passthrue = deleting;
            delete.AddInput(job, liste.OnOutput);


            await Start();

            if (enabled)
            {
                Assert.IsTrue(hasfile);
                Assert.IsTrue(liste.Enabled);
                Assert.AreEqual(nbreOfFile, counterExist);
            }
            else
            {
                Assert.IsFalse(hasfile);
                Assert.IsFalse(liste.Enabled);
                Assert.AreEqual(counterExist, 0);
            }
            Assert.AreEqual(counterDeleted, counterExist);
            if (!delete.Passthrue && liste.Enabled)
            {
                Assert.AreEqual(Directory.EnumerateFiles(path).Count(), 0);
            }
        }
Ejemplo n.º 2
0
        public async Task TestTFileList(int nbreOfFile)
        {
            CleanFiles();
            GenerateFiles(nbreOfFile);
            Assert.AreEqual(nbreOfFile, Directory.EnumerateFiles(path).Count());
            TFileList <FilenameSchema> liste = ctx.GetService <TFileList <FilenameSchema> >();

            Assert.IsNotNull(liste);
            RegisterComponentForEvents(liste);
            liste.Path = path;
            liste.AddToJob(job);
            var dbg = new DebugObserver <FilenameSchema>(nameof(TestTFileList));

            liste.OnOutput.SubscribeOn(scheduler).Subscribe(dbg);

            await Start();
        }