Skip to content

Commit 7eb0939

Browse files
authored
Merge pull request #3 from Augurk/feature/embed-images
Feature/embed images
2 parents 310a49c + a096f1d commit 7eb0939

32 files changed

Lines changed: 752 additions & 39 deletions

GitVersion.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
next-version: 2.3.2
1+
next-version: 2.4.0
22
branches: {}
33
ignore:
44
sha: []
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{2D5857CB-96F4-423A-9644-C79172792EB9}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<AppDesignerFolder>Properties</AppDesignerFolder>
9+
<RootNamespace>Augurk.CommandLine.UnitTest</RootNamespace>
10+
<AssemblyName>Augurk.CommandLine.UnitTest</AssemblyName>
11+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
15+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
16+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
17+
<IsCodedUITest>False</IsCodedUITest>
18+
<TestProjectType>UnitTest</TestProjectType>
19+
<TargetFrameworkProfile />
20+
</PropertyGroup>
21+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
22+
<DebugSymbols>true</DebugSymbols>
23+
<DebugType>full</DebugType>
24+
<Optimize>false</Optimize>
25+
<OutputPath>bin\Debug\</OutputPath>
26+
<DefineConstants>DEBUG;TRACE</DefineConstants>
27+
<ErrorReport>prompt</ErrorReport>
28+
<WarningLevel>4</WarningLevel>
29+
</PropertyGroup>
30+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
31+
<DebugType>pdbonly</DebugType>
32+
<Optimize>true</Optimize>
33+
<OutputPath>bin\Release\</OutputPath>
34+
<DefineConstants>TRACE</DefineConstants>
35+
<ErrorReport>prompt</ErrorReport>
36+
<WarningLevel>4</WarningLevel>
37+
</PropertyGroup>
38+
<ItemGroup>
39+
<Reference Include="System" />
40+
</ItemGroup>
41+
<Choose>
42+
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
43+
<ItemGroup>
44+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
45+
</ItemGroup>
46+
</When>
47+
<Otherwise>
48+
<ItemGroup>
49+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
50+
</ItemGroup>
51+
</Otherwise>
52+
</Choose>
53+
<ItemGroup>
54+
<Compile Include="MarkdownExtensionsTests.cs" />
55+
<Compile Include="Properties\AssemblyInfo.cs" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<ProjectReference Include="..\Augurk.CommandLine\Augurk.CommandLine.csproj">
59+
<Project>{3d0e1e13-76c3-4cb7-b864-0f3d93672144}</Project>
60+
<Name>Augurk.CommandLine</Name>
61+
</ProjectReference>
62+
</ItemGroup>
63+
<ItemGroup>
64+
<Content Include="TestData\Image1.png">
65+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
66+
</Content>
67+
<Content Include="TestData\Image2.png">
68+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
69+
</Content>
70+
<Content Include="TestData\Image3.jpg">
71+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
72+
</Content>
73+
</ItemGroup>
74+
<Choose>
75+
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
76+
<ItemGroup>
77+
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
78+
<Private>False</Private>
79+
</Reference>
80+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
81+
<Private>False</Private>
82+
</Reference>
83+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
84+
<Private>False</Private>
85+
</Reference>
86+
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
87+
<Private>False</Private>
88+
</Reference>
89+
</ItemGroup>
90+
</When>
91+
</Choose>
92+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
93+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
94+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
95+
Other similar extension points exist, see Microsoft.Common.targets.
96+
<Target Name="BeforeBuild">
97+
</Target>
98+
<Target Name="AfterBuild">
99+
</Target>
100+
-->
101+
</Project>
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
Copyright 2017, Augurk
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
using System;
18+
using Augurk.CommandLine.Extensions;
19+
using Microsoft.VisualStudio.TestTools.UnitTesting;
20+
21+
namespace Augurk.CommandLine.UnitTest
22+
{
23+
[TestClass]
24+
public class MarkdownExtenionsTests
25+
{
26+
[TestMethod]
27+
[DeploymentItem(@"TestData\Image1.png")]
28+
public void EmbedSingleImage()
29+
{
30+
// Arrange
31+
string inputMarkdown = "text ![alt for image1.png](image1.png \"title for image1.png\") text, bla [link](image1.png)";
32+
string expectedMarkdown = "text ![alt for image1.png](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd" +
33+
"1PeAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwwAADsMBx2+oZAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQ" +
34+
"uMC4xMkMEa+wAAAAMSURBVBhXY/jPwAAAAwEBAGMkVdMAAAAASUVORK5CYII= \"title for image1.png\") te" +
35+
"xt, bla [link](image1.png)";
36+
37+
// Act
38+
string actualMarkdown = inputMarkdown.EmbedImages();
39+
40+
// Assert
41+
Assert.AreEqual(expectedMarkdown, actualMarkdown);
42+
}
43+
44+
[TestMethod]
45+
[DeploymentItem("TestData")]
46+
public void EmbedMultipleImages()
47+
{
48+
// Arrange
49+
string inputMarkdown = "![alt](image1.png \"title\") ![alt](image2.png) ![alt](image3.jpg \"title\")";
50+
string expectedMarkdown = "![alt](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAABGdBTUEAALGPC" +
51+
"/xhBQAAAAlwSFlzAAAOwwAADsMBx2+oZAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMkMEa+wAAAAMSUR" +
52+
"BVBhXY/jPwAAAAwEBAGMkVdMAAAAASUVORK5CYII= \"title\") ![alt](data:image/png;base64,iVBORw0K" +
53+
"GgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwwAADsMBx2+oZAAAAB" +
54+
"l0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMkMEa+wAAAAMSURBVBhXY2BQ+w8AAU8BJr37vWkAAAAASUVORK5C" +
55+
"YII=) ![alt](data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBoRXhpZgAATU0AKgAAAAgABA" +
56+
"EaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAARAAAATgAAAAAAAABgAAAAAQAAAGAAAAAB" +
57+
"cGFpbnQubmV0IDQuMC4xMgAA/9sAQwABAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ" +
58+
"EBAQEBAQEBAQEBAQEBAQEBAQEB/9sAQwEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB" +
59+
"AQEBAQEBAQEBAQEBAQEBAQEBAQEB/8AAEQgAAQABAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQ" +
60+
"YHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYX" +
61+
"GBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6" +
62+
"Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEB" +
63+
"AQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQ" +
64+
"kjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWG" +
65+
"h4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v" +
66+
"/aAAwDAQACEQMRAD8A/WCiiiv+Pc/51z//2Q== \"title\")";
67+
68+
// Act
69+
string actualMarkdown = inputMarkdown.EmbedImages();
70+
71+
// Assert
72+
Assert.AreEqual(expectedMarkdown, actualMarkdown);
73+
}
74+
75+
[TestMethod]
76+
public void EmbedImageThatDoesNotExist()
77+
{
78+
// Arrange
79+
string inputMarkdown = "text ![alt for image4.png](image4.png \"title for image4.png\") text, bla [link](image4.png)";
80+
81+
// Act
82+
string actualMarkdown = inputMarkdown.EmbedImages();
83+
84+
// Assert
85+
// As nothing should happen, compare it against the input
86+
Assert.AreEqual(inputMarkdown, actualMarkdown);
87+
}
88+
89+
[TestMethod]
90+
public void EmbedImageFromTheWeb()
91+
{
92+
// Arrange
93+
string inputMarkdown = "![alt](https://augurk.github.io/Augurk/img/icon16.png)";
94+
95+
// Act
96+
string actualMarkdown = inputMarkdown.EmbedImages();
97+
98+
// Assert
99+
// As nothing should happen, compare it against the input
100+
Assert.AreEqual(inputMarkdown, actualMarkdown);
101+
}
102+
103+
[TestMethod]
104+
public void EmbedImageWithRandomText()
105+
{
106+
// Arrange
107+
string inputMarkdown = "![alt](There should probably have been a filename here. \"Title which will not be shown.\")";
108+
109+
// Act
110+
string actualMarkdown = inputMarkdown.EmbedImages();
111+
112+
// Assert
113+
// As nothing should happen, compare it against the input
114+
Assert.AreEqual(inputMarkdown, actualMarkdown);
115+
}
116+
}
117+
}
118+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Augurk.CommandLine.UnitTest")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Augurk.CommandLine.UnitTest")]
13+
[assembly: AssemblyCopyright("Copyright © 2017")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("2d5857cb-96f4-423a-9644-c79172792eb9")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
156 Bytes
Loading
156 Bytes
Loading
742 Bytes
Loading

src/Augurk.CommandLine.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1111
..\GitVersion.yml = ..\GitVersion.yml
1212
EndProjectSection
1313
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Augurk.CommandLine.UnitTest", "Augurk.CommandLine.UnitTest\Augurk.CommandLine.UnitTest.csproj", "{2D5857CB-96F4-423A-9644-C79172792EB9}"
15+
EndProject
1416
Global
1517
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1618
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
2123
{3D0E1E13-76C3-4CB7-B864-0F3D93672144}.Debug|Any CPU.Build.0 = Debug|Any CPU
2224
{3D0E1E13-76C3-4CB7-B864-0F3D93672144}.Release|Any CPU.ActiveCfg = Release|Any CPU
2325
{3D0E1E13-76C3-4CB7-B864-0F3D93672144}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{2D5857CB-96F4-423A-9644-C79172792EB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{2D5857CB-96F4-423A-9644-C79172792EB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{2D5857CB-96F4-423A-9644-C79172792EB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{2D5857CB-96F4-423A-9644-C79172792EB9}.Release|Any CPU.Build.0 = Release|Any CPU
2430
EndGlobalSection
2531
GlobalSection(SolutionProperties) = preSolution
2632
HideSolutionNode = FALSE

src/Augurk.CommandLine/App.config

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2017, Augurk
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
217
<configuration>
318
<configSections>
419
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />

src/Augurk.CommandLine/Augurk.CommandLine.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<Reference Include="System" />
5959
<Reference Include="System.ComponentModel.Composition" />
6060
<Reference Include="System.Core" />
61+
<Reference Include="System.Drawing" />
6162
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6263
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
6364
<Private>True</Private>
@@ -100,6 +101,7 @@
100101
<Compile Include="Entities\StepKeyword.cs" />
101102
<Compile Include="Entities\Table.cs" />
102103
<Compile Include="Extensions\CompositionContainerExtensions.cs" />
104+
<Compile Include="Extensions\MarkdownExtensions.cs" />
103105
<Compile Include="Extensions\SpecFlowEntityExtensions.cs" />
104106
<Compile Include="Options\DeleteOptions.cs" />
105107
<Compile Include="Options\GlobalOptions.cs" />

0 commit comments

Comments
 (0)