Exemple #1
0
        public async Task HandleGetPreservationRecordQuery_ShouldSucceed_WhenKnownRecord()
        {
            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider))
            {
                var query  = new GetPreservationRecordQuery(_tagId, _requirementWithoutFieldId, _preservationRecordGuid);
                var dut    = new GetPreservationRecordQueryHandler(context);
                var result = await dut.Handle(query, default);

                Assert.IsNotNull(result);
                var dto = result.Data;
                Assert.AreEqual(dto.Id, _preservationRecordId);
                Assert.IsNotNull(dto.RequirementType);
                Assert.AreEqual(_interval, dto.IntervalWeeks);
                Assert.AreEqual(_comment, dto.Comment);
                Assert.AreEqual(_requirementType.Id, dto.RequirementType.Id);
                Assert.AreEqual(_requirementType.Code, dto.RequirementType.Code);
                Assert.AreEqual(_requirementType.Icon, dto.RequirementType.Icon);
                Assert.AreEqual(_requirementType.Title, dto.RequirementType.Title);
                Assert.IsNotNull(dto.RequirementDefinition);
                Assert.AreEqual(_requirementDefinitionWithoutOneField.Id, dto.RequirementDefinition.Id);
                Assert.AreEqual(_requirementDefinitionWithoutOneField.Title, dto.RequirementDefinition.Title);
                Assert.IsTrue(dto.Fields.Count == 1);
                var field = dto.Fields.ElementAt(0);
                Assert.AreEqual(_infoField.Id, field.Id);
                Assert.AreEqual(_infoField.FieldType, field.FieldType);
                Assert.AreEqual(_infoField.Label, field.Label);
            }
        }
Exemple #2
0
        public async Task HandleGetPreservationRecordQuery_ShouldFail_WhenPreservationRecordNotExist()
        {
            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher,
                                                         _currentUserProvider))
            {
                var presevRecordGuid = new Guid();
                var query            = new GetPreservationRecordQuery(_tagId, _requirementWithoutFieldId, presevRecordGuid);
                var dut    = new GetPreservationRecordQueryHandler(context);
                var result = await dut.Handle(query, default);

                Assert.AreEqual(1, result.Errors.Count);
                Assert.IsTrue(result.Errors[0].StartsWith($"{nameof(PreservationPeriod)} not found"));
            }
        }
Exemple #3
0
        public async Task HandleGetPreservationRecordQuery_ShouldFail_WhenTagRequirementNotExist()
        {
            using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher,
                                                         _currentUserProvider))
            {
                var reqId  = 22;
                var query  = new GetPreservationRecordQuery(_tagId, reqId, _preservationRecordGuid);
                var dut    = new GetPreservationRecordQueryHandler(context);
                var result = await dut.Handle(query, default);

                Assert.AreEqual(1, result.Errors.Count);
                Assert.IsTrue(result.Errors[0].StartsWith(Strings.EntityNotFound(nameof(TagRequirement), reqId)));
            }
        }