예제 #1
0
 private static void CompareComponents(Components expectedComponents, Components actualComponents)
 {
     if (TestCompareUtilities.BothNotNullAndEmpty(expectedComponents.Coloring, actualComponents.Coloring, "Viewpoint.Components.Coloring"))
     {
         Assert.Equal(expectedComponents.Coloring.Count, actualComponents.Coloring.Count);
         foreach (var expectedColoring in expectedComponents.Coloring)
         {
             var actualColoring = actualComponents.Coloring.FirstOrDefault(c => c.Color == expectedColoring.Color);
             Assert.NotNull(actualColoring);
             CompareComponentsList(expectedColoring.Component, actualColoring.Component);
         }
         var allActualColorsAreExpected = actualComponents.Coloring.All(c => expectedComponents.Coloring.Any(ec => ec.Color == c.Color));
         Assert.True(allActualColorsAreExpected);
     }
     CompareComponentsList(expectedComponents.Selection, actualComponents.Selection);
     if (TestCompareUtilities.BothNotNullAndEmpty(expectedComponents.ViewSetupHints, actualComponents.ViewSetupHints, "Viewpoint.Components.ViewSetupHints"))
     {
         var expectedViewSetupHints = expectedComponents.ViewSetupHints;
         var actualViewSetupHints   = actualComponents.ViewSetupHints;
         Assert.Equal(expectedViewSetupHints.OpeningsVisible, actualViewSetupHints.OpeningsVisible);
         Assert.Equal(expectedViewSetupHints.SpaceBoundariesVisible, actualViewSetupHints.SpaceBoundariesVisible);
         Assert.Equal(expectedViewSetupHints.SpacesVisible, actualViewSetupHints.SpacesVisible);
     }
     if (TestCompareUtilities.BothNotNullAndEmpty(expectedComponents.Visibility, actualComponents.Visibility, "Viewpoint.Components.Visibility"))
     {
         var expectedVisibility = expectedComponents.Visibility;
         var actualVisibility   = actualComponents.Visibility;
         Assert.Equal(expectedVisibility.DefaultVisibility, actualVisibility.DefaultVisibility);
         CompareComponentsList(expectedVisibility.Exceptions, actualVisibility.Exceptions);
     }
 }
예제 #2
0
        public static void CompareMarkup(Markup expectedMarkup, Markup actualMarkup, ZipArchive expectedArchive, ZipArchive actualArchive)
        {
            // Compare Header Section
            if (TestCompareUtilities.BothNotNullAndEmpty(expectedMarkup.Header, actualMarkup.Header, "Markup.Header"))
            {
                foreach (var currentHeaderEntry in expectedMarkup.Header)
                {
                    var foundExactlyOneMatchignEntryInActual = actualMarkup.Header
                                                               .Where(h => h.Date == currentHeaderEntry.Date)
                                                               .Where(h => h.Filename == currentHeaderEntry.Filename)
                                                               .Where(h => h.IfcProject == currentHeaderEntry.IfcProject)
                                                               .Where(h => h.IfcSpatialStructureElement == currentHeaderEntry.IfcSpatialStructureElement)
                                                               .Where(h => h.isExternal == currentHeaderEntry.isExternal)
                                                               .Where(h => h.Reference == currentHeaderEntry.Reference)
                                                               .Count() == 1;

                    Assert.True(foundExactlyOneMatchignEntryInActual, "Found not matching header entry in actual file.");
                }

                // Check that the both sections contain the same number of entries
                Assert.Equal(expectedMarkup.Header.Count, actualMarkup.Header.Count);
            }

            CompareComments(expectedMarkup.Comment, actualMarkup.Comment);

            if (TestCompareUtilities.BothNotNullAndEmpty(expectedMarkup.Viewpoints, actualMarkup.Viewpoints, "Markup.Viewpoints"))
            {
                CompareViewpoints(expectedMarkup.Viewpoints, actualMarkup.Viewpoints, expectedArchive, actualArchive, expectedMarkup.Topic.Guid);
            }

            if (TestCompareUtilities.BothNotNullAndEmpty(expectedMarkup.Topic, actualMarkup.Topic, "Markup.Topic"))
            {
                CompareTopic(expectedMarkup.Topic, actualMarkup.Topic);
            }
        }
