public void NestedClassWithSimpleTypes() { string input = @"{ ""Nested1"": { ""SomeString"": ""somestring"", ""SomeInt"": 42, ""SomeDouble"": 42.5, ""SomeDateTime"": ""2021-04-02T09:00:34"" }, ""Nested2"": { ""SomeString"": ""somestring"", ""SomeInt"": 42, ""SomeDouble"": 42.5, ""SomeDateTime"": ""2021-04-02T09:00:34"" } }"; string actual = Mockpiler.StartMockpile(input); string expected = @"new() { Nested1 = new() { SomeString = ""somestring"", SomeInt = 42, SomeDouble = 42.5, SomeDateTime = DateTime.Parse(""2021-04-02T09:00:34"") }, Nested2 = new() { SomeString = ""somestring"", SomeInt = 42, SomeDouble = 42.5, SomeDateTime = DateTime.Parse(""2021-04-02T09:00:34"") } }"; TestHelper.AssertEqualNoWhitepace(expected, actual); }
public void NestedClassWithClassArray() { string input = @"{ ""SomeClassList"": [ { InnerClassInt: 2, InnerClassString: ""lala"" }, { InnerClassInt: 3, InnerClassString: ""lolo"" } ] }"; string actual = Mockpiler.StartMockpile(input); string expected = @"new() { SomeClassList = new() { new () { InnerClassInt = 2, InnerClassString = ""lala"" }, new() { InnerClassInt = 3, InnerClassString = ""lolo"" } } }"; TestHelper.AssertEqualNoWhitepace(expected, actual); }
public void SingleDateTimeExactMatch() { string input = @"{""SomeDateTime"": ""2021-04-02T09:00:34""}"; string actual = Mockpiler.StartMockpile(input); string expected = @"new() { SomeDateTime = DateTime.Parse(""2021-04-02T09:00:34"") }"; TestHelper.AssertEqualNoWhitepace(expected, actual); }
public void SingleDoubleExactMatch() { string input = @"{ ""SomeDouble"": 42.5 }"; string actual = Mockpiler.StartMockpile(input); string expected = @"new() { SomeDouble = 42.5 }"; TestHelper.AssertEqualNoWhitepace(expected, actual); }
public void StringButCouldBeInt() { string input = @"{""SomeString"": ""42""}"; string actual = Mockpiler.StartMockpile(input); string expected = @"new() { SomeString = ""42"" }"; TestHelper.AssertEqualNoWhitepace(expected, actual); }
public void SingleStringExactMatch() { string input = @"{""SomeString"": ""somestring""}"; string actual = Mockpiler.StartMockpile(input); string expected = @"new() { SomeString = ""somestring"" }"; TestHelper.AssertEqualNoWhitepace(expected, actual); }
public void EmptyExactMatch() { string input = @"{}"; string actual = Mockpiler.StartMockpile(input); string expected = @"new() {}"; TestHelper.AssertEqualNoWhitepace(expected, actual); }
public async Task <string> Post() { using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8)) { string body = await reader.ReadToEndAsync(); _logger.LogInformation($"mockpile called with body: {JsonConvert.SerializeObject(body)}"); string result = Mockpiler.StartMockpile(body); _logger.LogInformation($"mockpile resulted in: {result}"); return(result); } }
static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine("arg1 should be filepath to json file"); return; } string input = File.ReadAllText(args[0]); string output = Mockpiler.StartMockpile(input); // write output to stdout Console.Write(output); }
public void NestedClassWithStringArray() { string input = @"{ ""SomeStringList"": [ ""item1"", ""item2"" ] }"; string actual = Mockpiler.StartMockpile(input); string expected = @"new() { SomeStringList = new() { ""item1"", ""item2"" } }"; TestHelper.AssertEqualNoWhitepace(expected, actual); }
public void NestedClassWithIntArray() { string input = @"{ ""SomeIntList"": [ 42, 24 ] }"; string actual = Mockpiler.StartMockpile(input); string expected = @"new() { SomeIntList = new() { 42, 24 } }"; TestHelper.AssertEqualNoWhitepace(expected, actual); }
public void AllSimpleTypesExactMatch() { string input = @"{ ""SomeString"": ""somestring"", ""SomeInt"": 42, ""SomeDouble"": 42.5, ""SomeDateTime"": ""2021-04-02T09:00:34"" }"; string actual = Mockpiler.StartMockpile(input); string expected = @"new() { SomeString = ""somestring"", SomeInt = 42, SomeDouble = 42.5, SomeDateTime = DateTime.Parse(""2021-04-02T09:00:34"") }"; TestHelper.AssertEqualNoWhitepace(expected, actual); }
public void InvalidJson() { string input = @"{"; Assert.Throws <JsonSerializationException>(() => Mockpiler.StartMockpile(input)); }