Ejemplo n.º 1
0
        public void CanCreateViewportOnSheet()
        {
            // Arrange
            var sheet = ElementSelector.ByType <Autodesk.Revit.DB.ViewSheet>(true).First() as Sheet;
            var view  = CreateTestView();
            var point = Point.ByCoordinates(250, 250);

            var expectedExceptionMessage = Revit.Properties.Resources.ViewAlreadyPlacedOnSheet;

            // Act
            var viewport          = Viewport.BySheetViewLocation(sheet, view, point);
            var viewportLocation  = viewport.InternalViewport.GetBoxCenter().ToPoint() as Point;
            var exceptionViewport = Assert.Throws <InvalidOperationException>(() => Viewport.BySheetViewLocation(sheet, view, point));

            // Assert
            Assert.AreEqual(viewport.GetType(), typeof(Viewport));
            Assert.AreEqual(point.X, viewportLocation.X, Tolerance);
            Assert.AreEqual(point.Y, viewportLocation.Y, Tolerance);
            Assert.AreEqual(expectedExceptionMessage, exceptionViewport.Message);
        }