예제 #1
0
        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);
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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));
        }
예제 #4
0
 private void ShouldThrowArgumentNullExceptionWhenContextIsNull(
     TypeMetadataProvider sut
     )
 {
     Assert.Throws <ArgumentNullException>(() => sut.GetMetadata(null).ToArray());
 }