private void ShouldIterateOverTypeMetaProviders( Mock <IEnumerable <ITypeMetaProvider> > typeMetaProviders, FieldGenerationContext context ) { var sut = new TypeMetadataProvider(typeMetaProviders.Object); var meta = sut.GetMetadata(context).ToArray(); typeMetaProviders.Verify(e => e.GetEnumerator(), Times.Once); }
private void ShouldCallGetMetadataForEachProvider( List <Mock <ITypeMetaProvider> > typeMetaProviderMocks, FieldGenerationContext context ) { var typeMetaProviders = typeMetaProviderMocks.Select(m => m.Object).ToArray(); var sut = new TypeMetadataProvider(typeMetaProviders); var meta = sut.GetMetadata(context).ToArray(); foreach (var typeMetaProviderMock in typeMetaProviderMocks) { typeMetaProviderMock.Verify(m => m.GetMetadata(context), Times.Once); } }
private void ShouldForwardGetMetadataForEachProviderAsReturn( List <IEnumerable <KeyValuePair <string, object> > > expectedKeyValuePairs, List <Mock <ITypeMetaProvider> > typeMetaProviderMocks, FieldGenerationContext context ) { var typeMetaProviders = typeMetaProviderMocks.Select(m => m.Object).ToArray(); for (var index = 0; index < typeMetaProviderMocks.Count; index++) { var typeMetaProviderMock = typeMetaProviderMocks[index]; typeMetaProviderMock .Setup(m => m.GetMetadata(context)) .Returns(expectedKeyValuePairs[index]); } var sut = new TypeMetadataProvider(typeMetaProviders); var meta = sut.GetMetadata(context).ToArray(); Assert.Equal(meta, expectedKeyValuePairs.SelectMany(kvp => kvp)); }
private void ShouldThrowArgumentNullExceptionWhenContextIsNull( TypeMetadataProvider sut ) { Assert.Throws <ArgumentNullException>(() => sut.GetMetadata(null).ToArray()); }