예제 #3
0
        /// <summary>
        ///     Will compare the project and version descriptions within the file
        /// </summary>
        /// <param name="expectedContainer"></param>
        /// <param name="actualContainer"></param>
        public static void CompareProjectAndVersion(BCFv21Container expectedContainer, BCFv21Container actualContainer)
        {
            // Compare project
            if (TestCompareUtilities.BothNotNullAndEmpty(expectedContainer.BcfProject, actualContainer.BcfProject, "BCFProject"))
            {
                if (TestCompareUtilities.BothNotNullAndEmpty(expectedContainer.BcfProject.Project, actualContainer.BcfProject.Project, "BCFProject.Project"))
                {
                    Assert.Equal(expectedContainer.BcfProject.Project.Name, actualContainer.BcfProject.Project.Name);
                    Assert.Equal(expectedContainer.BcfProject.Project.ProjectId, actualContainer.BcfProject.Project.ProjectId);
                }
                Assert.Equal(expectedContainer.BcfProject.ExtensionSchema, actualContainer.BcfProject.ExtensionSchema);
            }

            // Compare version
            if (TestCompareUtilities.BothNotNullAndEmpty(expectedContainer.BcfVersionInfo, actualContainer.BcfVersionInfo, "BCFVersionInfo"))
            {
                if (expectedContainer.BcfVersionInfo.VersionId.Contains("2.1"))
                {
                    Assert.Contains("2.1", actualContainer.BcfVersionInfo.VersionId);
                }
                else
                {
                    Assert.True(false, "Unrecognized VersionId");
                }
            }
        }
예제 #4
0
 public static void CompareProjectExtensions(BCFv21Container expectedContainer, BCFv21Container actualContainer)
 {
     if (TestCompareUtilities.BothNotNullAndEmpty(expectedContainer.ProjectExtensions, actualContainer.ProjectExtensions, "ProjectExtensions"))
     {
         CompareStringList(expectedContainer.ProjectExtensions.SnippetType, actualContainer.ProjectExtensions.SnippetType, "SnippetType");
         CompareStringList(expectedContainer.ProjectExtensions.Priority, actualContainer.ProjectExtensions.Priority, "Priority");
         CompareStringList(expectedContainer.ProjectExtensions.TopicStatus, actualContainer.ProjectExtensions.TopicStatus, "TopicStatus");
         CompareStringList(expectedContainer.ProjectExtensions.TopicType, actualContainer.ProjectExtensions.TopicType, "TopicType");
         CompareStringList(expectedContainer.ProjectExtensions.UserIdType, actualContainer.ProjectExtensions.UserIdType, "UserIdType");
         CompareStringList(expectedContainer.ProjectExtensions.TopicLabel, actualContainer.ProjectExtensions.TopicLabel, "TopicLabel");
     }
 }
