示例#1
0
        public void StringRequired()
        {
            UnitTestContext context = GetContext();

            ApplicationContext.GlobalContext.Clear();
            ApplicationContext.GlobalContext["Shared"] = 0;

            HasPerTypeRules root = new HasPerTypeRules();

            root.Validate();
            context.Assert.AreEqual(string.Empty, root.Test, "Test string should be empty");
            context.Assert.AreEqual(1, root.BrokenRulesCollection.Count, "Broken rule count should be 1 first");
            root.Test = "test";
            context.Assert.AreEqual("test", root.Test, "Test string should be 'test'");
            context.Assert.AreEqual(0, root.BrokenRulesCollection.Count, "Broken rule count should be 0");
            root.Test = "big test";
            context.Assert.AreEqual("big test", root.Test, "Test string should be 'big test'");
            context.Assert.AreEqual(1, root.BrokenRulesCollection.Count, "Broken rule count should be 1 last");
            context.Assert.Success();

            context.Complete();
        }
示例#2
0
        public void StringRequired()
        {
            IDataPortal <HasPerTypeRules> dataPortal = _testDIContext.CreateDataPortal <HasPerTypeRules>();

            UnitTestContext context = GetContext();

            TestResults.Reinitialise();
            TestResults.Add("Shared", "0");

            HasPerTypeRules root = dataPortal.Create();

            root.Validate();
            context.Assert.AreEqual(string.Empty, root.Test, "Test string should be empty");
            context.Assert.AreEqual(1, root.BrokenRulesCollection.Count, "Broken rule count should be 1 first");
            root.Test = "test";
            context.Assert.AreEqual("test", root.Test, "Test string should be 'test'");
            context.Assert.AreEqual(0, root.BrokenRulesCollection.Count, "Broken rule count should be 0");
            root.Test = "big test";
            context.Assert.AreEqual("big test", root.Test, "Test string should be 'big test'");
            context.Assert.AreEqual(1, root.BrokenRulesCollection.Count, "Broken rule count should be 1 last");
            context.Assert.Success();

            context.Complete();
        }