コード例 #1
0
        public void TestExample()
        {
            var myTerm = new Term <object>("something's name", DBNull.Value);

            myTerm.As(new ColorGreen());
            myTerm.As(new SmoothSurface());
            myTerm.As(new HardSurface());
            myTerm.As(new SmallSize());
            myTerm.As(new RoundShape());

            Assert.IsTrue(myTerm.IsCategory(new SmallSize()));
            Console.WriteLine(myTerm.ToString()); //something's name
            Console.WriteLine(myTerm.GetCategory());

            var myTerm2 = new Term <object>("another name for same thing", DBNull.Value);

            Assert.IsFalse(myTerm2.Equals(myTerm));
            Assert.IsTrue(myTerm2.EqualRefersTo(myTerm));
        }
コード例 #2
0
ファイル: ContractTermTests.cs プロジェクト: nofuture-git/31g
        public void TestDecorator()
        {
            var testSubject = new Term <object>("test term", DBNull.Value);

            testSubject.As(new OralTerm()).As(new TechnicalTerm());

            var testResultName = testSubject.GetCategory();

            Console.WriteLine(testResultName);

            var testResult = testSubject.IsCategory(new OralTerm());

            Assert.IsTrue(testResult);

            testResult = testSubject.IsCategory(typeof(TechnicalTerm));
            Assert.IsTrue(testResult);

            testResult = testSubject.IsCategory(typeof(CommonUseTerm));
            Assert.IsFalse(testResult);
        }