예제 #1
0
        public void ReadExtensionSchema()
        {
            using (var memStream = new MemoryStream())
            {
                CreatedContainer.WriteStream(memStream);
                memStream.Position = 0;

                var readContainer = BCFv21Container.ReadStream(memStream);

                Assert.NotNull(readContainer.ProjectExtensions);
            }
        }
예제 #2
0
        public void WriteReadAgainAndCompare()
        {
            using (var memStream = new MemoryStream())
            {
                CreatedContainer.WriteStream(memStream);
                memStream.Position = 0;

                var readContainer = BCFv21Container.ReadStream(memStream);

                var readMemStream = new MemoryStream();
                readContainer.WriteStream(readMemStream);
                var writtenZipArchive = new ZipArchive(readMemStream);

                CompareTool.CompareContainers(CreatedContainer, readContainer, CreatedArchive, writtenZipArchive);
            }
        }
예제 #3
0
            public void Simple_WriteSingleTopic()
            {
                var testContainerInstance = new BCFv21Container();

                testContainerInstance.ProjectExtensions = MockExtensions();

                testContainerInstance.Topics.Add(MockBCFv2_WithValues());

                using (var memStream = new MemoryStream())
                {
                    testContainerInstance.WriteStream(memStream);
                    Assert.True(memStream.Length > 0);
                }
            }
예제 #4
0
        public static ZipArchive ReturnAndWriteIfRequired(BCFv21Container container, string testCaseName, string readmeText)
        {
            var memStream = new MemoryStream();

            container.WriteStream(memStream);
            memStream.Position = 0;
            var createdArchive = new ZipArchive(memStream, ZipArchiveMode.Read);

            if (string.IsNullOrWhiteSpace(FOLDERNAME))
            {
                return(createdArchive);
            }
            if (!Directory.Exists(FOLDERNAME + @"\" + testCaseName))
            {
                Directory.CreateDirectory(FOLDERNAME + @"\" + testCaseName);
            }
            var filePath = FOLDERNAME + @"\" + testCaseName + @"\" + testCaseName + ".bcf";

            using (var fileStream = File.Create(filePath))
            {
                container.WriteStream(fileStream);
            }
            filePath = FOLDERNAME + @"\" + testCaseName + @"\Readme.md";
            using (var streamWriter = new StreamWriter(File.Create(filePath)))
            {
                readmeText = readmeText.TrimEnd()
                             + Environment.NewLine
                             + Environment.NewLine
                             + "---"
                             + Environment.NewLine
                             + Environment.NewLine
                             + $"Created by iabi at {DateTime.UtcNow:dd.MM.yyyy HH:mm} (UTC)";
                streamWriter.Write(readmeText);
            }
            return(createdArchive);
        }
예제 #5
0
                public void SimpleExtensions()
                {
                    var originalContainer = new BCFv21Container();

                    originalContainer.ProjectExtensions = new ProjectExtensions();
                    originalContainer.ProjectExtensions.UserIdType.Add("Some user");
                    using (var memStream = new MemoryStream())
                    {
                        originalContainer.WriteStream(memStream);
                        var readContainer = BCFv21Container.ReadStream(memStream);
                        Assert.NotNull(readContainer.ProjectExtensions);
                        Assert.Equal("Some user", readContainer.ProjectExtensions.UserIdType.First());
                        Assert.Equal("extensions.xsd", readContainer.BcfProject.ExtensionSchema);
                    }
                }
예제 #6
0
        /// <summary>
        /// </summary>
        /// <param name="expectedContainer"></param>
        /// <param name="actualContainer"></param>
        /// <param name="expectedArchive"></param>
        /// <param name="actualArchive"></param>
        /// <param name="originatesFromApiConversion">If true, Bitmaps are not compared since the API does not support them</param>
        public static void CompareContainers(BCFv21Container expectedContainer, BCFv21Container actualContainer, ZipArchive expectedArchive = null, ZipArchive actualArchive = null, bool originatesFromApiConversion = false)
        {
            CompareProjectAndVersion(expectedContainer, actualContainer);
            CompareFileAttachments(expectedContainer, actualContainer);
            CompareProjectExtensions(expectedContainer, actualContainer);

            if (expectedArchive == null && actualArchive == null)
            {
                using (var memStream01 = new MemoryStream())
                {
                    expectedContainer.WriteStream(memStream01);
                    expectedArchive = new ZipArchive(memStream01);
                    using (var memStream02 = new MemoryStream())
                    {
                        expectedContainer.WriteStream(memStream02);
                        actualArchive = new ZipArchive(memStream02);
                        TopicsCompareTool.CompareAllTopics(expectedContainer, actualContainer, expectedArchive, actualArchive, originatesFromApiConversion);
                        return;
                    }
                }
            }

            TopicsCompareTool.CompareAllTopics(expectedContainer, actualContainer, expectedArchive, actualArchive, originatesFromApiConversion);
        }
예제 #7
0
            public void AppendSnapshotInfoToMarkup()
            {
                var instance = new BCFv21Container();

                instance.Topics.Add(new BCFTopic());
                instance.Topics.First().Viewpoints.Add(new VisualizationInfo());
                instance.Topics.First().AddOrUpdateSnapshot(instance.Topics.First().Viewpoints.First().Guid, new byte[] { 15, 15, 15, 15, 15, 15 });

                using (var memStream = new MemoryStream())
                {
                    instance.WriteStream(memStream);
                    memStream.Position = 0;
                    var readAgain = BCFv21Container.ReadStream(memStream);
                    Assert.False(string.IsNullOrWhiteSpace(readAgain.Topics.First().Markup.Viewpoints.First().Viewpoint));
                    Assert.True(readAgain.Topics.First().ViewpointSnapshots.Any());
                }
            }
예제 #8
0
            public void Simple_WriteSingleTopic_Extensions()
            {
                var testContainerInstance = new BCFv21Container();

                testContainerInstance.ProjectExtensions = MockExtensions();

                testContainerInstance.Topics.Add(new BCFTopic());
                testContainerInstance.Topics[0].Markup             = new Markup();
                testContainerInstance.Topics[0].Markup.Topic       = new Topic();
                testContainerInstance.Topics[0].Markup.Topic.Title = "Sample with extensions.";
                testContainerInstance.Topics[0].Markup.Topic.Guid  = Guid.NewGuid().ToString();

                using (var memStream = new MemoryStream())
                {
                    testContainerInstance.WriteStream(memStream);
                    Assert.True(memStream.Length > 0);

                    memStream.Position = 0;
                    var archive         = new ZipArchive(memStream);
                    var extensionsEntry = archive.Entries.FirstOrDefault(e => e.FullName == "extensions.xsd");
                    Assert.NotNull(extensionsEntry);
                }
            }