Ejemplo n.º 1
0
        public void ThrowsOnArrayWriteWhenValueExpected()
        {
            var elements = new List <PlyElement>()
            {
                new PlyElement("vertex", 1, new List <PlyProperty>()
                {
                    new PlyProperty("x", PlyType.Float),
                }),
                new PlyElement("face", 1, new List <PlyProperty>()
                {
                    new PlyArrayProperty("vertex_index", PlyType.Int, PlyType.Int)
                })
            };

            var header = new PlyHeader(PlyFormat.Ascii, elements);

            using (var stream = new MemoryStream())
            {
                var writer = new PlyAsciiWriter(stream, header);
                Assert.Throws <UnexpectedDataTypeException>(() => writer.WriteArray(1, 2, 3));
                Assert.DoesNotThrow(() => writer.WriteValue(1.2f));
                Assert.Throws <UnexpectedDataTypeException>(() => writer.WriteValue(12.0f));
                Assert.Throws <InvalidOperationException>(() => writer.Dispose());
                Assert.DoesNotThrow(() => writer.WriteArray(1, 2, 3));
                Assert.DoesNotThrow(() => writer.Dispose());
            }
        }
Ejemplo n.º 2
0
        public void ThrowsWhenTooManyValuesWritten()
        {
            var elements = new List <PlyElement>()
            {
                new PlyElement("vertex", 1, new List <PlyProperty>()
                {
                    new PlyProperty("x", PlyType.Float),
                }),
                new PlyElement("face", 1, new List <PlyProperty>()
                {
                    new PlyArrayProperty("vertex_index", PlyType.Int, PlyType.Int)
                })
            };

            var header = new PlyHeader(PlyFormat.Ascii, elements);

            using (var stream = new MemoryStream())
            {
                using (var writer = new PlyAsciiWriter(stream, header))
                {
                    writer.WriteValue(1.0f);
                    writer.WriteArray(new int[] { 12, 16, 45 });
                    Assert.Throws <InvalidOperationException>(() => writer.WriteArray(new int[] { 1, 2, 3 }));
                }
            }
        }
Ejemplo n.º 3
0
        public void ThrowsOnUnexpectedDataType()
        {
            var elements = new List <PlyElement>()
            {
                new PlyElement("vertex", 1, new List <PlyProperty>()
                {
                    new PlyProperty("x", PlyType.Float),
                })
            };

            var header = new PlyHeader(PlyFormat.Ascii, elements);

            using (var stream = new MemoryStream())
            {
                var writer = new PlyAsciiWriter(stream, header);
                Assert.Throws <UnexpectedDataTypeException>(() => writer.WriteValue(12));
                writer.ForceDispose();
            }
        }
Ejemplo n.º 4
0
        public void ThrowsWhenNotAllValuesWritten()
        {
            var elements = new List <PlyElement>()
            {
                new PlyElement("vertex", 1, new List <PlyProperty>()
                {
                    new PlyProperty("x", PlyType.Float),
                }),
                new PlyElement("face", 1, new List <PlyProperty>()
                {
                    new PlyArrayProperty("vertex_index", PlyType.Int, PlyType.Int)
                })
            };

            var header = new PlyHeader(PlyFormat.Ascii, elements);

            using (var stream = new MemoryStream())
            {
                var writer = new PlyAsciiWriter(stream, header);
                writer.WriteValue(1.0f);
                Assert.Throws <InvalidOperationException>(() => writer.Dispose());
                writer.ForceDispose();
            }
        }