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 ExtractMembersValues_ExtractDataFromObject_ShouldBeEquivilent() { const int numberOfPrivatePropertiesAndFields = 8; var mock = new PersonMockData(); var reflectionMetadataInfos = _extractor.ExtractMemberMetadata(mock.GetType()).ToDictionary(x => x.Name); reflectionMetadataInfos[nameof(PersonMockData.FieldNonSensitive)].ValueExtractor(mock).ShouldBe(mock.FieldNonSensitive); reflectionMetadataInfos[nameof(PersonMockData.FieldSensitive)].ValueExtractor(mock).ShouldBe(mock.FieldSensitive); reflectionMetadataInfos[nameof(PersonMockData.FieldCryptic)].ValueExtractor(mock).ShouldBe(mock.FieldCryptic); reflectionMetadataInfos[nameof(PersonMockData.ID)].ValueExtractor(mock).ShouldBe(mock.ID); reflectionMetadataInfos[nameof(PersonMockData.Name)].ValueExtractor(mock).ShouldBe(mock.Name); reflectionMetadataInfos[nameof(PersonMockData.IsMale)].ValueExtractor(mock).ShouldBe(mock.IsMale); reflectionMetadataInfos[nameof(PersonMockData.Sensitive)].ValueExtractor(mock).ShouldBe(mock.Sensitive); reflectionMetadataInfos[nameof(PersonMockData.Cryptic)].ValueExtractor(mock).ShouldBe(mock.Cryptic); reflectionMetadataInfos.Count.ShouldBe(numberOfPrivatePropertiesAndFields); }
public void ExtractPropertiesAndFieldsValues_ExtractDataFromObject_ShouldBeEquivilent() { const int numberOfPrivatePropertiesAndFields = 8; var mock = new PersonMockData(); var reflectionMetadataInfos = _extractor.ExtractMemberMetadata(mock.GetType()).ToDictionary(x => x.Name); var dissectParams = DissectPropertyInfoMetadata.GetMembers(mock); var numberProperties = dissectParams.Count(); int count = 0; foreach (var member in dissectParams) { var result = reflectionMetadataInfos[member.Name].ValueExtractor(mock); member.Value.ShouldBe(result, $"Propery name {member.Name} doesn't exists."); count++; } count.ShouldBe(numberProperties); count.ShouldBe(numberOfPrivatePropertiesAndFields); reflectionMetadataInfos.Count.ShouldBe(numberProperties); }
public void ExtracPropertiesValues_ExtractDataFromObject_ShouldBeEquivilent() { var mock = new PersonMockData(); var reflectionMetadataInfos = PropertiesMetadataPropertiesCache.ExtracPropertiesMetadata(mock, mock.GetType()).ToList(); reflectionMetadataInfos.Count.ShouldBe(_numOfProperties); foreach (var reflectionMetadata in reflectionMetadataInfos) { var propertyInfo = typeof(PersonMockData).GetProperty(reflectionMetadata.PropertyName); var result = reflectionMetadata.ValueExtractor(mock); if (propertyInfo.GetValue(mock).Equals(result) == false) { throw new InvalidDataException($"Propery name {propertyInfo.Name} doesn't exists."); } } }