コード例 #1
0
        public void GivenKParameterOne_ShouldReturnTheSameList()
        {
            var ageAnonimizator = new KNumberAnonimization <string>(1, p => p.Age);
            var anonymzed       = ageAnonimizator.GetAnonymizedData(_people);

            Assert.IsTrue(anonymzed.All(p => p.Age == _people.First(x => x.FirstName == p.FirstName && x.Surname == p.Surname).Age));
        }
コード例 #2
0
        public void GivenEmptyPeopleList_ShouldReturn_EmptyList()
        {
            var ageAnonimizator = new KNumberAnonimization <string>(2, p => p.Age);
            var anonymzed       = ageAnonimizator.GetAnonymizedData(new List <Person>());

            Assert.IsTrue(!anonymzed.Any());
        }
コード例 #3
0
 public void GivenInvalidData_ShouldThrowException()
 {
     var invalidData = _people.Union(new List <Person> {
         new Person("K", "Malarz", "Olawa", "Julia", "Wojcik", "invalid")
     });
     var ageAnonimizator = new KNumberAnonimization <string>(1, p => p.Age);
     var anonymzed       = ageAnonimizator.GetAnonymizedData(invalidData);
 }
コード例 #4
0
        public void GivenKParameter_GreaterThan_1_ShouldReturnAnonymyzedList(int parameterK)
        {
            var ageAnonimizator = new KNumberAnonimization <string>(parameterK, p => p.Age);
            var anonymzed       = ageAnonimizator.GetAnonymizedData(_people);

            Assert.AreEqual(_people.Count, anonymzed.Count);
            //All Groups have at least K people
            Assert.IsTrue(anonymzed.GroupBy(x => x.Age).Select(g => g.Count()).All(c => c >= parameterK));
            //No overlapping groups
            Assert.IsTrue(!AreIntervalsOverlapping(anonymzed));
        }