Exemplo n.º 1
0
        public async Task Create_should_create_events_and_update_state()
        {
            var command = new CreateAsset {
                File = file, ImageInfo = image, FileHash = "NewHash", Tags = new HashSet <string>()
            };

            var result = await sut.ExecuteAsync(CreateAssetCommand(command));

            result.ShouldBeEquivalent(sut.Snapshot);

            Assert.Equal(0, sut.Snapshot.FileVersion);
            Assert.Equal(command.FileHash, sut.Snapshot.FileHash);

            LastEvents
            .ShouldHaveSameEvents(
                CreateAssetEvent(new AssetCreated
            {
                IsImage     = true,
                FileName    = file.FileName,
                FileSize    = file.FileSize,
                FileHash    = command.FileHash,
                FileVersion = 0,
                MimeType    = file.MimeType,
                PixelWidth  = image.PixelWidth,
                PixelHeight = image.PixelHeight,
                Tags        = new HashSet <string>(),
                Slug        = file.FileName.ToAssetSlug()
            })
                );
        }
Exemplo n.º 2
0
        private async Task <object?> PublishAsync(AssetCommand command)
        {
            var result = await sut.ExecuteAsync(CreateAssetCommand(command));

            return(result.Value);
        }
Exemplo n.º 3
0
 private Task ExecuteCreateAsync()
 {
     return(asset.ExecuteAsync(CreateCommand(new CreateAsset {
         AssetId = Id, File = file
     })));
 }