예제 #5
0
        /// <summary>
        /// </summary>
        /// <param name="expectedViewpoint"></param>
        /// <param name="actualViewpoint"></param>
        /// <param name="originatesFromApiConversion">If true, Bitmaps are not compared since the API does not support them</param>
        public static void CompareSingleViewpoints(VisualizationInfo expectedViewpoint, VisualizationInfo actualViewpoint, bool originatesFromApiConversion)
        {
            Assert.Equal(expectedViewpoint.Guid, actualViewpoint.Guid);

            // Compare Bitmaps
            if (!originatesFromApiConversion && TestCompareUtilities.BothNotNullAndEmpty(expectedViewpoint.Bitmap, actualViewpoint.Bitmap, "Viewpoint.Bitmaps"))
            {
                Assert.Equal(expectedViewpoint.Bitmap.Count, actualViewpoint.Bitmap.Count);
                foreach (var expectedBitmap in expectedViewpoint.Bitmap)
                {
                    var actualBitmap = actualViewpoint.Bitmap
                                       .Where(b => b.Bitmap == expectedBitmap.Bitmap)
                                       .Where(b => b.Height == expectedBitmap.Height)
                                       .Where(b => b.Location.X == expectedBitmap.Location.X)
                                       .Where(b => b.Location.Y == expectedBitmap.Location.Y)
                                       .Where(b => b.Location.Z == expectedBitmap.Location.Z)
                                       .Where(b => b.Normal.X == expectedBitmap.Normal.X)
                                       .Where(b => b.Normal.Y == expectedBitmap.Normal.Y)
                                       .Where(b => b.Normal.Z == expectedBitmap.Normal.Z)
                                       .Where(b => b.Reference == expectedBitmap.Reference)
                                       .Where(b => b.Up.X == expectedBitmap.Up.X)
                                       .Where(b => b.Up.Y == expectedBitmap.Up.Y)
                                       .Where(b => b.Up.Z == expectedBitmap.Up.Z)
                                       .FirstOrDefault();
                    Assert.NotNull(actualViewpoint);
                }
            }

            // Compare Components
            if (TestCompareUtilities.BothNotNullAndEmpty(expectedViewpoint.Components, actualViewpoint.Components, "Viewpoint.Components"))
            {
                CompareComponents(expectedViewpoint.Components, actualViewpoint.Components);
            }

            // Compare Lines
            if (TestCompareUtilities.BothNotNullAndEmpty(expectedViewpoint.Lines, actualViewpoint.Lines, "Viewpoint.Lines"))
            {
                foreach (var expectedLine in expectedViewpoint.Lines)
                {
                    var actualLine = actualViewpoint.Lines
                                     .Where(l => l.EndPoint.X == expectedLine.EndPoint.X)
                                     .Where(l => l.EndPoint.Y == expectedLine.EndPoint.Y)
                                     .Where(l => l.EndPoint.Z == expectedLine.EndPoint.Z)
                                     .Where(l => l.StartPoint.X == expectedLine.StartPoint.X)
                                     .Where(l => l.StartPoint.Y == expectedLine.StartPoint.Y)
                                     .Where(l => l.StartPoint.Z == expectedLine.StartPoint.Z)
                                     .FirstOrDefault();
                    Assert.NotNull(actualLine);
                }
            }

            // Compare Clipping planes
            if (TestCompareUtilities.BothNotNullAndEmpty(expectedViewpoint.ClippingPlanes, actualViewpoint.ClippingPlanes, "Viewpoint.ClippingPlanes"))
            {
                foreach (var expectedPlane in expectedViewpoint.ClippingPlanes)
                {
                    var actualPlane = actualViewpoint.ClippingPlanes
                                      .Where(c => c.Direction.X == expectedPlane.Direction.X)
                                      .Where(c => c.Direction.Y == expectedPlane.Direction.Y)
                                      .Where(c => c.Direction.Z == expectedPlane.Direction.Z)
                                      .Where(c => c.Location.X == expectedPlane.Location.X)
                                      .Where(c => c.Location.Y == expectedPlane.Location.Y)
                                      .Where(c => c.Location.Z == expectedPlane.Location.Z)
                                      .FirstOrDefault();
                    Assert.NotNull(actualPlane);
                }
            }

            // Compare OrthogonalCamera
            if (TestCompareUtilities.BothNotNullAndEmpty(expectedViewpoint.OrthogonalCamera, actualViewpoint.OrthogonalCamera, "Viewpoint.OrthogonalCamera"))
            {
                CompareOrthogonalCameras(expectedViewpoint.OrthogonalCamera, actualViewpoint.OrthogonalCamera);
            }
            // Compare PerspectiveCamera
            if (TestCompareUtilities.BothNotNullAndEmpty(expectedViewpoint.PerspectiveCamera, actualViewpoint.PerspectiveCamera, "Viewpoint.PerspectiveCamera"))
            {
                ComparePerspectiveCameras(expectedViewpoint.PerspectiveCamera, actualViewpoint.PerspectiveCamera);
            }
        }
