public void ExtracPropertiesValues_SendTwoPeople_ShouldBeEquivilent() { var cache = new PropertiesMetadataPropertiesCache(_logMocked); var person = new PersonMockData(); var teacher = new TeacherWithExceptionMock(); var teacherArguments = cache.ParseIntoParams(teacher); var personArguments = cache.ParseIntoParams(person); var personDissect = DissectPropertyInfoMetadata.GetMemberWithSensitivity(person).ToDictionary(x => x.Name); var count = AssertBetweenCacheParamAndDissectParams(personArguments, personDissect); _logMocked.DidNotReceive().Warn(Arg.Any <string>(), Arg.Any <object>(), Arg.Any <object>(), Arg.Any <Exception>(), Arg.Any <bool>(), Arg.Any <string>(), Arg.Any <int>(), Arg.Any <string>()); count.ShouldBe(personDissect.Count); var teacherDissect = DissectPropertyInfoMetadata.GetMemberWithSensitivity(teacher).ToDictionary(x => x.Name); count = AssertBetweenCacheParamAndDissectParams(teacherArguments, teacherDissect); count.ShouldBe(teacherDissect.Count - 1); _logMocked.Received().Warn(Arg.Any <string>(), Arg.Any <object>(), Arg.Any <object>(), Arg.Any <Exception>(), Arg.Any <bool>(), Arg.Any <string>(), Arg.Any <int>(), Arg.Any <string>()); }
public void ExtracPropertiesValues_SendTwoPeople_ShouldBeEquivilent() { var cache = new PropertiesMetadataPropertiesCache(_logMocked); var person = new PersonMockData(); var teacher = new TeacherWithExceptionMock(); var teacherArguments = cache.ParseIntoParams(teacher); var personArguments = cache.ParseIntoParams(person); personArguments.Count().ShouldBe(person.GetType().GetProperties().Length); ArgumentVerivications(person, personArguments); _logMocked.DidNotReceive().Warn(Arg.Any <string>(), Arg.Any <object>(), Arg.Any <object>(), Arg.Any <Exception>(), Arg.Any <bool>(), Arg.Any <string>(), Arg.Any <int>(), Arg.Any <string>()); teacherArguments.Count().ShouldBe(teacher.GetType().GetProperties().Length - 1); ArgumentVerivications(teacher, teacherArguments); _logMocked.Received().Warn(Arg.Any <string>(), Arg.Any <object>(), Arg.Any <object>(), Arg.Any <Exception>(), Arg.Any <bool>(), Arg.Any <string>(), Arg.Any <int>(), Arg.Any <string>()); }
public void ExtracPropertiesValues_ExtractSensitiveAndCrypticWithInheritenceAndException_ShouldBeEquivilent() { var cache = new PropertiesMetadataPropertiesCache(_logMocked); var mock = new TeacherWithExceptionMock(); var arguments = cache.ParseIntoParams(mock); arguments.Count().ShouldBe(mock.GetType().GetProperties().Length - 1); ArgumentVerivications(mock, arguments); _logMocked.Received().Warn(Arg.Any <string>(), Arg.Any <object>(), Arg.Any <object>(), Arg.Any <Exception>(), Arg.Any <bool>(), Arg.Any <string>(), Arg.Any <int>(), Arg.Any <string>()); }
public void ExtracPropertiesValues_ExtractSensitiveAndCryptic_ShouldBeEquivilent() { var mock = new PersonMockData(); var cache = new PropertiesMetadataPropertiesCache(_logMocked); var metadataCacheParams = cache.ParseIntoParams(mock); var dissectedParams = DissectPropertyInfoMetadata.GetMemberWithSensitivity(mock).ToDictionary(x => x.Name); int count = AssertBetweenCacheParamAndDissectParams(metadataCacheParams, dissectedParams); metadataCacheParams.Count().ShouldBe(dissectedParams.Count); count.ShouldBe(dissectedParams.Count); }
public void LoadTest() { var cache = new PropertiesMetadataPropertiesCache(_logMocked); var people = GeneratePeople(10000).ToList(); var stopWatch = new Stopwatch(); stopWatch.Start(); foreach (var person in people) { var tmpParams = cache.ParseIntoParams(person); tmpParams.Count().ShouldBe(_numOfProperties); } stopWatch.Stop(); }
public void LoadTest() { var cache = new PropertiesMetadataPropertiesCache(_logMocked); var people = GeneratePeople(10000).ToList(); var numOfProperties = DissectPropertyInfoMetadata.GetMemberWithSensitivity(new PersonMockData()); var stopWatch = new Stopwatch(); stopWatch.Start(); foreach (var person in people) { var tmpParams = cache.ParseIntoParams(person); tmpParams.Count().ShouldBe(numOfProperties.Count()); } stopWatch.Stop(); }
public void PropertyMetadata_Extract_All_Public_Properties() { var cache = new PropertiesMetadataPropertiesCache(_logMocked); var mock = new PersonMockData(); var arguments = cache.ParseIntoParams(mock).ToList(); arguments.Count.ShouldBe(_numOfProperties); foreach (var param in arguments) { var propertyInfo = typeof(PersonMockData).GetProperty(param.Name); if (propertyInfo.GetValue(mock).ToString().Equals(param.Value.ToString()) == false) { throw new InvalidDataException($"Propery name {propertyInfo.Name} doesn't exists."); } } }
public void ExtracPropertiesValues_ExtractSensitiveAndCrypticWithInheritenceAndException_ShouldBeEquivilent() { var mock = new TeacherWithExceptionMock(); var cache = new PropertiesMetadataPropertiesCache(_logMocked); var dissectedParams = DissectPropertyInfoMetadata.GetMemberWithSensitivity(mock).ToDictionary(x => x.Name); var parseParams = cache.ParseIntoParams(mock); int count = AssertBetweenCacheParamAndDissectParams(parseParams, dissectedParams); parseParams.Count().ShouldBe(dissectedParams.Count - 1); count.ShouldBe(dissectedParams.Count - 1); _logMocked.Received().Warn(Arg.Any <string>(), Arg.Any <object>(), Arg.Any <object>(), Arg.Any <Exception>(), Arg.Any <bool>(), Arg.Any <string>(), Arg.Any <int>(), Arg.Any <string>()); }
public void ExtracPropertiesValues_ExtractSensitiveAndCryptic_ShouldBeEquivilent() { const string crypticPropertyName = nameof(PersonMockData.Cryptic); const string sensitivePropertyName = nameof(PersonMockData.Sensitive); var cache = new PropertiesMetadataPropertiesCache(_logMocked); var mock = new PersonMockData(); var arguments = cache.ParseIntoParams(mock); foreach (var arg in arguments.Where(x => x.Sensitivity != null)) { if (arg.Name == crypticPropertyName) { arg.Sensitivity.ShouldBe(Sensitivity.Secretive); typeof(PersonMockData).GetProperty(crypticPropertyName).GetValue(mock).ShouldBe(mock.Cryptic); } if (arg.Name == sensitivePropertyName) { arg.Sensitivity.ShouldBe(Sensitivity.Sensitive); typeof(PersonMockData).GetProperty(sensitivePropertyName).GetValue(mock).ShouldBe(mock.Sensitive); } } }