Ejemplo n.º 1
0
        public async Task ImageMustHaveValidBinData()
        {
            //arrange
            var manager   = GetTestShopManager();
            var validator = new ImageValidator();

            var image = new Image {
                ProductId = 1, BinData = new ImageBinData()
            };

            //act
            var result = await validator.ValidateAsync(manager, image);

            Assert.True(!result.Succeeded &&
                        result.Errors.Any(x => x.Code == nameof(OperationErrorDescriber.InvalidImageFormat)));
        }
Ejemplo n.º 2
0
        public async Task PassValidImage()
        {
            //arrange
            var manager   = GetTestShopManager();
            var validator = new ImageValidator();

            var imageBytes = TestFactory.GenerateValidImageBytes(1001, 1001, ImageFormat.Png);
            var image      = new Image()
            {
                ProductId = 322,
                BinData   = new ImageBinData()
                {
                    FullData = imageBytes
                }
            };

            //act
            var result = await validator.ValidateAsync(manager, image);

            Assert.True(result.Succeeded);
        }