Esempio n. 1
0
        protected async Task Grain_Generic_AzureStore_Read_Write()
        {
            long id = random.Next();

            IAzureStorageGenericGrain <int> grain = this.GrainFactory.GetGrain <IAzureStorageGenericGrain <int> >(id);

            int val = await grain.GetValue();

            Assert.Equal(0, val);   // "Initial value"

            await grain.DoWrite(1);

            val = await grain.GetValue();

            Assert.Equal(1, val);   // "Value after Write-1"

            await grain.DoWrite(2);

            val = await grain.GetValue();

            Assert.Equal(2, val);   // "Value after Write-2"

            val = await grain.DoRead();

            Assert.Equal(2, val);   // "Value after Re-Read"
        }
        public async Task Grain_Generic_AzureStore_Read_Write()
        {
            long id = random.Next();

            IAzureStorageGenericGrain <int> grain = GrainClient.GrainFactory.GetGrain <IAzureStorageGenericGrain <int> >(id);

            int val = await grain.GetValue();

            Assert.AreEqual(0, val, "Initial value");

            await grain.DoWrite(1);

            val = await grain.GetValue();

            Assert.AreEqual(1, val, "Value after Write-1");

            await grain.DoWrite(2);

            val = await grain.GetValue();

            Assert.AreEqual(2, val, "Value after Write-2");

            val = await grain.DoRead();

            Assert.AreEqual(2, val, "Value after Re-Read");
        }
Esempio n. 3
0
        protected async Task Grain_Generic_AzureStore_DiffTypes()
        {
            long id1 = random.Next();
            long id2 = id1;
            long id3 = id1;

            IAzureStorageGenericGrain <int> grain1 = this.GrainFactory.GetGrain <IAzureStorageGenericGrain <int> >(id1);

            IAzureStorageGenericGrain <string> grain2 = this.GrainFactory.GetGrain <IAzureStorageGenericGrain <string> >(id2);

            IAzureStorageGenericGrain <double> grain3 = this.GrainFactory.GetGrain <IAzureStorageGenericGrain <double> >(id3);

            int val1 = await grain1.GetValue();

            Assert.Equal(0, val1);   // "Initial value - 1"

            string val2 = await grain2.GetValue();

            Assert.Null(val2);  // "Initial value - 2"

            double val3 = await grain3.GetValue();

            Assert.Equal(0.0, val3);   // "Initial value - 3"

            int expected1 = 1;
            await grain1.DoWrite(expected1);

            val1 = await grain1.GetValue();

            Assert.Equal(expected1, val1);   // "Value after Write#1 - 1"

            string expected2 = "Three";
            await grain2.DoWrite(expected2);

            val2 = await grain2.GetValue();

            Assert.Equal(expected2, val2);   // "Value after Write#1 - 2"

            double expected3 = 5.1;
            await grain3.DoWrite(expected3);

            val3 = await grain3.GetValue();

            Assert.Equal(expected3, val3);   // "Value after Write#1 - 3"

            val1 = await grain1.GetValue();

            Assert.Equal(expected1, val1);   // "Value before Write#2 - 1"
            expected1 = 2;
            await grain1.DoWrite(expected1);

            val1 = await grain1.GetValue();

            Assert.Equal(expected1, val1);   // "Value after Write#2 - 1"
            val1 = await grain1.DoRead();

            Assert.Equal(expected1, val1);   // "Value after Re-Read - 1"

            val2 = await grain2.GetValue();

            Assert.Equal(expected2, val2);   // "Value before Write#2 - 2"
            expected2 = "Four";
            await grain2.DoWrite(expected2);

            val2 = await grain2.GetValue();

            Assert.Equal(expected2, val2);   // "Value after Write#2 - 2"
            val2 = await grain2.DoRead();

            Assert.Equal(expected2, val2);   // "Value after Re-Read - 2"

            val3 = await grain3.GetValue();

            Assert.Equal(expected3, val3);   // "Value before Write#2 - 3"
            expected3 = 6.2;
            await grain3.DoWrite(expected3);

            val3 = await grain3.GetValue();

            Assert.Equal(expected3, val3);   // "Value after Write#2 - 3"
            val3 = await grain3.DoRead();

            Assert.Equal(expected3, val3);   // "Value after Re-Read - 3"
        }
        public async Task Grain_Generic_AzureStore_DiffTypes()
        {
            long id1 = random.Next();
            long id2 = id1;
            long id3 = id1;

            IAzureStorageGenericGrain <int> grain1 = GrainClient.GrainFactory.GetGrain <IAzureStorageGenericGrain <int> >(id1);

            IAzureStorageGenericGrain <string> grain2 = GrainClient.GrainFactory.GetGrain <IAzureStorageGenericGrain <string> >(id2);

            IAzureStorageGenericGrain <double> grain3 = GrainClient.GrainFactory.GetGrain <IAzureStorageGenericGrain <double> >(id3);

            int val1 = await grain1.GetValue();

            Assert.AreEqual(0, val1, "Initial value - 1");

            string val2 = await grain2.GetValue();

            Assert.AreEqual(null, val2, "Initial value - 2");

            double val3 = await grain3.GetValue();

            Assert.AreEqual(0.0, val3, "Initial value - 3");

            int expected1 = 1;
            await grain1.DoWrite(expected1);

            val1 = await grain1.GetValue();

            Assert.AreEqual(expected1, val1, "Value after Write#1 - 1");

            string expected2 = "Three";
            await grain2.DoWrite(expected2);

            val2 = await grain2.GetValue();

            Assert.AreEqual(expected2, val2, "Value after Write#1 - 2");

            double expected3 = 5.1;
            await grain3.DoWrite(expected3);

            val3 = await grain3.GetValue();

            Assert.AreEqual(expected3, val3, "Value after Write#1 - 3");

            val1 = await grain1.GetValue();

            Assert.AreEqual(expected1, val1, "Value before Write#2 - 1");
            expected1 = 2;
            await grain1.DoWrite(expected1);

            val1 = await grain1.GetValue();

            Assert.AreEqual(expected1, val1, "Value after Write#2 - 1");
            val1 = await grain1.DoRead();

            Assert.AreEqual(expected1, val1, "Value after Re-Read - 1");

            val2 = await grain2.GetValue();

            Assert.AreEqual(expected2, val2, "Value before Write#2 - 2");
            expected2 = "Four";
            await grain2.DoWrite(expected2);

            val2 = await grain2.GetValue();

            Assert.AreEqual(expected2, val2, "Value after Write#2 - 2");
            val2 = await grain2.DoRead();

            Assert.AreEqual(expected2, val2, "Value after Re-Read - 2");

            val3 = await grain3.GetValue();

            Assert.AreEqual(expected3, val3, "Value before Write#2 - 3");
            expected3 = 6.2;
            await grain3.DoWrite(expected3);

            val3 = await grain3.GetValue();

            Assert.AreEqual(expected3, val3, "Value after Write#2 - 3");
            val3 = await grain3.DoRead();

            Assert.AreEqual(expected3, val3, "Value after Re-Read - 3");
        }