Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public void SingleDoubleExactMatch()
        {
            string input    = @"{ ""SomeDouble"": 42.5 }";
            string actual   = Mockpiler.StartMockpile(input);
            string expected = @"new() { SomeDouble = 42.5 }";

            TestHelper.AssertEqualNoWhitepace(expected, actual);
        }
Esempio n. 5
0
        public void StringButCouldBeInt()
        {
            string input    = @"{""SomeString"": ""42""}";
            string actual   = Mockpiler.StartMockpile(input);
            string expected = @"new() { SomeString = ""42"" }";

            TestHelper.AssertEqualNoWhitepace(expected, actual);
        }
Esempio n. 6
0
        public void SingleStringExactMatch()
        {
            string input    = @"{""SomeString"": ""somestring""}";
            string actual   = Mockpiler.StartMockpile(input);
            string expected = @"new() { SomeString = ""somestring"" }";

            TestHelper.AssertEqualNoWhitepace(expected, actual);
        }
Esempio n. 7
0
        public void EmptyExactMatch()
        {
            string input    = @"{}";
            string actual   = Mockpiler.StartMockpile(input);
            string expected = @"new() {}";

            TestHelper.AssertEqualNoWhitepace(expected, actual);
        }
Esempio n. 8
0
        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);
            }
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        public void NestedClassWithStringArray()
        {
            string input    = @"{
              ""SomeStringList"": [
                    ""item1"", ""item2""
                ]
            }";
            string actual   = Mockpiler.StartMockpile(input);
            string expected = @"new() {
                SomeStringList = new() {
                    ""item1"", ""item2""
                }
            }";

            TestHelper.AssertEqualNoWhitepace(expected, actual);
        }
Esempio n. 11
0
        public void NestedClassWithIntArray()
        {
            string input    = @"{
              ""SomeIntList"": [
                    42, 24
                ]
            }";
            string actual   = Mockpiler.StartMockpile(input);
            string expected = @"new() {
                SomeIntList = new() {
                    42, 24
                }
            }";

            TestHelper.AssertEqualNoWhitepace(expected, actual);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        public void InvalidJson()
        {
            string input = @"{";

            Assert.Throws <JsonSerializationException>(() => Mockpiler.StartMockpile(input));
        }