Esempio n. 1
0
 public void RWReferences()
 {
     writer = GrainClient.GrainFactory.GetGrain<IMultifacetWriter>(GetRandomGrainId());
     reader = writer.AsReference<IMultifacetReader>();
     
     int x = 1234;
     bool ok = writer.SetValue(x).Wait(timeout);
     if (!ok) throw new TimeoutException();
     int y = reader.GetValue().Result;
     Assert.Equal(x, y);
 }
Esempio n. 2
0
        public void RWReferences()
        {
            writer = GrainClient.GrainFactory.GetGrain <IMultifacetWriter>(GetRandomGrainId());
            reader = writer.AsReference <IMultifacetReader>();

            int  x  = 1234;
            bool ok = writer.SetValue(x).Wait(timeout);

            if (!ok)
            {
                throw new TimeoutException();
            }
            int y = reader.GetValue().Result;

            Assert.Equal(x, y);
        }
Esempio n. 3
0
        public void CastMultifacetRWReference()
        {
            // MultifacetTestGrain implements IMultifacetReader
            // MultifacetTestGrain implements IMultifacetWriter
            int newValue = 3;

            IMultifacetWriter writer = GrainClient.GrainFactory.GetGrain <IMultifacetWriter>(1);
            // No Wait in this test case

            IMultifacetReader reader = writer.AsReference <IMultifacetReader>();  // --> Test case intermittently fails here

            // Error: System.InvalidCastException: Grain reference MultifacetGrain.MultifacetWriterFactory+MultifacetWriterReference service interface mismatch: expected interface id=[1947430462] received interface name=[MultifacetGrain.IMultifacetWriter] id=[62435819] in grainRef=[GrainReference:*std/b198f19f]

            writer.SetValue(newValue).Wait();

            Task <int> readAsync = reader.GetValue();

            readAsync.Wait();
            int result = readAsync.Result;

            Assert.Equal(newValue, result);
        }
Esempio n. 4
0
        public void CastMultifacetRWReferenceWaitForResolve()
        {
            // MultifacetTestGrain implements IMultifacetReader
            // MultifacetTestGrain implements IMultifacetWriter

            //Interface Id values for debug:
            // IMultifacetWriter = 62435819
            // IMultifacetReader = 1947430462
            // IMultifacetTestGrain = 222717230 (also compatable with 1947430462 or 62435819)

            int newValue = 4;

            IMultifacetWriter writer = GrainClient.GrainFactory.GetGrain <IMultifacetWriter>(2);

            IMultifacetReader reader = writer.AsReference <IMultifacetReader>(); // --> Test case fails here

            // Error: System.InvalidCastException: Grain reference MultifacetGrain.MultifacetWriterFactory+MultifacetWriterReference service interface mismatch: expected interface id=[1947430462] received interface name=[MultifacetGrain.IMultifacetWriter] id=[62435819] in grainRef=[GrainReference:*std/8408c2bc]

            writer.SetValue(newValue).Wait();

            int result = reader.GetValue().Result;

            Assert.Equal(newValue, result);
        }