コード例 #1
0
        public void DefaultValues()
        {
            var sut = new SwitchBlock();

            Assert.AreEqual(new VariableReference(), sut.Reference);
            Assert.AreEqual(Lists.NewList <IStatement>(), sut.Sections);
            Assert.AreEqual(Lists.NewList <IStatement>(), sut.DefaultSection);
            Assert.AreNotEqual(0, sut.GetHashCode());
            Assert.AreNotEqual(1, sut.GetHashCode());
        }
コード例 #2
0
        public void Equality_Default()
        {
            var a = new SwitchBlock();
            var b = new SwitchBlock();

            Assert.AreEqual(a, b);
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
        }
コード例 #3
0
        public void Equality_DifferentDefaultSection()
        {
            var a = new SwitchBlock();

            a.DefaultSection.Add(new ReturnStatement());
            var b = new SwitchBlock();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
コード例 #4
0
        public void Equality_DifferentSections()
        {
            var a = new SwitchBlock();

            a.Sections.Add(new CaseBlock());
            var b = new SwitchBlock();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
コード例 #5
0
        public void Equality_DifferentReference()
        {
            var a = new SwitchBlock {
                Reference = SomeVarRef("a")
            };
            var b = new SwitchBlock();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
コード例 #6
0
        public void Equality_ReallyTheSame()
        {
            var a = new SwitchBlock
            {
                Reference      = SomeVarRef("a"),
                Sections       = { new CaseBlock() },
                DefaultSection =
                {
                    new ReturnStatement()
                }
            };
            var b = new SwitchBlock
            {
                Reference      = SomeVarRef("a"),
                Sections       = { new CaseBlock() },
                DefaultSection =
                {
                    new ReturnStatement()
                }
            };

            Assert.AreEqual(a, b);
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
        }