コード例 #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));
        }
コード例 #2
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);
     GrainReference grain = (GrainReference)this.GrainFactory.GetGrain <IGeneratorTestDerivedDerivedGrain>(GetRandomGrainId());
 }
コード例 #3
0
 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 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);
        }
コード例 #5
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");
        }