Example #1
0
        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]);
        }
Example #2
0
        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);
        }
Example #4
0
 public async Task <ActionResult <IEnumerable <AttachmentDto> > > GetAllAttachments(
     [FromRoute] GetAttachmentsQuery query) =>
 Ok(Mapper.Map <IEnumerable <AttachmentDto> >(await Mediator.Send(query)));
Example #5
0
        public void Constructor_SetsProperties()
        {
            var dut = new GetAttachmentsQuery(1);

            Assert.AreEqual(1, dut.InvitationId);
        }