public async Task GeneratorDerivedDerivedGrainControlFlow() { IGeneratorTestDerivedDerivedGrain grain = GrainClient.GrainFactory.GetGrain<IGeneratorTestDerivedDerivedGrain>(GetRandomGrainId()); bool isNull = await grain.StringIsNullOrEmpty(); Assert.IsTrue(isNull); await grain.StringSet("Begin"); isNull = await grain.StringIsNullOrEmpty(); Assert.IsFalse(isNull); MemberVariables members = await grain.GetMemberVariables(); Assert.AreEqual("Begin", members.stringVar); ReplaceArguments arguments = new ReplaceArguments("Begin", "End"); string strPromise = await grain.StringReplace(arguments); Assert.AreEqual("End", strPromise); strPromise = await grain.StringConcat("Begin", "Cont", "End"); Assert.AreEqual("BeginContEnd", strPromise); string[] strArray = { "Begin", "Cont", "Cont", "End" }; strPromise = await grain.StringNConcat(strArray); Assert.AreEqual("BeginContContEnd", strPromise); ASCIIEncoding encoding = new ASCIIEncoding(); byte[] bytes = encoding.GetBytes("ByteBegin"); string str = "StringBegin"; MemberVariables memberVariables = new MemberVariables(bytes, str, ReturnCode.Fail); await grain.SetMemberVariables(memberVariables); members = await grain.GetMemberVariables(); ASCIIEncoding enc = new ASCIIEncoding(); Assert.AreEqual("ByteBegin", enc.GetString(members.byteArray)); Assert.AreEqual("StringBegin", members.stringVar); Assert.AreEqual(ReturnCode.Fail, members.code); }
public Task<string> StringReplace(ReplaceArguments strs) { myGrainString = myGrainString.Replace(strs.OldString, strs.NewString); return Task.FromResult(myGrainString); }