Ejemplo n.º 1
0
        public async Task Validate_ValidCommand_ShouldBeTrueAsync()
        {
            //// Arrange
            var sut = new PinAttachFileCommandHandler(_context);

            var command = new PinAttachFileCommand
            {
                MessageId      = validMessageId,
                BlobStorageUrl = validBlobStorageUrl,
                IsPinFile      = true
            };

            /// Act
            await sut.Handle(command, CancellationToken.None);

            var entity = _context.MessageChats.Find(validMessageId);

            entity.ShouldNotBeNull();

            var attachFile = entity.AttachFileList
                             .Where(file => file.BlobStorageUrl == validBlobStorageUrl)
                             .FirstOrDefault();

            attachFile.IsPin.ShouldBe(true);
        }
Ejemplo n.º 2
0
        public async Task Handle_GivenInvalidBlobStorageUrl_ShouldRaiseException()
        {
            //// Arrange
            var sut = new PinAttachFileCommandHandler(_context);

            var command = new PinAttachFileCommand
            {
                MessageId      = validMessageId,
                BlobStorageUrl = "invalid-url/invalid-file-name",
                IsPinFile      = true
            };

            //// Act
            await Assert.ThrowsAsync <NotFoundException>(() => sut.Handle(command, CancellationToken.None));
        }