diff --git a/src/managed/OpenLiveWriter.PostEditor/Tables/TableEditor.cs b/src/managed/OpenLiveWriter.PostEditor/Tables/TableEditor.cs
index 64bb1ce2..a4ca2b2e 100644
--- a/src/managed/OpenLiveWriter.PostEditor/Tables/TableEditor.cs
+++ b/src/managed/OpenLiveWriter.PostEditor/Tables/TableEditor.cs
@@ -45,7 +45,8 @@ namespace OpenLiveWriter.PostEditor.Tables
// table properties
TableProperties properties = parameters.Properties;
StringBuilder propertiesString = new StringBuilder();
- propertiesString.AppendFormat("width=\"{0}\"", properties.Width);
+ if (properties.Width.Units != PixelPercentUnits.Undefined)
+ propertiesString.AppendFormat("width=\"{0}\"", properties.Width);
if (properties.BorderSize != String.Empty)
propertiesString.AppendFormat(" border=\"{0}\"", properties.BorderSize);
if (properties.CellPadding != String.Empty)
diff --git a/src/managed/OpenLiveWriter.Tests/OpenLiveWriter.Tests.csproj b/src/managed/OpenLiveWriter.Tests/OpenLiveWriter.Tests.csproj
new file mode 100644
index 00000000..7005415f
--- /dev/null
+++ b/src/managed/OpenLiveWriter.Tests/OpenLiveWriter.Tests.csproj
@@ -0,0 +1,139 @@
+
+
+
+ Debug
+ AnyCPU
+ {B3E5F002-AFD0-427A-BCBB-B1E4FB6FC92E}
+ Library
+ Properties
+ OpenLiveWriter.Tests
+ OpenLiveWriter.Tests
+ v4.5.2
+ 512
+ {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 10.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+ $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
+ False
+ UnitTest
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ x86
+ true
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+ x86
+ true
+
+
+
+ ..\packages\ApprovalTests.3.0.10\lib\net40\ApprovalTests.dll
+ True
+
+
+ ..\packages\ApprovalUtilities.3.0.10\lib\net45\ApprovalUtilities.dll
+ True
+
+
+ ..\packages\ApprovalUtilities.3.0.10\lib\net45\ApprovalUtilities.Net45.dll
+ True
+
+
+ ..\packages\NUnit3TestAdapter.3.0.8-ctp-8\lib\Mono.Cecil.dll
+ False
+
+
+ ..\packages\NUnit3TestAdapter.3.0.8-ctp-8\lib\nunit.engine.dll
+ False
+
+
+ ..\packages\NUnit3TestAdapter.3.0.8-ctp-8\lib\nunit.engine.api.dll
+ False
+
+
+ ..\packages\NUnit.3.0.1\lib\net45\nunit.framework.dll
+ True
+
+
+ ..\packages\NUnit3TestAdapter.3.0.8-ctp-8\lib\NUnit3.TestAdapter.dll
+ False
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {eeee653a-90ce-44e2-b40e-22f747880cc0}
+ OpenLiveWriter.ApplicationFramework
+
+
+ {6A6872BC-67EF-4A42-A21A-30ECED376923}
+ OpenLiveWriter.HtmlEditor
+
+
+ {d6c9a393-e0b8-4548-b84b-f8b6fe2a5645}
+ OpenLiveWriter.PostEditor
+
+
+
+
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.Table100PercentWide3Rows4Columns.approved.html b/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.Table100PercentWide3Rows4Columns.approved.html
new file mode 100644
index 00000000..4add3db1
--- /dev/null
+++ b/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.Table100PercentWide3Rows4Columns.approved.html
@@ -0,0 +1,22 @@
+
+
+
+ |
+ |
+ |
+ |
+
+
+ |
+ |
+ |
+ |
+
+
+ |
+ |
+ |
+ |
+
+
+
\ No newline at end of file
diff --git a/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.Table400PixelsWide3Rows4Columns.approved.html b/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.Table400PixelsWide3Rows4Columns.approved.html
new file mode 100644
index 00000000..7930ce4d
--- /dev/null
+++ b/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.Table400PixelsWide3Rows4Columns.approved.html
@@ -0,0 +1,22 @@
+
+
+
+ |
+ |
+ |
+ |
+
+
+ |
+ |
+ |
+ |
+
+
+ |
+ |
+ |
+ |
+
+
+
\ No newline at end of file
diff --git a/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.TableNoWide3Rows4Columns.approved.html b/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.TableNoWide3Rows4Columns.approved.html
new file mode 100644
index 00000000..3d30fba1
--- /dev/null
+++ b/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.TableNoWide3Rows4Columns.approved.html
@@ -0,0 +1,22 @@
+
+
+
+ |
+ |
+ |
+ |
+
+
+ |
+ |
+ |
+ |
+
+
+ |
+ |
+ |
+ |
+
+
+
\ No newline at end of file
diff --git a/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.TableNoWide3Rows4ColumnsCellSpacingPadding.approved.html b/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.TableNoWide3Rows4ColumnsCellSpacingPadding.approved.html
new file mode 100644
index 00000000..109b30f0
--- /dev/null
+++ b/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.TableNoWide3Rows4ColumnsCellSpacingPadding.approved.html
@@ -0,0 +1,22 @@
+
+
+
+ |
+ |
+ |
+ |
+
+
+ |
+ |
+ |
+ |
+
+
+ |
+ |
+ |
+ |
+
+
+
\ No newline at end of file
diff --git a/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.cs b/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.cs
new file mode 100644
index 00000000..4c2c7f60
--- /dev/null
+++ b/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/InsertTableTests.cs
@@ -0,0 +1,89 @@
+using ApprovalTests;
+using ApprovalTests.Reporters;
+
+using NUnit.Framework;
+
+using OpenLiveWriter.PostEditor.Tables;
+
+namespace OpenLiveWriter.Tests.PostEditor.Tables
+{
+ [UseReporter(typeof(DiffReporter))]
+ [TestFixture]
+ public class InsertTableTests
+ {
+
+ [Test]
+ public void Table400PixelsWide3Rows4Columns()
+ {
+ // Arrange
+ var editor = new TestHtmlEditor();
+ TableProperties tableProperties = new TableProperties();
+ tableProperties.Width = new PixelPercent(400, PixelPercentUnits.Pixels);
+ int rows = 3;
+ int columns = 4;
+ TableCreationParameters tableCreationParamters = new TableCreationParameters(rows, columns, tableProperties);
+
+ // Act
+ TableEditor.InsertTable(editor, null, tableCreationParamters);
+
+ // Assert
+ Approvals.VerifyHtml(editor.Html);
+ }
+
+ [Test]
+ public void Table100PercentWide3Rows4Columns()
+ {
+ // Arrange
+ var editor = new TestHtmlEditor();
+ TableProperties tableProperties = new TableProperties();
+ tableProperties.Width = new PixelPercent(100, PixelPercentUnits.Percentage);
+ int rows = 3;
+ int columns = 4;
+ TableCreationParameters tableCreationParamters = new TableCreationParameters(rows, columns, tableProperties);
+
+ // Act
+ TableEditor.InsertTable(editor, null, tableCreationParamters);
+
+ // Assert
+ Approvals.VerifyHtml(editor.Html);
+ }
+
+ [Test]
+ public void TableNoWide3Rows4Columns()
+ {
+ // Arrange
+ var editor = new TestHtmlEditor();
+ TableProperties tableProperties = new TableProperties();
+ tableProperties.Width = new PixelPercent(0, PixelPercentUnits.Undefined);
+ int rows = 3;
+ int columns = 4;
+ TableCreationParameters tableCreationParamters = new TableCreationParameters(rows, columns, tableProperties);
+
+ // Act
+ TableEditor.InsertTable(editor, null, tableCreationParamters);
+
+ // Assert
+ Approvals.VerifyHtml(editor.Html);
+ }
+
+ [Test]
+ public void TableNoWide3Rows4ColumnsCellSpacingPadding()
+ {
+ // Arrange
+ var editor = new TestHtmlEditor();
+ TableProperties tableProperties = new TableProperties();
+ tableProperties.Width = new PixelPercent(0, PixelPercentUnits.Undefined);
+ tableProperties.CellSpacing = "2";
+ tableProperties.CellPadding = "0";
+ int rows = 3;
+ int columns = 4;
+ TableCreationParameters tableCreationParamters = new TableCreationParameters(rows, columns, tableProperties);
+
+ // Act
+ TableEditor.InsertTable(editor, null, tableCreationParamters);
+
+ // Assert
+ Approvals.VerifyHtml(editor.Html);
+ }
+ }
+}
diff --git a/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/TestHtmlEditor.cs b/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/TestHtmlEditor.cs
new file mode 100644
index 00000000..d3c7ce13
--- /dev/null
+++ b/src/managed/OpenLiveWriter.Tests/PostEditor/Tables/TestHtmlEditor.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Windows.Forms;
+
+using OpenLiveWriter.HtmlEditor;
+
+namespace OpenLiveWriter.Tests.PostEditor.Tables
+{
+ class TestHtmlEditor : IHtmlEditor
+ {
+
+ public string Html { get; set; } = string.Empty;
+
+ public void Dispose()
+ {
+ }
+
+ public Control EditorControl { get; }
+
+ public void LoadHtmlFile(string filePath)
+ {
+ }
+
+ public string GetEditedHtml(bool preferWellFormed)
+ {
+ return null;
+ }
+
+ public string GetEditedHtmlFast()
+ {
+ return null;
+ }
+
+ public string SelectedText { get; }
+ public string SelectedHtml { get; }
+ public void EmptySelection()
+ {
+ }
+
+ public void InsertHtml(string content, bool moveSelectionRight)
+ {
+ Html += content;
+ }
+
+ public void InsertHtml(string content, HtmlInsertionOptions options)
+ {
+ }
+
+ public void InsertLink(string url, string linkText, string linkTitle, string rel, bool newWindow)
+ {
+ }
+
+ public bool IsDirty { get; set; }
+ public IHtmlEditorCommandSource CommandSource { get; }
+
+#pragma warning disable CS0067
+ public event EventHandler IsDirtyEvent;
+ public bool SuspendAutoSave { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/managed/OpenLiveWriter.Tests/Properties/AssemblyInfo.cs b/src/managed/OpenLiveWriter.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..6874c5e5
--- /dev/null
+++ b/src/managed/OpenLiveWriter.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("OpenLiveWriter.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("OpenLiveWriter.Tests")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("b3e5f002-afd0-427a-bcbb-b1e4fb6fc92e")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/managed/OpenLiveWriter.Tests/app.config b/src/managed/OpenLiveWriter.Tests/app.config
new file mode 100644
index 00000000..ad262c61
--- /dev/null
+++ b/src/managed/OpenLiveWriter.Tests/app.config
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/managed/OpenLiveWriter.Tests/packages.config b/src/managed/OpenLiveWriter.Tests/packages.config
new file mode 100644
index 00000000..ac85d7b2
--- /dev/null
+++ b/src/managed/OpenLiveWriter.Tests/packages.config
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/managed/writer.sln b/src/managed/writer.sln
index df5eba94..d44c3f28 100644
--- a/src/managed/writer.sln
+++ b/src/managed/writer.sln
@@ -85,6 +85,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PostBuild.CreateInstaller",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenLiveWriter.SpellChecker", "OpenLiveWriter.SpellChecker\OpenLiveWriter.SpellChecker.csproj", "{2DB3A424-0F1E-44AC-AE01-5454586CE769}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenLiveWriter.Tests", "OpenLiveWriter.Tests\OpenLiveWriter.Tests.csproj", "{B3E5F002-AFD0-427A-BCBB-B1E4FB6FC92E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -199,6 +201,10 @@ Global
{2DB3A424-0F1E-44AC-AE01-5454586CE769}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DB3A424-0F1E-44AC-AE01-5454586CE769}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DB3A424-0F1E-44AC-AE01-5454586CE769}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B3E5F002-AFD0-427A-BCBB-B1E4FB6FC92E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B3E5F002-AFD0-427A-BCBB-B1E4FB6FC92E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B3E5F002-AFD0-427A-BCBB-B1E4FB6FC92E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B3E5F002-AFD0-427A-BCBB-B1E4FB6FC92E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE