コード例 #1
0
        public void ToArrayTest04()
        {
            HashSet <int> hashSet;

            int[] ints = new int[90];
            hashSet = HashSetFactory.Create(ints);
            this.ToArrayTest(hashSet);
        }
コード例 #2
0
        public void RemoveNodeWithBothSubtreesTest06()
        {
            HashSet <int> hashSet;

            int[] ints = new int[90];
            hashSet = HashSetFactory.Create(ints);
            this.RemoveNodeWithBothSubtreesTest(hashSet, 0);
        }
コード例 #3
0
        public void AddTest12()
        {
            HashSet <int> hashSet;

            int[] ints = new int[198];
            hashSet = HashSetFactory.Create(ints);
            this.AddTest(hashSet);
        }
コード例 #4
0
 public void Initialize()
 {
     TestCommon.InitializeTest();
     _hashSet = HashSetFactory.CreateNew(
         DirPath,
         Guid.NewGuid().ToString("P"),
         ServiceProvider.GetAllInstances <IHasher>().FirstOrDefault(p => p.GUID == HashGUID)
         );
     Assert.IsNotNull(_hashSet);
 }
コード例 #5
0
 //gets the correct hash set with the chosen hash function
 private HashSet <Cloneable> getHashSet()
 {
     if (rdbModTableSize.Checked)
     {
         return(HashSetFactory <Cloneable> .getHashSet(HashingStrategy.ModTableSize));
     }
     else
     {
         return(HashSetFactory <Cloneable> .getHashSet(HashingStrategy.MultiplyPrimeModPrimeModTable));
     }
 }
コード例 #6
0
        public void ToArrayTest03()
        {
            HashSet <int> hashSet;

            int[] ints = new int[0];
            hashSet = HashSetFactory.Create(ints);
            this.ToArrayTest(hashSet);
            PexAssert.IsNotNull((object)hashSet);
            PexAssert.AreEqual <int>(0, hashSet.Count);
            PexAssert.IsNotNull(hashSet.Comparer);
        }
コード例 #7
0
        public void AddTest08()
        {
            HashSet <int> hashSet;

            int[] ints = new int[4];
            hashSet = HashSetFactory.Create(ints);
            this.AddTest(hashSet);
            PexAssert.IsNotNull((object)hashSet);
            PexAssert.AreEqual <int>(1, hashSet.Count);
            PexAssert.IsNotNull(hashSet.Comparer);
        }
コード例 #8
0
        public void RemoveNodeWithBothSubtreesTest05()
        {
            HashSet <int> hashSet;

            int[] ints = new int[4];
            ints[0] = 8192;
            ints[1] = 4111;
            ints[2] = 8192;
            ints[3] = 8192;
            hashSet = HashSetFactory.Create(ints);
            this.RemoveNodeWithBothSubtreesTest(hashSet, 0);
        }
コード例 #9
0
        public void RemoveNodeWithBothSubtreesTest04()
        {
            HashSet <int> hashSet;

            int[] ints = new int[4];
            ints[0] = 40668;
            ints[1] = 2113937320;
            ints[2] = 40668;
            ints[3] = 40668;
            hashSet = HashSetFactory.Create(ints);
            this.RemoveNodeWithBothSubtreesTest(hashSet, 0);
        }
コード例 #10
0
        public void AddTest10()
        {
            HashSet <int> hashSet;

            int[] ints = new int[4];
            ints[0] = 229376;
            ints[1] = -2147254272;
            hashSet = HashSetFactory.Create(ints);
            this.AddTest(hashSet);
            PexAssert.IsNotNull((object)hashSet);
            PexAssert.AreEqual <int>(3, hashSet.Count);
            PexAssert.IsNotNull(hashSet.Comparer);
        }
コード例 #11
0
        public void AddTest09()
        {
            HashSet <int> hashSet;

            int[] ints = new int[4];
            ints[0] = 57845396;
            ints[1] = 956301312;
            hashSet = HashSetFactory.Create(ints);
            this.AddTest(hashSet);
            PexAssert.IsNotNull((object)hashSet);
            PexAssert.AreEqual <int>(3, hashSet.Count);
            PexAssert.IsNotNull(hashSet.Comparer);
        }
コード例 #12
0
        public void AddHashSetTest()
        {
            var hashSet = HashSetFactory.CreateNew(
                DirPath,
                Guid.NewGuid().ToString("P"),
                ServiceProvider.GetAllInstances <IHasher>().FirstOrDefault(p => p.GUID == HashGUID)
                );

            _hashSetManagementService.ClearHashSets();
            _hashSetManagementService.AddHashSet(hashSet);
            Assert.AreEqual(_hashSetManagementService.HashSets.Count(), 1);
            var hashSet2 = _hashSetManagementService.HashSets.First();

            Assert.AreEqual(hashSet2, hashSet);
        }
コード例 #13
0
        public void AddTest11()
        {
            HashSet <int> hashSet;

            int[] ints = new int[4];
            ints[0] = 704643072;
            ints[1] = -1442840576;
            ints[2] = int.MinValue;
            ints[3] = int.MinValue;
            hashSet = HashSetFactory.Create(ints);
            this.AddTest(hashSet);
            PexAssert.IsNotNull((object)hashSet);
            PexAssert.AreEqual <int>(3, hashSet.Count);
            PexAssert.IsNotNull(hashSet.Comparer);
        }
        public void Initialize()
        {
            TestCommon.InitializeTest();
            HashSetManagementService.Initialize();
            HashSetManagementService.Current.ClearHashSets();

            var hashSet = HashSetFactory.CreateNew(
                "E:\\anli\\lucene",
                Guid.NewGuid().ToString("P"),
                GenericServiceStaticInstances <IHasher> .Currents.First(
                    p => p.GUID == SingularityForensic.Hash.Constants.HashTypeGUID_MD5
                    )
                );

            hashSet.Name = testHashSetName;
            HashSetManagementService.AddHashSet(hashSet);


            _vm = new HashSetManagementDialogViewModel();
            _vm.Initialize();
        }
コード例 #15
0
        /// <summary>
        /// 初始化哈希集集合;
        /// </summary>
        private void InitializeHashSets()
        {
            _hashSets.Clear();
            if (!CheckDataFileExists())
            {
                LoggerService.WriteCallerLine($"Failed to check {GetDataFileName()} file");
                return;
            }

            XDocument xDoc = null;

            try {
                xDoc = XDocument.Load(GetDataFileName());
            }
            catch (Exception ex) {
                LoggerService.WriteException(ex);
                return;
            }

            if (xDoc.Root == null)
            {
                LoggerService.WriteCallerLine($"{nameof(xDoc.Root)} can't be null.");
                return;
            }

            var root  = xDoc.Root;
            var elems = root.Elements(Constants.XmlElemName_HashSets_Set);

            foreach (var elem in elems)
            {
                try {
                    //必要元素;
                    var storagePath  = elem.Attribute(Constants.XmlAttrName_HashSets_Set_StoragePath)?.Value;
                    var guid         = elem.Attribute(Constants.XmlAttrName_HashSets_Set_GUID)?.Value;
                    var hashTypeGuid = elem.Attribute(Constants.XmlAttrName_HashSets_Set_HashTypeGUID)?.Value;

                    //可选元素;
                    var name        = elem.Attribute(Constants.XmlAttrName_HashSets_Set_Name)?.Value;
                    var description = elem.GetXElemValue(Constants.XmlElemName_HashSets_Set_Description);
                    var isEnabled   = elem.Attribute(Constants.XmlAttrName_HashSets_Set_IsEnabled)?.Value == bool.TrueString;

                    var hasher = GenericServiceStaticInstances <IHasher> .Currents.FirstOrDefault(p => p.GUID == hashTypeGuid);

                    if (hasher == null)
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(guid))
                    {
                        continue;
                    }

                    if (name == null)
                    {
                        continue;
                    }

                    if (!Directory.Exists(storagePath))
                    {
                        continue;
                    }

                    var hashSet = HashSetFactory.LoadFromLocal(storagePath, guid, hasher);

                    hashSet.Name        = name;
                    hashSet.Description = description;
                    hashSet.IsEnabled   = isEnabled;

                    _hashSets.Add(hashSet);
                }
                catch (Exception ex) {
                    LoggerService.WriteException(ex);
                }
            }
        }