public void ShouldGenerate_CharacterWithApostrophe() { var stackObject = new ExpressionData("char", "'\\''", "testString", new ExpressionData[] { }, "char"); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var testString = \'\\\'\';\n"); }
public void ShouldGenerate_ConcurrentBagOfDateTime() { var stackObject = GetConcurrentBagOfThreeDateTimeDefinition(); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var test123 = new ConcurrentBag<DateTime>()\n{\r\n new DateTime(2018, 4, 9, 0, 9, 25, 874, DateTimeKind.Unspecified),\r\n new DateTime(2021, 6, 10, 15, 50, 2, 609, DateTimeKind.Unspecified),\r\n new DateTime(2019, 1, 21, 15, 6, 53, 551, DateTimeKind.Unspecified)\r\n};\n"); }
public void ShouldGenerate_StringWithQuotationMarkAndBackslash() { var stackObject = new ExpressionData("string", "\" sdasd \\\\\\\\ \\\"test\\\" asdasd ' asd\"", "testString", new ExpressionData[] { }, "string"); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var testString = \" sdasd \\\\ \\\"test\\\" asdasd ' asd\";\n"); }
public void ShouldGenerate_SimpleIntAssignment() { var stackObject = new ExpressionData("int", "10", "testInt", new ExpressionData[] { }, "int"); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var testInt = 10;\n"); }
public void ShouldGenerate_NullabeIntAssignment() { var stackObject = new ExpressionData("int?", "10", "testNullable", new List <ExpressionData>() { }, "int?"); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var testNullable = new Nullable<int>(10);\n"); }
public void ShouldGenerate_Dictionary() { var dictionaryObject = new ExpressionData("Dictionary<int, string>", "Count = 3", "testDictionary", new ExpressionData[] { GenerateDictionaryElement("0", "test0", 0), GenerateDictionaryElement("1", "test1", 1), GenerateDictionaryElement("2", "test2", 2) }, "System.Collections.Generic.Dictionary<int, string>"); var generated = _codeGeneratorManager.GenerateStackDump(dictionaryObject); generated.Should().Be("var testDictionary = new Dictionary<int, string>()\n{\r\n [0] = \"test0\",\r\n [1] = \"test1\",\r\n [2] = \"test2\"\r\n};\n"); }
public void ShouldGenerate_Regex() { var stackObject = GetRegexDefinition(); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var regex = new Regex(\"<([A-Z][A-Z0-9]*)\\\\b[^>]*>(.*?)</\\\\1>\");\n"); }
public void ShouldGenerate_NullabeIntAssignment() { var stackObject = GetImmutableComplexType(); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var readonlyClass = new ReadOnlyClass(\"testStringad691a26-4398-4ca6-be89-a84ff8f1d90b\",\nnew Nullable<DateTime>(new DateTime(2021, 11, 7, 3, 9, 45, 771, DateTimeKind.Unspecified)),\nnew Nullable<TimeSpan>(new TimeSpan(0, 0, 0, 0, 0)),\nnew Nullable<DateTimeOffset>(new DateTimeOffset(2018, 9, 2, 14, 5, 36, 423, new TimeSpan(0, 2, 0, 0, 0))),\n84,\nnew Nullable<int>(153),\nnew Nullable<decimal>(144M),\nnew List<int>()\n{\r\n 66,\r\n 232,\r\n 161\r\n},\nnew List<string>()\n{\r\n \"5fe2da12-02a4-43aa-b35b-05915a60dad4\",\r\n \"979d153d-cf1b-4ac7-b486-ca1f64977a2b\",\r\n \"252ae04a-db0a-406a-bd86-b98fb6d22537\"\r\n});\n"); }
public void ShouldGenerate_TimeSpan() { var stackObject = GetTimeSpanDefinition(); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var nullableTimeSpan = new Nullable<TimeSpan>(new TimeSpan(3, 21, 42, 24, 53));\n"); }
public void ShouldGenerate_ReadonlyTypeViaConstructor() { var stackObject = GetReadonlyTypeDefinition(); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var mainObject = new ExpressionData(\"List<ExpressionData>\",\n\"Count = 1\",\n\"testList\",\nnew List<ExpressionData>()\n{\r\n new ExpressionData(\"ExpressionData\", \"{ConsoleApp1.Program.ExpressionData}\", \"[0]\", new List<ExpressionData>()\r\n {\r\n new ExpressionData(\"string\", \"ExpressionData21212\", \"Name\", null, \"string\")\r\n }, \"ConsoleApp1.Program.ExpressionData\")\r\n},\n\"System.Collections.Generic.List<ConsoleApp1.Program.ExpressionData>\");\n"); }
public void ShouldGenerate_TimeSpan() { var stackObject = GetTimeSpanDefinition(); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var timeSpan = new TimeSpan(0, 10, 10, 10, 0);\n"); }
public void ShouldGenerate_ComplexTypeWithInheritance() { var stackObject = GetComplexTypeWithInheritanceDefinition(); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var inheritacne = new MainClass()\n{\r\n TestBase = 10,\r\n TestBaseString = \" test\",\r\n TestMain = 10\r\n};\n"); }
public void ShouldGenerate_Uri() { var stackObject = GetUriDefinition(); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var uri = new Uri(\"localhost:80/test/test\");\n"); }
public void ShouldGenerate_GenericClass() { var stackObject = GetGenericClassDefinition(); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var genericClass = new GenericClass<string>()\n{\r\n TestType = \"test\"\r\n};\n"); }
public void ShouldGenerate_ArrayAssignment() { var firstElement = new ExpressionData("string", "test1", "[0]", new ExpressionData[] { }, "string"); var secondElement = new ExpressionData("string", "test2", "[1]", new ExpressionData[] { }, "string"); var stackObject = new ExpressionData("string[]", "{string[2]}", "testStringArray", new ExpressionData[] { firstElement, secondElement }, "string[]"); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var testStringArray = new string[] { \"test1\", \"test2\" };\n"); }
public void ShouldGenerate_Enum() { var stackObject = new ExpressionData("TestEnum", "One", "objectOnStack", new List <ExpressionData>() { }, "ConsoleApp1.Program.TestEnum"); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var objectOnStack = TestEnum.One;\n"); }
public void ShouldGenerate_Guid() { var stackObject = new ExpressionData("Guid", "{2a348889-33ee-479e-a986-81f61f62f35f}", "guid", new List <ExpressionData>() { new ExpressionData("int", "708085897", "_a", new List <ExpressionData>() { }, "int"), new ExpressionData("short", "13294", "_b", new List <ExpressionData>() { }, "short"), new ExpressionData("short", "18334", "_c", new List <ExpressionData>() { }, "short"), new ExpressionData("byte", "169", "_d", new List <ExpressionData>() { }, "byte"), new ExpressionData("byte", "134", "_e", new List <ExpressionData>() { }, "byte"), new ExpressionData("byte", "129", "_f", new List <ExpressionData>() { }, "byte"), new ExpressionData("byte", "246", "_g", new List <ExpressionData>() { }, "byte"), new ExpressionData("byte", "31", "_h", new List <ExpressionData>() { }, "byte"), new ExpressionData("byte", "98", "_i", new List <ExpressionData>() { }, "byte"), new ExpressionData("byte", "243", "_j", new List <ExpressionData>() { }, "byte"), new ExpressionData("byte", "95", "_k", new List <ExpressionData>() { }, "byte") }, "System.Guid"); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var guid = new Guid(\"2a348889-33ee-479e-a986-81f61f62f35f\");\n"); }
public void ShouldGenerate_DateTime() { var dateTime = new ExpressionData("DateTime", "{10.10.0010 10:10:10}", "Date", new List <ExpressionData>() { new ExpressionData("int", "10", "Day", new List <ExpressionData>() { }, "int"), new ExpressionData("DayOfWeek", "Sunday", "DayOfWeek", new List <ExpressionData>() { }, "System.DayOfWeek"), new ExpressionData("int", "283", "DayOfYear", new List <ExpressionData>() { }, "int"), new ExpressionData("int", "10", "Hour", new List <ExpressionData>() { }, "int"), new ExpressionData("ulong", "0", "InternalKind", new List <ExpressionData>() { }, "ulong"), new ExpressionData("long", "3083982100000000", "InternalTicks", new List <ExpressionData>() { }, "long"), new ExpressionData("DateTimeKind", "Unspecified", "Kind", new List <ExpressionData>() { }, "System.DateTimeKind"), new ExpressionData("int", "0", "Millisecond", new List <ExpressionData>() { }, "int"), new ExpressionData("int", "10", "Minute", new List <ExpressionData>() { }, "int"), new ExpressionData("int", "10", "Month", new List <ExpressionData>() { }, "int"), new ExpressionData("int", "10", "Second", new List <ExpressionData>() { }, "int"), new ExpressionData("long", "3083982100000000", "Ticks", new List <ExpressionData>() { }, "long"), new ExpressionData("int", "10", "Year", new List <ExpressionData>() { }, "int"), new ExpressionData("ulong", "3083982100000000", "_dateData", new List <ExpressionData>() { }, "ulong") }, "System.DateTime"); var generated = _codeGeneratorManager.GenerateStackDump(dateTime); generated.Should().Be("var Date = new DateTime(10, 10, 10, 10, 10, 10, 0, DateTimeKind.Unspecified);\n"); }
public void ShouldGenerate_ComplexObjectAssignment() { var stackObject = new ExpressionData("Test", "{ConsoleApp1.Program.Test}", "test123", new List <ExpressionData>() { new ExpressionData("List<int>", "Count = 3", "testListOfInt", new List <ExpressionData>() { new ExpressionData("int", "84", "[0]", new List <ExpressionData>() { }, "int"), new ExpressionData("int", "193", "[1]", new List <ExpressionData>() { }, "int"), new ExpressionData("int", "167", "[2]", new List <ExpressionData>() { }, "int") }, "System.Collections.Generic.List<int>") }, "ConsoleApp1.Program.Test"); var generated = _codeGeneratorManager.GenerateStackDump(stackObject); generated.Should().Be("var test123 = new Test()\n{\r\n testListOfInt = new List<int>() { 84, 193, 167 }\r\n};\n"); }