public async Task Handle_HappyFlow() { // Arrange var note1 = await _wolkDbContext.CreateAndSaveNote(); var note2 = await _wolkDbContext.CreateAndSaveNote(); var file1 = await _wolkDbContext.CreateAndSaveAttachment(note1); var file2 = await _wolkDbContext.CreateAndSaveAttachment(note2); var file3 = await _wolkDbContext.CreateAndSaveAttachment(note1); var request = new GetAttachmentsQuery { NoteId = note1.Id }; // Act var result = (await _handler.Handle(request, CancellationToken.None)).ToArray(); // Assert Assert.AreEqual(2, result.Length); ShouldBeEqual(file1, result[0]); ShouldBeEqual(file3, result[1]); }
public async Task ValidateAsync_OnGetAttachmentsQuery_ShouldReturnFalse_WhenNoAccessToProject() { // Arrange var query = new GetAttachmentsQuery(_invitationIdWithoutAccessToProject); // act var result = await _dut.ValidateAsync(query); // Assert Assert.IsFalse(result); }
public async Task Handle_ReturnsCorrectNumberOfAttachments() { using var context = new IPOContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider); var blobStorageMock = new Mock <IBlobStorage>(); var query = new GetAttachmentsQuery(1); var dut = new GetAttachmentsQueryHandler(context, blobStorageMock.Object, _blobStorageOptionsMonitorMock.Object); var result = await dut.Handle(query, default); Assert.IsNotNull(result); Assert.AreEqual(2, result.Data.Count); }
public async Task <ActionResult <IEnumerable <AttachmentDto> > > GetAllAttachments( [FromRoute] GetAttachmentsQuery query) => Ok(Mapper.Map <IEnumerable <AttachmentDto> >(await Mediator.Send(query)));
public void Constructor_SetsProperties() { var dut = new GetAttachmentsQuery(1); Assert.AreEqual(1, dut.InvitationId); }