public async Task Handler_ShouldReturnNotFound_IfActionIsNotFound() { using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var query = new GetActionAttachmentsQuery(_tagId, 0); var dut = new GetActionAttachmentsQueryHandler(context); var result = await dut.Handle(query, default); Assert.IsNotNull(result); Assert.AreEqual(ResultType.NotFound, result.ResultType); Assert.IsNull(result.Data); } }
public async Task Handler_ShouldReturnAttachments() { using (var context = new PreservationContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var query = new GetActionAttachmentsQuery(_tagId, _actionId); var dut = new GetActionAttachmentsQueryHandler(context); var result = await dut.Handle(query, default); Assert.IsNotNull(result); Assert.AreEqual(ResultType.Ok, result.ResultType); var attachmentDtos = result.Data; Assert.AreEqual(1, attachmentDtos.Count); var attachment = attachmentDtos.Single(); Assert.AreEqual(_attachment.Id, attachment.Id); Assert.AreEqual(_attachment.FileName, attachment.FileName); } }