public virtual async Task <IPropertyBatchResultWrapper> SubmitPropertyBatchAsync( Uri parentName, ICollection <PropertyBatchOperation> operations) { var batchResult = new MockPropertyBatchResultWrapper(); return(await Task.FromResult(batchResult).ConfigureAwait(false)); }
private MockPropertyBatchResultWrapper WorkflowForInitializeTest2( Uri parentName, ICollection <PropertyBatchOperation> operations) { var result = new MockPropertyBatchResultWrapper { FailedOperationIndex = 0, FailedOperationException = new FabricException(FabricErrorCode.Unknown) }; TraceType.ConsoleWriteLine("Setting FailedOperationIndex = 0 to simulate error from SubmitPropertyBatchAsync inside Initialize"); return(result); }
private MockPropertyBatchResultWrapper Workflow2( Uri parentName, ICollection <PropertyBatchOperation> operations) { var result = new MockPropertyBatchResultWrapper { FailedOperationIndex = -1, }; if (workflow2Counter == 0) { // there are 6 operations that are batched up inside UpdatePropertiesAsync // If we succeed, we get the values of indices 2 and 4 to update the cache. // Simulating this behavior result.NamedProperties.Add(new MockNamedPropertyWrapper()); result.NamedProperties.Add(new MockNamedPropertyWrapper()); result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = (Int64)0 }); result.NamedProperties.Add(new MockNamedPropertyWrapper()); result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = "Apple" }); result.NamedProperties.Add(new MockNamedPropertyWrapper()); traceType.ConsoleWriteLine("Setting FailedOperationIndex = -1 to simulate success from SubmitPropertyBatchAsync for an Update"); } else { result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = (Int64)25 }); result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = "Antelope" }); traceType.ConsoleWriteLine("Setting FailedOperationIndex = -1 to simulate success from SubmitPropertyBatchAsync for a Get"); } workflow2Counter++; return(result); }
private MockPropertyBatchResultWrapper WorkflowForUpdatePolicyAsyncTest3( Uri parentName, ICollection <PropertyBatchOperation> operations) { var result = new MockPropertyBatchResultWrapper(); if (funcToInvoke == 0) { Trace.ConsoleWriteLine( TraceType, "Setting FailedOperationIndex = -1 to simulate success from ReadProperties() inside UpdatePolicyAsync"); result.FailedOperationIndex = -1; // operation succeeds result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = (Int64)1 }); result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = JobBlockingPolicy.BlockNone.ToString() }); funcToInvoke++; } else { Trace.ConsoleWriteLine(TraceType, "Setting FailedOperationIndex = -1 (i.e. success) to simulate success inside UpdatePolicyAsync"); // there are 6 operations that are batched up inside UpdatePropertiesAsync // If we succeed, we get the values of indices 2 and 4 to update the cache. // Simulating this behavior result.NamedProperties.Add(new MockNamedPropertyWrapper()); result.NamedProperties.Add(new MockNamedPropertyWrapper()); result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = (Int64)2 }); result.NamedProperties.Add(new MockNamedPropertyWrapper()); result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = JobBlockingPolicy.BlockAllJobs.ToString() }); result.NamedProperties.Add(new MockNamedPropertyWrapper()); } return(result); }
private MockPropertyBatchResultWrapper WorkflowForUpdatePolicyAsyncTest1( Uri parentName, ICollection <PropertyBatchOperation> operations) { var result = new MockPropertyBatchResultWrapper(); if (funcToInvoke == 0) { Trace.ConsoleWriteLine(TraceType, "Setting FailedOperationIndex = -1 to simulate success from ReadProperties() inside UpdatePolicyAsync"); result.FailedOperationIndex = -1; // operation succeeds result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = (Int64)1 }); result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = JobBlockingPolicy.BlockAllJobs.ToString() }); funcToInvoke++; } else if (funcToInvoke == 1) { Trace.ConsoleWriteLine(TraceType, "Setting FailedOperationIndex = 0 to simulate version mismatch from SubmitPropertyBatchAsync inside UpdatePolicyAsync"); result.FailedOperationIndex = 0; // operation fails result.FailedOperationException = new FabricException(FabricErrorCode.Unknown); funcToInvoke++; // the next time SubmitFunc is called, it should succeed } else { Trace.ConsoleWriteLine(TraceType, "Setting FailedOperationIndex = -1 to simulate success from ReadProperties() inside UpdatePolicyAsync"); result.FailedOperationIndex = -1; // operation succeeds result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = (Int64)1 }); result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = JobBlockingPolicy.BlockAllJobs.ToString() }); } return(result); }
private MockPropertyBatchResultWrapper WorkflowForInitializeTest1( Uri parentName, ICollection <PropertyBatchOperation> operations) { var result = new MockPropertyBatchResultWrapper { FailedOperationIndex = -1, FailedOperationException = new FabricException(FabricErrorCode.Unknown) }; result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = (Int64)1 }); result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = JobBlockingPolicy.BlockAllJobs.ToString() }); TraceType.ConsoleWriteLine("Setting FailedOperationIndex = -1 to simulate success from SubmitPropertyBatchAsync inside Initialize"); return(result); }
private MockPropertyBatchResultWrapper Workflow3( Uri parentName, ICollection <PropertyBatchOperation> operations) { var result = new MockPropertyBatchResultWrapper { FailedOperationIndex = -1, }; result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = (Int64)2 }); result.NamedProperties.Add(new MockNamedPropertyWrapper { Value = "Apple" }); traceType.ConsoleWriteLine("Setting FailedOperationIndex = -1 to simulate success from SubmitPropertyBatchAsync for a Get"); workflow3Counter++; return(result); }