Пример #1
0
            public async Task Should_Create_NOMAnswer_And_Get_ToValidate_Finally_do_DeleteAsync()
            {
                using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                //Arrange
                var identityWorkId = Guid.NewGuid();
                var instanceId     = Guid.NewGuid();

                var NOMAnswers = await new NOMAnswerManagerUT().CreateDefaultAsync <NOMAnswer>(identityWorkId, instanceId);

                //Act
                var middlewareManager = new MiddlewareManager <NOMAnswer>(new BaseRecordManager <NOMAnswer>(), new NOMAnswerValidator());

                //Asserts
                //Get
                var result = middlewareManager
                             .GetByIds(NOMAnswers.Select(p => p.ID).ToList(), identityWorkId);

                Assert.True(result.Count() > 0);

                //Delete
                middlewareManager.Delete(NOMAnswers.Select(p => p.ID).ToList(), identityWorkId);

                //Get it again to verify if the registry it was deleted
                var result2 = middlewareManager
                              .GetByIds(NOMAnswers.Select(p => p.ID).ToList(), identityWorkId);

                Assert.True(result2.Count() == 0);
            }
Пример #2
0
            public async Task Should_Create_NOMEvaluationPhase_And_Get_ToValidate_Finally_do_Delete()
            {
                using var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);

                //Arrange
                var identityWorkId = Guid.NewGuid();
                var instanceId     = Guid.NewGuid();

                var NOMEvaluationPhases = await new PhaseManagerUT().CreateDefaultAsync <NOMEvaluationPhase>(identityWorkId, instanceId);

                //Act
                var middlewareManager         = new MiddlewareManager <NOMEvaluationPhase>(new BaseRecordManager <NOMEvaluationPhase>(), new NOMEvaluationPhaseValidator());
                var middlewareManagerQuestion = new MiddlewareManager <NOMEvaluationQuestion>(new BaseRecordManager <NOMEvaluationQuestion>(), new NOMEvaluationQuestionValidator());

                //Asserts
                //Get
                var ids    = NOMEvaluationPhases.Select(p => p.ID).ToList();
                var id     = NOMEvaluationPhases.Select(p => p.ID).ToList().First();
                var result = middlewareManager
                             .GetByIds(ids, identityWorkId);

                Assert.True(result.Count() > 0);

                //Act again

                var NOMEvaluationPhases2 = new List <NOMEvaluationQuestion>();

                NOMEvaluationPhases2.Add(new NOMEvaluationQuestion()
                {
                    ID                   = Guid.NewGuid(),
                    Active               = true,
                    Timestamp            = DateTime.UtcNow,
                    Description          = "Mi trabajo me exige hacer mucho esfuerzo físico.",
                    CreationDate         = DateTime.Now,
                    Name                 = "Mi trabajo me exige hacer mucho esfuerzo físico..",
                    StatusID             = 1,
                    NOMEvaluationPhaseID = id,
                });

                var middlewareManager3 = new MiddlewareManager <NOMEvaluationQuestion>(new BaseRecordManager <NOMEvaluationQuestion>(), new NOMEvaluationQuestionValidator());
                await middlewareManager3.CreateAsync(NOMEvaluationPhases2, identityWorkId);

                var NoEvalQuestion = NOMEvaluationPhases2;
                var ids2           = NoEvalQuestion.Select(p => p.ID).ToList();

                var resultQuestions = await middlewareManagerQuestion.GetByIdsAsync(ids2, identityWorkId);

                Assert.True(result.Any());
                Assert.True(result.FirstOrDefault().ID == NOMEvaluationPhases.FirstOrDefault().ID);
                Assert.True(resultQuestions.Any());

                //Delete
                await middlewareManagerQuestion.DeleteAsync(ids2, identityWorkId);

                await middlewareManager.DeleteAsync(ids, identityWorkId);

                //Get it again to verify if the registry was deleted
                var result2 = await middlewareManager
                              .GetByIdsAsync(ids, identityWorkId);

                Assert.True(!result2.Any());

                var result3 = await middlewareManager
                              .GetByIdsAsync(ids2, identityWorkId);

                Assert.True(!result3.Any());
            }