public void GetProxyType_IfAlreadyInCache_AlsoAddedToVisited_FromError() { // Arrange var targetType = typeof(IPerson); var sourceType = typeof(Person); var key = new Tuple <Type, Type>(sourceType, targetType); var cache = new ProxyTypeCache(); cache[key] = ProxyTypeCacheResult.FromError(key, "Test Error"); var context = new ProxyTypeEmitter.ProxyBuilderContext(cache, targetType, sourceType); // Act var result = ProxyTypeEmitter.VerifyProxySupport(context, key); // Assert Assert.False(result); Assert.Equal(key, context.Visited.Single().Key); }
public void GetProxyType_IfAlreadyInCache_AlsoAddedToVisited_FromType() { // Arrange var targetType = typeof(IPerson); var sourceType = typeof(Person); var key = new Tuple <Type, Type>(sourceType, targetType); var cache = new ProxyTypeCache(); cache[key] = ProxyTypeCacheResult.FromType(key, sourceType, sourceType.GetConstructor(Array.Empty <Type>())); var context = new ProxyTypeEmitter.ProxyBuilderContext(cache, targetType, sourceType); // Act var result = ProxyTypeEmitter.VerifyProxySupport(context, key); var result2 = ProxyTypeEmitter.VerifyProxySupport(context, key); // Assert Assert.True(result); Assert.True(result2); Assert.Single(context.Visited); Assert.Equal(key, context.Visited.Single().Key); }