예제 #6
0
        public static void CompareTopic(Topic expectedTopic, Topic actualTopic)
        {
            Assert.Equal(expectedTopic.AssignedTo, actualTopic.AssignedTo);

            // Compare Snippet
            if (TestCompareUtilities.BothNotNullAndEmpty(expectedTopic.BimSnippet, actualTopic.BimSnippet, "Markup.BimSnippet"))
            {
                CompareBimSnippet(expectedTopic.BimSnippet, actualTopic.BimSnippet);
            }

            // Compare document references
            if (TestCompareUtilities.BothNotNullAndEmpty(expectedTopic.DocumentReference, actualTopic.DocumentReference, "Markup.DocumentReferences"))
            {
                Assert.Equal(expectedTopic.DocumentReference.Count, actualTopic.DocumentReference.Count);

                foreach (var expectedDocumentReference in expectedTopic.DocumentReference)
                {
                    // Find the matching document reference in the actual topic
                    var actualDocumentReference = actualTopic.DocumentReference
                                                  .Where(d => d.Description == expectedDocumentReference.Description)
                                                  .Where(d => d.Guid == expectedDocumentReference.Guid)
                                                  .Where(d => d.isExternal == expectedDocumentReference.isExternal)
                                                  .Where(d => d.ReferencedDocument == expectedDocumentReference.ReferencedDocument)
                                                  .FirstOrDefault();
                    Assert.NotNull(actualDocumentReference);
                }
            }

            // Check labels
            if (TestCompareUtilities.BothNotNullAndEmpty(expectedTopic.Labels, actualTopic.Labels, "Markup.Labels"))
            {
                Assert.Equal(expectedTopic.Labels.Count, actualTopic.Labels.Count);
                foreach (var expectedLabel in expectedTopic.Labels)
                {
                    Assert.Contains(expectedLabel, actualTopic.Labels);
                }
            }

            // Check related topics
            if (TestCompareUtilities.BothNotNullAndEmpty(expectedTopic.RelatedTopic, actualTopic.RelatedTopic, "Markup.RelatedTopics"))
            {
                Assert.Equal(expectedTopic.RelatedTopic.Count, actualTopic.RelatedTopic.Count);
                foreach (var expectedRelatedTopic in expectedTopic.RelatedTopic)
                {
                    var actualRelatedTopic = actualTopic.RelatedTopic
                                             .Where(r => r.Guid == expectedRelatedTopic.Guid)
                                             .FirstOrDefault();
                    Assert.NotNull(actualRelatedTopic);
                }
            }

            Assert.Equal(expectedTopic.CreationAuthor, actualTopic.CreationAuthor);
            Assert.True((int)(expectedTopic.CreationDate - actualTopic.CreationDate).TotalSeconds < 5);
            Assert.True(expectedTopic.ShouldSerializeCreationDate());
            Assert.True(actualTopic.ShouldSerializeCreationDate());

            if (!(string.IsNullOrWhiteSpace(expectedTopic.Description) && string.IsNullOrWhiteSpace(actualTopic.Description)))
            {
                Assert.Equal(expectedTopic.Description, actualTopic.Description);
            }
            Assert.Equal(expectedTopic.Guid, actualTopic.Guid);

            if (expectedTopic.Index != actualTopic.Index)
            {
                Assert.True(false, "Index does not match");
            }

            Assert.Equal(expectedTopic.ModifiedAuthor, actualTopic.ModifiedAuthor);
            Assert.Equal(expectedTopic.ModifiedDate, actualTopic.ModifiedDate);
            Assert.Equal(expectedTopic.ModifiedDateSpecified, actualTopic.ModifiedDateSpecified);
            Assert.Equal(expectedTopic.Priority, actualTopic.Priority);
            Assert.Equal(expectedTopic.ReferenceLink, actualTopic.ReferenceLink);
            Assert.Equal(expectedTopic.Title, actualTopic.Title);
            Assert.Equal(expectedTopic.TopicStatus, actualTopic.TopicStatus);
            Assert.Equal(expectedTopic.TopicType, actualTopic.TopicType);
        }