Beispiel #1
0
    private static unsafe void UnsafeUnmanagedImplementation(string input, string oldValue, string[] newValues)
    {
        StringBuilder sb = new StringBuilder(input);

#if UNSAFE
        var res = SHUnsafe.ReplaceUnsafeUnmanaged(sb, oldValue, newValues);
#endif
        int i = 0;
    }
Beispiel #2
0
        public void ReplaceUnsafeUnmanagedTest()
        {
            //            string testString = @"Assert.Equal -> Assert.AreEqual
            //Assert.AreEqual<*> -> CollectionAssert.AreEqual
            //[Fact] -> [TestMethod]
            //using Xunit; -> using Microsoft.VisualStudio.TestTools.UnitTesting;";
            //            testString = "Assert.AreEqual<*> -> CollectionAssert.AreEqual";

            //            string file = @"e:\Documents\vs\Projects\sunamo.Tests\sunamo.Tests.Data\ReplaceManyFromString\In_ReplaceManyFromString.cs";
            //            var s = TF.ReadFile(file);

            //            s = SH.ReplaceManyFromString(s, testString, Consts.transformTo);

            //            TF.SaveFile(s, file);

            var inputS = @"void SetMode(object mode2)
{";

            var l = inputS.Length;

            var input = new StringBuilder( );

            input.Append(inputS);

            var inputS2 = input.ToString();

            string replaceWhat = @"void SetMode(object mode2)
{";

            var replaceFor = @"void SetMode(object mode2)
{
var mode = EnumHelper.Parse<Mode>(mode2.ToString(), Mode.Empty);";

            var excepted = @"void SetMode(object mode2)
{
var mode = EnumHelper.Parse<Mode>(mode2.ToString(), Mode.Empty);";


            var result  = SHUnsafe.ReplaceUnsafeUnmanaged(input, replaceWhat, replaceFor);
            var result2 = result.ToString();


            Assert.Equal(excepted, result2);
        }