public DiscoverImageFormatTests()
        {
            this.localImageFormatMock = new Mock <IImageFormat>();

            this.localMimeTypeDetector = new Mock <IImageFormatDetector>();
            this.localMimeTypeDetector.Setup(x => x.HeaderSize).Returns(1);
            this.localMimeTypeDetector.Setup(x => x.DetectFormat(It.IsAny <ReadOnlySpan <byte> >())).Returns(localImageFormatMock.Object);

            this.fileSystem = new Mock <IFileSystem>();

            this.LocalConfiguration = new Configuration()
            {
                FileSystem = this.fileSystem.Object
            };
            this.LocalConfiguration.AddImageFormatDetector(this.localMimeTypeDetector.Object);

            TestFormat.RegisterGloablTestFormat();
            this.Marker     = Guid.NewGuid().ToByteArray();
            this.DataStream = TestFormat.GlobalTestFormat.CreateStream(this.Marker);

            this.FilePath = Guid.NewGuid().ToString();
            this.fileSystem.Setup(x => x.OpenRead(this.FilePath)).Returns(this.DataStream);

            TestFileSystem.RegisterGloablTestFormat();
            TestFileSystem.Global.AddFile(this.FilePath, this.DataStream);
        }
Exemple #2
0
        public DiscoverImageFormatTests()
        {
            this.localImageFormatMock = new Mock <IImageFormat>();

            this.localMimeTypeDetector = new MockImageFormatDetector(this.localImageFormatMock.Object);

            this.fileSystem = new Mock <IFileSystem>();

            this.LocalConfiguration = new Configuration
            {
                FileSystem = this.fileSystem.Object
            };

            this.LocalConfiguration.ImageFormatsManager.AddImageFormatDetector(this.localMimeTypeDetector);

            TestFormat.RegisterGlobalTestFormat();
            this.Marker     = Guid.NewGuid().ToByteArray();
            this.DataStream = TestFormat.GlobalTestFormat.CreateStream(this.Marker);

            this.FilePath = Guid.NewGuid().ToString();
            this.fileSystem.Setup(x => x.OpenRead(this.FilePath)).Returns(this.DataStream);

            TestFileSystem.RegisterGlobalTestFormat();
            TestFileSystem.Global.AddFile(this.FilePath, this.DataStream);
        }
            public void Configuration_Bytes_Decoder_Agnostic(bool useSpan)
            {
                var localFormat = new TestFormat();

                var img = useSpan ?
                          Image.Load(this.TopLevelConfiguration, this.ByteSpan, localFormat.Decoder) :
                          Image.Load(this.TopLevelConfiguration, this.ByteArray, localFormat.Decoder);

                Assert.NotNull(img);
                localFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration);
            }
        public ImageLoadTests()
        {
            this.returnImage = new Image <Rgba32>(1, 1);

            this.localImageFormatMock = new Mock <IImageFormat>();

            this.localDecoder          = new Mock <IImageDecoder>();
            this.localMimeTypeDetector = new Mock <IImageFormatDetector>();
            this.localMimeTypeDetector.Setup(x => x.HeaderSize).Returns(1);
            this.localMimeTypeDetector.Setup(x => x.DetectFormat(It.IsAny <ReadOnlySpan <byte> >())).Returns(localImageFormatMock.Object);

            this.localDecoder.Setup(x => x.Decode <Rgba32>(It.IsAny <Configuration>(), It.IsAny <Stream>()))

            .Callback <Configuration, Stream>((c, s) =>
            {
                using (var ms = new MemoryStream())
                {
                    s.CopyTo(ms);
                    this.DecodedData = ms.ToArray();
                }
            })
            .Returns(this.returnImage);

            this.fileSystem = new Mock <IFileSystem>();

            this.LocalConfiguration = new Configuration()
            {
                FileSystem = this.fileSystem.Object
            };
            this.LocalConfiguration.AddImageFormatDetector(this.localMimeTypeDetector.Object);
            this.LocalConfiguration.SetDecoder(localImageFormatMock.Object, this.localDecoder.Object);

            TestFormat.RegisterGloablTestFormat();
            this.Marker     = Guid.NewGuid().ToByteArray();
            this.DataStream = TestFormat.GlobalTestFormat.CreateStream(this.Marker);

            this.FilePath = Guid.NewGuid().ToString();
            this.fileSystem.Setup(x => x.OpenRead(this.FilePath)).Returns(this.DataStream);

            TestFileSystem.RegisterGloablTestFormat();
            TestFileSystem.Global.AddFile(this.FilePath, this.DataStream);
        }
Exemple #5
0
 public TestEncoder(TestFormat testFormat)
 {
     this.testFormat = testFormat;
 }
Exemple #6
0
 public TestHeader(TestFormat testFormat)
 {
     this.testFormat = testFormat;
 }