public void ReadExtensionSchema() { using (var memStream = new MemoryStream()) { CreatedContainer.WriteStream(memStream); memStream.Position = 0; var readContainer = BCFv21Container.ReadStream(memStream); Assert.NotNull(readContainer.ProjectExtensions); } }
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); } }
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); } }
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); }
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); } }
/// <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); }
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()); } }
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); } }