public void ShouldIncludeNamespacesForMethodParameters()
        {
            var generator = ProxyGenerator.ForTest(false, World.DefaultLogger);
            var result    = generator.GenerateFor(typeof(IProxyGenTestInterface));

            Assert.Contains("using System.Net;", result.Source);
        }
Exemple #2
0
        public void ShouldCreateAProxyWithReferenceToInnerInterface()
        {
            var generator = ProxyGenerator.ForTest(false, World.DefaultLogger);
            var result    = generator.GenerateFor(typeof(IOuterInnerClassInterface));

            Assert.Contains("public class OuterInnerClassInterface__Proxy : Vlingo.Actors.Tests.IOuterInnerClassInterface", result.Source);
            Assert.Contains("public void DoSomethingWith(Vlingo.Actors.Tests.OuterClass.InnerClass obj)", result.Source);
        }
Exemple #3
0
        public void ShouldCreateAProxyWithInnerInterface()
        {
            var generator = ProxyGenerator.ForTest(false, World.DefaultLogger);
            var result    = generator.GenerateFor(typeof(ClassWithNestedInterface.INestedInterface));

            Assert.Contains("private const string DoSomethingRepresentation1 = \"DoSomething()\";", result.Source);
            Assert.Contains("public class NestedInterface__Proxy : Vlingo.Actors.Tests.ClassWithNestedInterface.INestedInterface", result.Source);
            Assert.Contains($"Action<Vlingo.Actors.Tests.ClassWithNestedInterface.INestedInterface> {_consumerName} = __ => __.DoSomething();", result.Source);
        }
Exemple #4
0
        public void ShouldIncludeMultipleGenericConstraintForMethod()
        {
            var generator = ProxyGenerator.ForTest(false, World.DefaultLogger);
            var result    = generator.GenerateFor(typeof(IProxyGenericMethodWithMultipleConstraint));

            Assert.Contains("private const string WriteRepresentation1 = \"Write<TSource>(string, int)\";", result.Source);
            Assert.Contains("public void Write<TSource>(string id, int state) where TSource : Vlingo.Actors.Tests.IProxyGenTestInterface, Vlingo.Actors.Tests.IProxyGenTestSecondInterface", result.Source);
            Assert.Contains($"Action<Vlingo.Actors.Tests.IProxyGenericMethodWithMultipleConstraint> {_consumerName} = __ => __.Write<TSource>(id, state);", result.Source);
        }
Exemple #5
0
        public void ShouldCorrectlyGenerateParameterNameWithReservedKeywordsAddtional()
        {
            var generator = ProxyGenerator.ForTest(false, World.DefaultLogger);
            var result    = generator.GenerateFor(typeof(IProxyGenTestReservedKeyword));

            Assert.Contains("private const string DoSomethingRepresentation1 = \"DoSomething(object, bool)\";", result.Source);
            Assert.Contains("public void DoSomething(object @object, bool @event)", result.Source);
            Assert.Contains($"Action<Vlingo.Actors.Tests.IProxyGenTestReservedKeyword> {_consumerName} = __ => __.DoSomething(@object, @event);", result.Source);
        }
Exemple #6
0
        public void ShouldIncludeNamespacesForMethodParameters()
        {
            var generator = ProxyGenerator.ForTest(false, World.DefaultLogger);
            var result    = generator.GenerateFor(typeof(IProxyGenTestInterface));

            Assert.Contains("private const string DoSomethingRepresentation1 = \"DoSomething(System.Threading.Tasks.Task)\";", result.Source);
            Assert.Contains("System.Threading.Tasks.Task t", result.Source);
            Assert.Contains($"Action<Vlingo.Actors.Tests.IProxyGenTestInterface> {_consumerName} = __ => __.DoSomething(t);", result.Source);
        }
Exemple #7
0
        public void ShouldNotIncludeGenericConstraintForMethod()
        {
            var generator = ProxyGenerator.ForTest(false, World.DefaultLogger);
            var result    = generator.GenerateFor(typeof(IProxyGenericMethodWithoutConstraint));

            Assert.Contains("private const string WriteRepresentation1 = \"Write<TSource>(string, int)\";", result.Source);
            Assert.Contains("public void Write<TSource>(string id, int state)", result.Source);
            Assert.Contains("Action<Vlingo.Actors.Tests.IProxyGenericMethodWithoutConstraint> cons128873 = __ => __.Write<TSource>(id, state);", result.Source);
        }
Exemple #8
0
 private static object TryGenerateCreate(Type protocol, Actor actor, IMailbox mailbox, string targetClassName, string lookupTypeName)
 {
     try
     {
         var generator = ProxyGenerator.ForMain(true, actor.Logger);
         return(TryGenerateCreate(protocol, actor, mailbox, generator, targetClassName, lookupTypeName));
     }
     catch (Exception e)
     {
         actor.Logger.Error($"Trying generate proxy but it failed because of '{e.Message}' but still trying", e);
         try
         {
             var generator = ProxyGenerator.ForTest(true, actor.Logger);
             return(TryGenerateCreate(protocol, actor, mailbox, generator, targetClassName, lookupTypeName));
         }
         catch (Exception etest)
         {
             throw new ArgumentException($"Actor proxy {protocol.Name} not created for main or test: {etest.Message}", etest);
         }
     }
 }