public void ErrorMessages()
        {
            var tests = new ListOfTuples <string, string[]>
            {
                { "xa", new[] { "Contains A" } },
                { "xb", new[] { "Contains B (abc, 123)", "Property:Name" } },
                { "xc", new[] { "Contains C (xc, 2)" } },
                { "xdddddd", new[] { "Property 'Simple2-Name' should not contain 'letter D'. The entered text is 'xdddddd', 7 characters long." } },
            };

            foreach (var test in tests)
            {
                using (var scope = TestScope.Create())
                {
                    Console.WriteLine("\r\nInput: " + test.Item1);
                    var simple2 = scope.Resolve <Common.DomRepository>().TestInvalidData.Simple2;
                    simple2.Delete(simple2.Query());
                    var newItem = new TestInvalidData.Simple2 {
                        Name = test.Item1
                    };
                    var error = TestUtility.ShouldFail <Rhetos.UserException>(
                        () => simple2.Insert(newItem),
                        test.Item2);
                    Console.WriteLine("ErrorMessage: " + ExceptionsUtility.MessageForLog(error));
                    Console.WriteLine("Exception: " + error.ToString());
                }
            }
        }
Exemple #2
0
        public void ErrorMessages()
        {
            var tests = new ListOfTuples<string, string[]>
            {
                { "xa", new[] { "Contains A" } },
                { "xb", new[] { "Contains B (abc, 123)", "Property:Name" } },
                { "xc", new[] { "Contains C (xc, 2)" } },
                { "xdddddd", new[] { "Property 'Simple2-Name' should not contain 'letter D'. The entered text is 'xdddddd', 7 characters long." } },
            };

            foreach (var test in tests)
            {
                using (var container = new RhetosTestContainer())
                {
                    Console.WriteLine("\r\nInput: " + test.Item1);
                    var simple2 = container.Resolve<Common.DomRepository>().TestInvalidData.Simple2;
                    simple2.Delete(simple2.Query());
                    var newItem = new TestInvalidData.Simple2 { Name = test.Item1 };
                    var error = TestUtility.ShouldFail<Rhetos.UserException>(
                        () => simple2.Insert(newItem),
                        test.Item2);
                    Console.WriteLine("ErrorMessage: " + ExceptionsUtility.SafeFormatUserMessage(error));
                    Console.WriteLine("Exception: " + error.ToString());
                }
            }
        }