public void MATI_GivenKParameter_GreaterThan_1_ShouldReturnAnonymyzedList(int parameterK)
        {
            var ageAnonimizator = new KAgeAnonimization(parameterK);
            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));
        }
Beispiel #2
0
        public void GivenKParameterOne_ShouldReturnTheSameList()
        {
            //Arrange
            var algorithm = new KAgeAnonimization(1);

            //Act
            var anonymzed = algorithm.GetAnonymizedData(new List <Person>());

            //Assert
            Assert.IsTrue(anonymzed.All(p => p.Age == _people.First(x => x.FirstName == p.FirstName && x.Surname == p.Surname).Age));
        }
Beispiel #3
0
        public void GivenEmptyPeopleList_ShouldReturn_EmptyList()
        {
            //Arrange
            var algorithm = new KAgeAnonimization(2);

            //Act
            var anonymzed = algorithm.GetAnonymizedData(new List <Person>());

            //Assert
            Assert.IsTrue(!anonymzed.Any());
        }
Beispiel #4
0
        public void GivenKParameter_GreaterThan_1_ShouldReturnAnonymyzedList(int parameterK)
        {
            //Arrange
            var algorithm = new KAgeAnonimization(parameterK);
            //Act
            var anonymzed = algorithm.GetAnonymizedData(_people);

            //Assert

            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));
        }