Ejemplo n.º 1
0
        public void ThrowOnAnyError_MultipleErrors()
        {
            var response = new AnnotateVideoResponse
            {
                AnnotationResults =
                {
                    new VideoAnnotationResults {
                        Error = new Rpc.Status {
                            Message = "Boom"
                        }
                    },
                    new VideoAnnotationResults {
                        ExplicitAnnotation = new ExplicitContentAnnotation()
                    },
                    new VideoAnnotationResults {
                        Error = new Rpc.Status {
                            Message = "Bang"
                        }
                    }
                }
            };
            var exception        = Assert.Throws <AggregateException>(() => response.ThrowOnAnyError());
            var nestedExceptions = exception.InnerExceptions.Cast <AnnotateVideoException>().ToList();

            Assert.Equal(2, nestedExceptions.Count);
            Assert.Equal("Boom", nestedExceptions[0].Message);
            Assert.Equal("Bang", nestedExceptions[1].Message);
            Assert.Same(response.AnnotationResults[0], nestedExceptions[0].Response);
            // response.AnnotationResults[1] is skipped as it had no error.
            Assert.Same(response.AnnotationResults[2], nestedExceptions[1].Response);
        }
Ejemplo n.º 2
0
        public void ThrowOnAnyError_NoErrors()
        {
            var response = new AnnotateVideoResponse
            {
                AnnotationResults =
                {
                    new VideoAnnotationResults {
                        ExplicitAnnotation = new ExplicitContentAnnotation()
                    },
                    new VideoAnnotationResults {
                        FaceAnnotations =      { new FaceAnnotation()}
                    }
                }
            };

            Assert.Same(response, response.ThrowOnAnyError());
        }
Ejemplo n.º 3
0
        public void ThrowOnAnyError_OneError()
        {
            var response = new AnnotateVideoResponse
            {
                AnnotationResults =
                {
                    new VideoAnnotationResults {
                        FaceAnnotations =      { new FaceAnnotation()}
                    },
                    new VideoAnnotationResults {
                        Error = new Rpc.Status {
                            Message = "Bang"
                        }
                    }
                }
            };
            var exception       = Assert.Throws <AggregateException>(() => response.ThrowOnAnyError());
            var nestedException = (AnnotateVideoException)exception.InnerExceptions[0];

            Assert.Equal("Bang", nestedException.Message);
            Assert.Same(response.AnnotationResults[1], nestedException.Response);
        }