예제 #1
0
        public void CastCheckExpectedCompatIds()
        {
            Type           t = typeof(ISimpleGrain);
            int            expectedInterfaceId = GrainInterfaceUtils.GetGrainInterfaceId(t);
            GrainReference grain = (GrainReference)GrainClient.GrainFactory.GetGrain <ISimpleGrain>(random.Next(), SimpleGrain.SimpleGrainNamePrefix);

            Assert.True(grain.IsCompatible(expectedInterfaceId));
        }
 public void CastCheckExpectedCompatIds2()
 {
     // GeneratorTestDerivedDerivedGrainReference extends GeneratorTestDerivedGrain2Reference
     // GeneratorTestDerivedGrain2Reference extends GeneratorTestGrainReference
     Type           t1    = typeof(IGeneratorTestDerivedDerivedGrain);
     Type           t2    = typeof(IGeneratorTestDerivedGrain2);
     Type           t3    = typeof(IGeneratorTestGrain);
     int            id1   = GrainInterfaceUtils.GetGrainInterfaceId(t1);
     int            id2   = GrainInterfaceUtils.GetGrainInterfaceId(t2);
     int            id3   = GrainInterfaceUtils.GetGrainInterfaceId(t3);
     GrainReference grain = (GrainReference)this.GrainFactory.GetGrain <IGeneratorTestDerivedDerivedGrain>(GetRandomGrainId());
 }
 public void CastFailInternalCastFromBadType()
 {
     Xunit.Assert.Throws <InvalidCastException>(() => {
         Type t = typeof(ISimpleGrain);
         GrainReference grain = (GrainReference)GrainClient.GrainFactory.GetGrain <ISimpleGrain>(random.Next(), SimpleGrain.SimpleGrainNamePrefix);
         IAddressable cast    = GrainReference.CastInternal(
             typeof(Boolean),
             null,
             grain,
             GrainInterfaceUtils.GetGrainInterfaceId(t));
         Assert.Fail("Exception should have been raised");
     });
 }
예제 #4
0
        public void ConfirmServiceInterfacesListContents()
        {
            // GeneratorTestDerivedDerivedGrainReference extends GeneratorTestDerivedGrain2Reference
            // GeneratorTestDerivedGrain2Reference extends GeneratorTestGrainReference
            Type t1 = typeof(IGeneratorTestDerivedDerivedGrain);
            Type t2 = typeof(IGeneratorTestDerivedGrain2);
            Type t3 = typeof(IGeneratorTestGrain);

            var interfaces = GrainInterfaceUtils.GetRemoteInterfaces(typeof(IGeneratorTestDerivedDerivedGrain));

            Assert.NotNull(interfaces);
            Assert.Equal(3, interfaces.Count);
            Assert.Contains(t1, interfaces);
            Assert.Contains(t2, interfaces);
            Assert.Contains(t3, interfaces);
        }
예제 #5
0
        public void CastCheckExpectedCompatIds2()
        {
            // GeneratorTestDerivedDerivedGrainReference extends GeneratorTestDerivedGrain2Reference
            // GeneratorTestDerivedGrain2Reference extends GeneratorTestGrainReference
            Type t1  = typeof(IGeneratorTestDerivedDerivedGrain);
            Type t2  = typeof(IGeneratorTestDerivedGrain2);
            Type t3  = typeof(IGeneratorTestGrain);
            int  id1 = GrainInterfaceUtils.GetGrainInterfaceId(t1);
            int  id2 = GrainInterfaceUtils.GetGrainInterfaceId(t2);
            int  id3 = GrainInterfaceUtils.GetGrainInterfaceId(t3);

            Assert.Equal(-692645356, id1);
            Assert.Equal(-342583538, id2);
            Assert.Equal(-712890543, id3);
            GrainReference grain = (GrainReference)this.GrainFactory.GetGrain <IGeneratorTestDerivedDerivedGrain>(GetRandomGrainId());

            Assert.NotNull(grain);
        }
예제 #6
0
        public void ConfirmServiceInterfacesListContents()
        {
            // GeneratorTestDerivedDerivedGrainReference extends GeneratorTestDerivedGrain2Reference
            // GeneratorTestDerivedGrain2Reference extends GeneratorTestGrainReference
            Type t1  = typeof(IGeneratorTestDerivedDerivedGrain);
            Type t2  = typeof(IGeneratorTestDerivedGrain2);
            Type t3  = typeof(IGeneratorTestGrain);
            int  id1 = GrainInterfaceUtils.GetGrainInterfaceId(t1);
            int  id2 = GrainInterfaceUtils.GetGrainInterfaceId(t2);
            int  id3 = GrainInterfaceUtils.GetGrainInterfaceId(t3);

            var interfaces = GrainInterfaceUtils.GetRemoteInterfaces(typeof(IGeneratorTestDerivedDerivedGrain));

            Assert.NotNull(interfaces);
            Assert.Equal(3, interfaces.Keys.Count);
            Assert.True(interfaces.Keys.Contains(id1), "id1 is present");
            Assert.True(interfaces.Keys.Contains(id2), "id2 is present");
            Assert.True(interfaces.Keys.Contains(id3), "id3 is present");
        }
예제 #7
0
 public void InterfaceRules_ObserverGrain_PropertySetter()
 {
     Xunit.Assert.Throws <GrainInterfaceUtils.RulesViolationException>(() =>
                                                                       GrainInterfaceUtils.ValidateInterface(typeof(IInheritedGrain_ObserverGrain_PropertySetter)));
 }
예제 #8
0
 public void InterfaceRules_RefArgument()
 {
     Xunit.Assert.Throws <GrainInterfaceUtils.RulesViolationException>(() =>
                                                                       GrainInterfaceUtils.ValidateInterface(typeof(ITestGrain_RefArgument)));
 }
예제 #9
0
 public void InterfaceRules_Observer_Property()
 {
     Xunit.Assert.Throws <GrainInterfaceUtils.RulesViolationException>(() =>
                                                                       GrainInterfaceUtils.ValidateInterface(typeof(ITestObserver_Property)));
 }
예제 #10
0
 public void InterfaceRules_IntMethod()
 {
     Xunit.Assert.Throws <GrainInterfaceUtils.RulesViolationException>(() =>
                                                                       GrainInterfaceUtils.ValidateInterface(typeof(ITestGrain_IntMethod)));
 }
예제 #11
0
 public void InterfaceRules_ObserverGrain_IntMethod()
 {
     Assert.Throws <GrainInterfaceUtils.RulesViolationException>(() =>
                                                                 GrainInterfaceUtils.ValidateInterface(typeof(IInheritedGrain_ObserverGrain_IntMethod)));
 }
예제 #12
0
 public void InterfaceRules_Observer_NonVoidMethod()
 {
     Assert.Throws <GrainInterfaceUtils.RulesViolationException>(() =>
                                                                 GrainInterfaceUtils.ValidateInterface(typeof(ITestObserver_NonVoidMethod)));
 }
예제 #13
0
 public void InterfaceRules_PropertySetter()
 {
     Assert.Throws <GrainInterfaceUtils.RulesViolationException>(() =>
                                                                 GrainInterfaceUtils.ValidateInterface(typeof(ITestGrain_PropertySetter)));
 }
예제 #14
0
 public void InterfaceRules_ValueTask()
 {
     GrainInterfaceUtils.ValidateInterface(typeof(ITestGrain_ValueTask));
 }