public async Task Grain_Generic_SimpleSQLStore_Read_Write() { long id = random.Next(); ISimpleSQLStorageGenericGrain <int> grain = GrainClient.GrainFactory.GetGrain <ISimpleSQLStorageGenericGrain <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_SimpleSQLStore_DiffTypes() { long id1 = random.Next(); long id2 = id1; long id3 = id1; ISimpleSQLStorageGenericGrain <int> grain1 = GrainClient.GrainFactory.GetGrain <ISimpleSQLStorageGenericGrain <int> >(id1); ISimpleSQLStorageGenericGrain <string> grain2 = GrainClient.GrainFactory.GetGrain <ISimpleSQLStorageGenericGrain <string> >(id2); ISimpleSQLStorageGenericGrain <double> grain3 = GrainClient.GrainFactory.GetGrain <ISimpleSQLStorageGenericGrain <double> >(id3); int val1 = await grain1.GetValue(); Assert.Equal(0, val1);// "Initial value - 1"); string val2 = await grain2.GetValue(); Assert.Equal(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"); }