|
11 | 11 | // limitations under the License.
|
12 | 12 | // ------------------------------------------------------------------------
|
13 | 13 |
|
| 14 | +using System; |
14 | 15 | using System.Linq;
|
15 | 16 | using System.Text.Json;
|
16 | 17 | using System.Threading.Tasks;
|
@@ -104,8 +105,33 @@ public void CanRegisterActorsToSpecificInterface()
|
104 | 105 |
|
105 | 106 | Assert.Collection(
|
106 | 107 | runtime.RegisteredActors.Select(r => r.Type.ActorTypeName).OrderBy(t => t),
|
107 |
| - t => Assert.Equal(ActorTypeInformation.Get(typeof(TestActor1), actorTypeName: null).ActorTypeName, t), |
108 |
| - t => Assert.Equal(ActorTypeInformation.Get(typeof(TestActor2), actorTypeName: null).ActorTypeName, t)); |
| 108 | + t => Assert.Equal(ActorTypeInformation.Get(typeof(IMyActor), typeof(InternalMyActor), actorTypeName: null).ActorTypeName, t)); |
| 109 | + |
| 110 | + Assert.Collection( |
| 111 | + runtime.RegisteredActors.Select(r => r.Type.InterfaceTypes.First()).OrderBy(t => t), |
| 112 | + t => Assert.Equal(ActorTypeInformation.Get(typeof(IMyActor), typeof(InternalMyActor), actorTypeName: null).InterfaceTypes.First(), t)); |
| 113 | + |
| 114 | + Assert.True(runtime.RegisteredActors.First().Type.InterfaceTypes.Count() == 1); |
| 115 | + } |
| 116 | + |
| 117 | + [Fact] |
| 118 | + public void RegisterActorThrowsArgumentExceptionWhenAnyInterfaceInTheChainIsNotIActor() |
| 119 | + { |
| 120 | + var services = new ServiceCollection(); |
| 121 | + services.AddLogging(); |
| 122 | + services.AddOptions(); |
| 123 | + services.AddActors(options => |
| 124 | + { |
| 125 | + Assert.Throws<ArgumentException>(() => options.Actors.RegisterActor<INonActor1, InternalMyActor>()); |
| 126 | + }); |
| 127 | + } |
| 128 | + |
| 129 | + private interface INonActor |
| 130 | + { |
| 131 | + } |
| 132 | + |
| 133 | + private interface INonActor1 : INonActor, IActor |
| 134 | + { |
109 | 135 | }
|
110 | 136 |
|
111 | 137 | private interface ITestActor : IActor
|
@@ -138,7 +164,7 @@ public interface IInternalMyActor : IMyActor
|
138 | 164 | void SomeInternalMethod();
|
139 | 165 | }
|
140 | 166 |
|
141 |
| - public class InternalMyActor : Actor, IInternalMyActor |
| 167 | + public class InternalMyActor : Actor, IInternalMyActor, INonActor1 |
142 | 168 | {
|
143 | 169 | public InternalMyActor(ActorHost host)
|
144 | 170 | : base(host)
|
|
0 commit comments