public async Task UpdateSurveyAnswersAsync() { var transactionScopeoption = TransactionScopeOption.RequiresNew; using var scope = new TransactionScope(transactionScopeoption, TransactionScopeAsyncFlowOption.Enabled); //Arrange var identityWorkId = Guid.NewGuid(); var instanceId = Guid.NewGuid(); var NOMSurveyReplies = (await CreateDefaultAsync <NOMSurveyReplyResult>(identityWorkId, instanceId)).FirstOrDefault(); //Act var middlewareManager = new NOMSurveyManager(); //Get var resultPrevious = await middlewareManager.GetAsync(NOMSurveyReplies.Token, identityWorkId); //Assert Assert.NotNull(resultPrevious); resultPrevious.Result = 1; resultPrevious.EvaluationState = EvaluationStateType.Sent; List <NOMAnswer> nOMAnswer = new List <NOMAnswer>() { new NOMAnswer() { ID = Guid.NewGuid(), Active = true, Timestamp = DateTime.UtcNow, Description = "Soy una surveyreply", CreationDate = DateTime.Now, company = identityWorkId, user = Guid.NewGuid(), InstanceID = instanceId, Name = "g1", StatusID = 1, Value = 1 } }; //resultPrevious.NOMAnswer = nOMAnswer; //Delete await middlewareManager.UpdateSurveyAsync(resultPrevious, identityWorkId); //Get resultPrevious = await middlewareManager.GetAsync(NOMSurveyReplies.Token, identityWorkId); //Assert Assert.NotNull(resultPrevious); Assert.Equal(1, resultPrevious.Result); Assert.Equal(EvaluationStateType.Sent, resultPrevious.EvaluationState); await middlewareManager.DeleteAsync(new List <Guid>() { resultPrevious.ID }, identityWorkId); //Get it again to verify if the registry it was deleted resultPrevious = await middlewareManager.GetAsync(NOMSurveyReplies.Token, identityWorkId); //Assert Assert.Null(resultPrevious); }
public async Task ProcessFinalization() { var transactionScopeoption = TransactionScopeOption.RequiresNew; using var scope = new TransactionScope(transactionScopeoption, TransactionScopeAsyncFlowOption.Enabled); //Arrange var identityWorkId = Guid.NewGuid(); var instanceId = Guid.NewGuid(); var NOMSurveyReplies = (await CreateDefaultAsync <NOMSurveyReplyResult>(identityWorkId, instanceId)).FirstOrDefault(); //Act var middlewareManager = new NOMSurveyManager(); //Get var resultPrevious = await middlewareManager.GetAsync(NOMSurveyReplies.Token, identityWorkId); //Assert Assert.NotNull(resultPrevious); Assert.True(resultPrevious.NOMAnswer.Any()); //TODO answers and process //Delete await middlewareManager.DeleteAsync(new List <Guid>() { resultPrevious.ID }, identityWorkId); //Get it again to verify if the registry it was deleted var mustNotExists = await middlewareManager.GetAsync(NOMSurveyReplies.Token, identityWorkId); //Assert Assert.Null(mustNotExists); }
public async Task UpdateSurveyAsync() { using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled); //Arrange var identityWorkId = Guid.NewGuid(); var instanceId = Guid.NewGuid(); var NOMSurveyReplies = (await CreateDefaultAsync <NOMSurveyReplyResult>(identityWorkId, instanceId)).FirstOrDefault(); //Act var middlewareManager = new NOMSurveyManager(); //Get var resultPrevious = await middlewareManager.GetAsync(NOMSurveyReplies.Token, identityWorkId); //Assert Assert.NotNull(resultPrevious); resultPrevious.Result = 1; resultPrevious.EvaluationState = EvaluationStateType.Sent; //Delete await middlewareManager.UpdateSurveyAsync(resultPrevious, identityWorkId); //Get resultPrevious = await middlewareManager.GetAsync(NOMSurveyReplies.Token, identityWorkId); //Assert Assert.NotNull(resultPrevious); Assert.Equal(1, resultPrevious.Result); Assert.Equal(EvaluationStateType.Sent, resultPrevious.EvaluationState); await middlewareManager.DeleteAsync(new List <Guid>() { resultPrevious.ID }, identityWorkId); //Get it again to verify if the registry it was deleted resultPrevious = await middlewareManager.GetAsync(NOMSurveyReplies.Token, identityWorkId); //Assert Assert.Null(resultPrevious); }