Example #1
0
        public static void CompareMarkup(Markup expectedMarkup, Markup actualMarkup, ZipArchive expectedArchive, ZipArchive actualArchive)
        {
            // Compare Header Section
            if (TestCompareUtilities.BothNotNull(expectedMarkup.Header, actualMarkup.Header, "Markup.Header"))
            {
                foreach (var currentHeaderEntry in expectedMarkup.Header)
                {
                    var foundExactlyOneMatchignEntryInActual = actualMarkup.Header
                                                               .Where(curr => curr.Date == currentHeaderEntry.Date)
                                                               .Where(curr => curr.Filename == currentHeaderEntry.Filename)
                                                               .Where(curr => curr.IfcProject == currentHeaderEntry.IfcProject)
                                                               .Where(curr => curr.IfcSpatialStructureElement == currentHeaderEntry.IfcSpatialStructureElement)
                                                               .Where(curr => curr.isExternal == currentHeaderEntry.isExternal)
                                                               .Where(curr => curr.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.BothNotNull(expectedMarkup.Viewpoints, actualMarkup.Viewpoints, "Markup.Viewpoints"))
            {
                CompareViewpoints(expectedMarkup.Viewpoints, actualMarkup.Viewpoints, expectedArchive, actualArchive, expectedMarkup.Topic.Guid);
            }

            if (TestCompareUtilities.BothNotNull(expectedMarkup.Topic, actualMarkup.Topic, "Markup.Topic"))
            {
                CompareTopic(expectedMarkup.Topic, actualMarkup.Topic);
            }
        }
Example #2
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(BCFv2Container expectedContainer, BCFv2Container actualContainer)
        {
            // Compare project
            if (TestCompareUtilities.BothNotNull(expectedContainer.BcfProject, actualContainer.BcfProject, "BCFProject"))
            {
                if (TestCompareUtilities.BothNotNull(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.BothNotNull(expectedContainer.BcfVersionInfo, actualContainer.BcfVersionInfo, "BCFVersionInfo"))
            {
                if (expectedContainer.BcfVersionInfo.VersionId.Contains("2.0"))
                {
                    Assert.Contains("2.0", actualContainer.BcfVersionInfo.VersionId);
                }
                else
                {
                    Assert.True(false, "Unrecognized VersionId");
                }
            }
        }
Example #3
0
 public static void CompareProjectExtensions(BCFv2Container expectedContainer, BCFv2Container actualContainer)
 {
     if (TestCompareUtilities.BothNotNull(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");
     }
 }
Example #4
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.BothNotNull(expectedViewpoint.Bitmaps, actualViewpoint.Bitmaps, "Viewpoint.Bitmaps"))
            {
                Assert.Equal(expectedViewpoint.Bitmaps.Count, actualViewpoint.Bitmaps.Count);
                foreach (var expectedBitmap in expectedViewpoint.Bitmaps)
                {
                    var actualBitmap = actualViewpoint.Bitmaps
                                       .Where(curr => curr.Bitmap == expectedBitmap.Bitmap)
                                       .Where(curr => curr.Height == expectedBitmap.Height)
                                       .Where(curr => curr.Location.X == expectedBitmap.Location.X)
                                       .Where(curr => curr.Location.Y == expectedBitmap.Location.Y)
                                       .Where(curr => curr.Location.Z == expectedBitmap.Location.Z)
                                       .Where(curr => curr.Normal.X == expectedBitmap.Normal.X)
                                       .Where(curr => curr.Normal.Y == expectedBitmap.Normal.Y)
                                       .Where(curr => curr.Normal.Z == expectedBitmap.Normal.Z)
                                       .Where(curr => curr.Reference == expectedBitmap.Reference)
                                       .Where(curr => curr.Up.X == expectedBitmap.Up.X)
                                       .Where(curr => curr.Up.Y == expectedBitmap.Up.Y)
                                       .Where(curr => curr.Up.Z == expectedBitmap.Up.Z)
                                       .FirstOrDefault();
                    Assert.NotNull(actualViewpoint);
                }
            }

            // Compare Components
            if (TestCompareUtilities.BothNotNull(expectedViewpoint.Components, actualViewpoint.Components, "Viewpoint.Components"))
            {
                if (expectedViewpoint.Components.Count == 1 && actualViewpoint.Components.Count == 1)
                {
                    var expectedComponent = expectedViewpoint.Components.First();
                    var actualComponent   = actualViewpoint.Components.First();

                    Assert.Equal(expectedComponent.AuthoringToolId, actualComponent.AuthoringToolId);
                    Assert.True((expectedComponent.Color == null && actualComponent.Color == null) || expectedComponent.Color.SequenceEqual(actualComponent.Color), "Color");
                    Assert.Equal(expectedComponent.IfcGuid, actualComponent.IfcGuid);
                    Assert.Equal(expectedComponent.OriginatingSystem, actualComponent.OriginatingSystem);
                    Assert.Equal(expectedComponent.Selected, actualComponent.Selected);
                    Assert.Equal(expectedComponent.Visible, actualComponent.Visible);
                }
                else
                {
                    foreach (var currentComponent in expectedViewpoint.Components)
                    {
                        var actualComponent = actualViewpoint.Components
                                              .Where(curr => curr.AuthoringToolId == currentComponent.AuthoringToolId)
                                              .Where(curr => (curr.Color == null && currentComponent.Color == null) || curr.Color.SequenceEqual(currentComponent.Color))
                                              .Where(curr => curr.IfcGuid == currentComponent.IfcGuid)
                                              .Where(curr => curr.OriginatingSystem == currentComponent.OriginatingSystem)
                                              .Where(curr => curr.Selected == currentComponent.Selected)
                                              .Where(curr => curr.Visible == currentComponent.Visible)
                                              .FirstOrDefault();

                        Assert.NotNull(actualComponent);
                    }
                }
            }

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

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

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

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

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

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

            // Check labels
            if (TestCompareUtilities.BothNotNull(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.BothNotNull(expectedTopic.RelatedTopics, actualTopic.RelatedTopics, "Markup.RelatedTopics"))
            {
                Assert.Equal(expectedTopic.RelatedTopics.Count, actualTopic.RelatedTopics.Count);
                foreach (var expectedRelatedTopic in expectedTopic.RelatedTopics)
                {
                    var actualRelatedTopic = actualTopic.RelatedTopics
                                             .Where(curr => curr.Guid == expectedRelatedTopic.Guid)
                                             .FirstOrDefault();
                    Assert.NotNull(actualRelatedTopic);
                }
            }

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

            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)
            {
                if (!(expectedTopic.Index != null && expectedTopic.Index.Trim() == "0" && string.IsNullOrWhiteSpace(actualTopic.Index) ||
                      actualTopic.Index != null && actualTopic.Index.Trim() == "0" && string.IsNullOrWhiteSpace(expectedTopic.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);
        }