I have an migration tool that gets data from different sources, map them and pushes it into a new system. The push to the new system is an api, I use the refit library as the httpClient. So because we dont want to push data to the new system always and just want to see the data we are going to push, I builded in a flag that gets passed everywhere : bool pushMode. If this is true, the data gets pushed to the new System, if not the data does not get pushed, but still gets all data from the sources and prints them out. Currently I have:
private async Task<KeyValuePair<Guid, MVInfo>?> CreateMyObject(Guid ownerId, Guid invoiceOwnerId, Guid objectTypeId,
ExtendedObjectResponse extendedObjectResponse, int groupId, Guid accountId, bool pushMode)
var creatObjectResult = pushMode==true? await _myApiClient.CreateObjectInNewSystem(myObject):new Domain.Responses.ItemCreationResponse {UniqueId = Guid.NewGuid()} ;
return new KeyValuePair<Guid, MVUnitInfo>(creatObjectResult.UniqueId, objectInfo.MVInfo);
I want to incorporate the flag sort of in the refit httpClient. So in the startup, specify the pushMode to false and then when the api is called that it will mock the response to something hardcoded or generated and when pushmode = true that it do the actual push. Any idea how to achieve this. Mock the response based on a flag set on startup
Aucun commentaire:
Enregistrer un commentaire