Ejemplo n.º 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]);
        }
        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);
        }