public async Task Grain_Generic_GrainStorage_Read_Write() { long id = random.Next(); IGrainStorageGenericGrain <int> grain = this.GrainFactory.GetGrain <IGrainStorageGenericGrain <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_NestedGeneric_GrainStorage_Read_Write() { long id = random.Next(); IGrainStorageGenericGrain <List <int> > grain = this.GrainFactory.GetGrain <IGrainStorageGenericGrain <List <int> > >(id); var val = await grain.GetValue(); Assert.Null(val); // "Initial value" await grain.DoWrite(new List <int> { 1 }); val = await grain.GetValue(); Assert.Equal(new List <int> { 1 }, val); // "Value after Write-1" await grain.DoWrite(new List <int> { 1, 2 }); val = await grain.GetValue(); Assert.Equal(new List <int> { 1, 2 }, val); // "Value after Write-2" val = await grain.DoRead(); Assert.Equal(new List <int> { 1, 2 }, val); // "Value after Re-Read" }
public async Task Grain_Generic_GrainStorage_DiffTypes() { long id1 = random.Next(); long id2 = id1; long id3 = id1; IGrainStorageGenericGrain <int> grain1 = this.GrainFactory.GetGrain <IGrainStorageGenericGrain <int> >(id1); IGrainStorageGenericGrain <string> grain2 = this.GrainFactory.GetGrain <IGrainStorageGenericGrain <string> >(id2); IGrainStorageGenericGrain <double> grain3 = this.GrainFactory.GetGrain <IGrainStorageGenericGrain <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" }