Undone changes to resolve line endings
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
@@ -6,14 +7,20 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.CustomTool.Tests
|
||||
{
|
||||
[TestClass]
|
||||
[DeploymentItem("Resources/Resources.resw")]
|
||||
public class StringExtensionTests
|
||||
{
|
||||
private const string FILE_PATH = "Resources.resw";
|
||||
|
||||
[TestMethod]
|
||||
public void LineEndingsAreSame()
|
||||
{
|
||||
var reswFileContents = File.ReadAllText(FILE_PATH);
|
||||
var target = new CodeGeneratorFactory().Create(FILE_PATH.Replace(".resw", string.Empty), "TestApp", reswFileContents);
|
||||
var expected = target.GenerateCode();
|
||||
|
||||
uint length;
|
||||
var target = string.Format("First line{0}Second line{0}", Environment.NewLine);
|
||||
var ptr = target.ConvertToIntPtr(out length);
|
||||
var ptr = expected.ConvertToIntPtr(out length);
|
||||
var actual = Marshal.PtrToStringAuto(ptr);
|
||||
Assert.AreEqual(target, actual);
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ namespace ChristianHelle.DeveloperTools.CodeGenerators.Resw.VSPackage.CustomTool
|
||||
public static IntPtr ConvertToIntPtr(this string code, out uint pcbOutput)
|
||||
{
|
||||
var data = Encoding.Default.GetBytes(code);
|
||||
pcbOutput = (uint)data.Length;
|
||||
|
||||
var ptr = Marshal.StringToCoTaskMemAuto(code);
|
||||
var ptr = Marshal.AllocCoTaskMem(data.Length);
|
||||
Marshal.Copy(data, 0, ptr, data.Length);
|
||||
|
||||
pcbOutput = (uint)data.Length;
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user