コード例 #1
0
        public void GivenEmptyPeopleList_ShouldReturn_EmptyList()
        {
            var algorithm  = new KCombinedAnonimization(3, _jobDictionary, _cityDictionary, p => p.FirstName, p => p.Surname, p => p.Age);
            var anonymized = algorithm.GetAnonymizedData(new List <Person>());

            Assert.IsTrue(!anonymized.Any());
        }
コード例 #2
0
        public void GivenKParameterOne_ShouldReturnTheSameList()
        {
            var pid       = new Expression <Func <Person, object> >[] { p => p.FirstName, p => p.Surname, p => p.Age };
            var algorithm = new KCombinedAnonimization(1, _jobDictionary, _cityDictionary, pid);
            var anonymzed = algorithm.GetAnonymizedData(_people);

            Assert.IsTrue(_people.All(p => anonymzed.Exists(x => x.FirstName == p.FirstName && x.Surname == p.Surname && x.Age == p.Age)));
        }
コード例 #3
0
        public void GivenKParameter_GreaterThan_1_AndFullPID_ShouldReturnAnonymizedList(int parameterK)
        {
            var pid       = new Expression <Func <Person, object> >[] { p => p.FirstName, p => p.Surname, p => p.Age, p => p.Job, p => p.City, p => p.Gender };
            var algorithm = new KCombinedAnonimization(parameterK, _jobDictionary, _cityDictionary, pid);

            var anonymzed = algorithm.GetAnonymizedData(_people);

            Assert.AreEqual(_people.Count, anonymzed.Count);
            //All Groups have at least K people
            Assert.IsTrue(anonymzed.GroupBy(x => new { x.FirstName, x.Surname, x.Age, x.Job, x.City, x.Gender })
                          .Select(g => g.Count())
                          .All(c => c >= parameterK));
        }