public AbstractSemanticObject[] BuildBs()
        {
            AbstractSemanticObject[] result = new AbstractSemanticObject[5];
            SemanticObjectA a = new SemanticObjectA();
            SemanticObjectC lastC = null;
            for (int i = 0; i < 5; i++)
            {
                SemanticObjectB b = new SemanticObjectB
                                    {
                                        IntProperty = i,
                                        StringProperty = s_SomeStrings[i]
                                    };

                for (int j = 0; j < 10; j++)
                {
                    SemanticObjectC c = new SemanticObjectC
                                        {
                                            B = b,
                                            A = a
                                        };
                    lastC = c;
                }

                b.A = a;
                result[i] = b;
            }

            // this creates a loop, as it is downstream, but not a collection
            a.C = lastC;
            return result;
        }
예제 #2
0
        public AbstractSemanticObject[] BuildBs()
        {
            AbstractSemanticObject[] result = new AbstractSemanticObject[5];
            SemanticObjectA          a      = new SemanticObjectA();
            SemanticObjectC          lastC  = null;

            for (int i = 0; i < 5; i++)
            {
                SemanticObjectB b = new SemanticObjectB
                {
                    IntProperty    = i,
                    StringProperty = s_SomeStrings[i]
                };

                for (int j = 0; j < 10; j++)
                {
                    SemanticObjectC c = new SemanticObjectC
                    {
                        B = b,
                        A = a
                    };
                    lastC = c;
                }

                b.A       = a;
                result[i] = b;
            }

            // this creates a loop, as it is downstream, but not a collection
            a.C = lastC;
            return(result);
        }
예제 #3
0
        public void OnPropertyChangedTest()
        {
            AbstractSemanticObject[] subjects = BuildBs();
            foreach (AbstractSemanticObject so in subjects)
            {
                SemanticObjectB b = so as SemanticObjectB;
                if (b != null)
                {
                    b.PropertyChanged      += DelegateMethod;
                    m_DelegateMethodeCalled = null;
                    for (int i = -7; i < 7; i++)
                    {
                        b.IntProperty = i;
                    }

                    Assert.IsNotNull(m_DelegateMethodeCalled);
                    Assert.AreEqual(b, m_DelegateMethodeCalled.Obj);
                    Assert.IsNotNull(m_DelegateMethodeCalled.PceArgs);
                    Assert.AreEqual("IntProperty", m_DelegateMethodeCalled.PceArgs.PropertyName);
                    m_DelegateMethodeCalled = null;
                    foreach (string s in s_SomeStrings)
                    {
                        b.StringProperty = s;
                    }

                    Assert.IsNotNull(m_DelegateMethodeCalled);
                    Assert.AreEqual(b, m_DelegateMethodeCalled.Obj);
                    Assert.IsNotNull(m_DelegateMethodeCalled.PceArgs);
                    Assert.AreEqual("StringProperty", m_DelegateMethodeCalled.PceArgs.PropertyName);
                }
            }
        }
예제 #4
0
        public void CreateAbstractSemanticObject()
        {
            AbstractSemanticObject result = new SemanticObjectB();

            Assert.IsNotNull(result);
            result = new SemanticObjectA();
            Assert.IsNotNull(result);
            result = new SemanticObjectC();
            Assert.IsNotNull(result);
        }
        internal void AddB(SemanticObjectB b)
        {
            Contract.Requires(b != null);
            Contract.Requires(b.A == this);
            Contract.Ensures(Bs.Contains(b));

            if (!m_Bs.Contains(b))
            {
                m_Bs.Add(b);
            }
        }
        internal void AddB(SemanticObjectB b)
        {
            Contract.Requires(b != null);
            Contract.Requires(b.A == this);
            Contract.Ensures(Bs.Contains(b));

            if (!m_Bs.Contains(b))
            {
                m_Bs.Add(b);
            }
        }
예제 #7
0
        public void ToLimitedStringTest()
        {
            List <AbstractSemanticObject> all = new List <AbstractSemanticObject>(BuildBs());
            AbstractSemanticObject        aB  = all[0];
            SemanticObjectB aBasB             = (SemanticObjectB)aB;

            all.Add(aBasB.A);
            all.AddRange(aBasB.Cs.Cast <AbstractSemanticObject>());
            foreach (AbstractSemanticObject aso in all)
            {
                string result = aso.LimitedToString();
                Trace.WriteLine(result);
                Trace.Flush();
            }
        }
예제 #8
0
        public void ToStringTest()
        {
            AbstractSemanticObject[] subjects = BuildBs();
            foreach (AbstractSemanticObject so in subjects)
            {
                string result = so.ToString();
                Trace.WriteLine(result);
                Trace.Flush();
                SemanticObjectB b = (SemanticObjectB)so;
                result = b.A.ToString();
                Trace.WriteLine(result);
                Trace.Flush();
                foreach (AbstractSemanticObject c in b.Cs)
                {
                    result = c.ToString();
                    Trace.WriteLine(result);
                }

                Trace.Flush();
            }
        }
예제 #9
0
        public void EqualsTest()
        {
            List <AbstractSemanticObject> all = new List <AbstractSemanticObject>(BuildBs());
            AbstractSemanticObject        aB  = all[0];
            SemanticObjectB aBasB             = (SemanticObjectB)aB;

            all.Add(aBasB.A);
            all.AddRange(aBasB.Cs.Cast <AbstractSemanticObject>());
            bool result = false;

            foreach (AbstractSemanticObject aso1 in all)
            {
                foreach (AbstractSemanticObject aso2 in all)
                {
                    result = aso1.Equals(aso2);
                    Assert.AreEqual(result, result);
                }

                result = aso1.Equals(null);
            }

            Assert.AreEqual(result, result);
        }
        internal void RemoveB(SemanticObjectB b)
        {
            Contract.Ensures(!Bs.Contains(b));

            m_Bs.Remove(b);
        }
 public void CreateAbstractSemanticObject()
 {
     AbstractSemanticObject result = new SemanticObjectB();
     Assert.IsNotNull(result);
     result = new SemanticObjectA();
     Assert.IsNotNull(result);
     result = new SemanticObjectC();
     Assert.IsNotNull(result);
 }
 public void CreateAbstractSemanticObject()
 {
     AbstractSemanticObject result = new SemanticObjectB();
     result = new SemanticObjectA();
     result = new SemanticObjectC();
 }
        internal void RemoveB(SemanticObjectB b)
        {
            Contract.Ensures(!Bs.Contains(b));

            m_Bs.Remove(b);
        }