Exemple #1
0
 public void CarneBateryTest(FlagFilter filter)
 {
     Assert.IsFalse(filter.Test(new string[] { }));
     Assert.IsTrue(filter.Test(new string[] { "vegetal", "carne" }));
     Assert.IsTrue(filter.Test(new string[] { "carne" }));
     Assert.IsFalse(filter.Test(new string[] { "vegetal" }));
     Assert.IsFalse(filter.Test(new string[] { "vegetal", "tomate", "cebola" }));
 }
Exemple #2
0
 public void Complex1BateryTest(FlagFilter filter)
 {
     //v1 or v2, never in test
     Assert.IsFalse(filter.Test(new string[] { "test" }));
     Assert.IsFalse(filter.Test(new string[] { "test", "v1" }));
     Assert.IsFalse(filter.Test(new string[] { "v3" }));
     Assert.IsTrue(filter.Test(new string[] { "v1" }));
     Assert.IsTrue(filter.Test(new string[] { "v2", "production" }));
 }
Exemple #3
0
        //[TestMethod]
        //public void ComplexFilter2_2()
        //{
        //    var filter = new FlagFilter("!test&((v1)|(v2))");
        //}

        //[TestMethod]
        //public void ComplexFilter2_3()
        //{
        //    var filter = new FlagFilter("!(test)&((v1)|(v2))");
        //}

        public void Complex2BateryTest(FlagFilter filter)
        {
            //meat, vegetable or fruit. never with muchSugar or muchCarbo. never rot
            Assert.IsFalse(filter.Test(new string[] { "rock" }));
            Assert.IsTrue(filter.Test(new string[] { "meat" }));
            Assert.IsFalse(filter.Test(new string[] { "meat", "rot" }));
            Assert.IsFalse(filter.Test(new string[] { "fruit", "muchSugar" }));
            Assert.IsTrue(filter.Test(new string[] { "fruit", "meat", "vegetable" }));
            Assert.IsFalse(filter.Test(new string[] { "fruit", "meat", "vegetable", "rot" }));
        }
Exemple #4
0
        public void NotCarneBateryTest(FlagFilter filter)
        {
            var result = !(new string[] { }).Contains("carne");

            Assert.IsTrue(filter.Test(new string[] { }), "Empty");
            Assert.IsFalse(filter.Test(new string[] { "vegetal", "carne" }), "vegetal,carne");
            Assert.IsFalse(filter.Test(new string[] { "carne" }), "carne");
            Assert.IsTrue(filter.Test(new string[] { "vegetal" }), "vegetal");
            Assert.IsTrue(filter.Test(new string[] { "vegetal", "tomate", "cebola" }), "vegetal,tomate,cebola");
            Assert.IsTrue(filter.Test(new string[] { "tomate", "cebola" }), "tomate,cebola");
        }
        internal void TrimFolder(string folder, string filter)
        {
            filter = filter.ToLowerInvariant();
            var        allFiles   = System.IO.Directory.GetFiles(folder, "*.*", System.IO.SearchOption.AllDirectories);
            FlagFilter flagFilter = new FlagFilter(filter);

            System.Uri rootFolder = new Uri(folder);
            foreach (var filePath in allFiles)
            {
                System.Uri fileUri     = new Uri(filePath);
                Uri        relativeUri = rootFolder.MakeRelativeUri(fileUri);
                var        parts       = relativeUri.ToString().ToLowerInvariant().Split('/');
                var        flags       = parts.Skip(1).Take(parts.Length - 2).ToArray();
                if (!flagFilter.Test(flags))
                {
                    System.IO.File.Delete(filePath);
                }
            }
        }
 public void Filter(MigrationFilterContext migrationFilterContext)
 {
     foreach (var node in migrationFilterContext.MigrationNodes)
     {
         List <IMigration> exceptMigrations = new List <IMigration>();
         foreach (var migration in node.MigrationsInfo.Select(x => x.Migration))
         {
             if (migration is IFlaggedMigration)
             {
                 var flags = ((IFlaggedMigration)migration).GetFlags();
                 if (!filter.Test(flags.ToArray()))
                 {
                     exceptMigrations.Add(migration);
                 }
             }
         }
         node.MigrationsInfo = node.MigrationsInfo.Where(x => !exceptMigrations.Contains(x.Migration)).ToList();
     }
 }