Re: Possible Bug

"Benjamin Morrison" <[email protected]>
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <[email protected]>
My base classes were in a separate namespace so I moved them all to the same
namespace, but the problem still exists.  Hopefully this will help you see
what else I might need to change.

namespace Sim1750Tests.CPU.Instructions
{
    public class InstructionTest
    {
        private AddressingMode mode;
        private Sys1750 sys1750;
        private TestScenario scenario;

        public InstructionTest(AddressingMode mode, TestScenario scenario)
        {
            this.mode = mode;
            this.scenario = scenario;

            InitializeSystem();
        }

        public void TestConditionStatus(string additionalMessage, bool
checkCarry)
        {
            string raMessage = "";
            if (scenario.Precision == Precision.Single)
            {
                raMessage = "(RA)";
            }
            else
            {
                raMessage = "(RA, RA+1)";
            }

            ushort cs = GetConditionStatus();
            string bitString = Convert.ToString(cs, 2);
            string equality = "";
            switch ((ConditionStatusFlag)(cs & 0x007F))
            {
                case ConditionStatusFlag.Negative:
                    equality = " < 0 ";                   
                    break;
                case ConditionStatusFlag.Positive:
                    equality = " > 0 ";
                    break;
                case ConditionStatusFlag.Zero:
                    equality = " = 0 ";
                    break;
            }

            string message = "(CS) <-- " + bitString + " if " + raMessage +
equality + additionalMessage;

            Assert.AreEqual(cs, sys1750.CPU.StatusWord.ConditionStatus,
message); 
        }
    }
}

namespace Sim1750Tests.CPU.Instructions
{
    public class Standard
    {
        protected AddressingMode mode;
        protected Dictionary<Boundary, TestScenario> simpleTest;
        protected List<TestScenario> completeTest;

        [Test]
        public void NumberOfCycles()
        {
            foreach (TestScenario scenario in simpleTest.Values)
            {
                InstructionTest test = new InstructionTest(mode, scenario);
                test.TestNumberOfCycles();
            }
        }
    }
}

namespace Sim1750Tests.CPU.Instructions
{
    public class ConditionStatus : Standard
    {
        [Test]
        public void Negative()
        {
            if (simpleTest.ContainsKey(Boundary.Lower) &&
                IsNegative(simpleTest[Boundary.Lower].Precision,
simpleTest[Boundary.Lower].Result))
            {
                InstructionTest test = new InstructionTest(mode,
simpleTest[Boundary.Lower]);
                test.TestConditionStatus("", false);
            }
            else
            {
                Assert.Ignore();
            }
        }
    }
}

namespace Sim1750Tests.CPU.Instructions
{
    public class SinglePrecisionLoad : ConditionStatus
    {
        [Test]
        public void MinimumValue()
        {
            if (simpleTest.ContainsKey(Boundary.Lower))
            {
                InstructionTest test = new InstructionTest(mode,
simpleTest[Boundary.Lower]);
                test.TestRA();
            }
            else
            {
                Assert.Ignore();
            }
        }
    }
}

namespace Sim1750Tests.CPU.Instructions
{
    [TestFixture]
    public class LR : SinglePrecisionLoad
    {
        public LR()
        {
            mode = AddressingMode.R;
            completeTest = new List<TestScenario>();

            TestScenario baseScenario = new TestScenario();
            baseScenario.OpCode = 0x81;
            baseScenario.NumCycles = 4;
            baseScenario.InstructionCounter = 1;
            baseScenario.Ra = 0;
            baseScenario.RaValue = 0xFFFF;
            baseScenario.Rb = 1;

            CreateSimpleTest_Register(baseScenario, "RbValue");

            foreach (TestScenario testScenario in simpleTest.Values)
            {
                TestScenario newScenario = testScenario.Clone();

                for (newScenario.Ra = 0; newScenario.Ra < 15;
newScenario.Ra++)
                {
                    for (newScenario.Rb = 0; newScenario.Rb < 15;
newScenario.Rb++)
                    {
                        if (newScenario.Ra != newScenario.Rb)
                        {
                            completeTest.Add(newScenario);
                        }
                    }
                }
            }
        }
    }
}

Ben

Message: 53
Date: Sat, 21 Jun 2008 16:34:48 -0700
From: "Charlie Poole" <[email protected]>
Subject: Re: [Nunit-users] Possible Bug
To: <[email protected]>
Message-ID: <001001c8d3f7$66797d80$6401a8c0@ferrari>
Content-Type: text/plain;	charset="us-ascii"

Hi Ben,

Inheriting from a base class would not change the order of your tests,
but moving them to a different namespace and/or nesting them in another
class would. Can you post a snippet of code to show what you have done?

Charlie

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf 
> Of Benjamin Morrison
> Sent: Saturday, June 21, 2008 4:03 PM
> To: [email protected]
> Subject: [Nunit-users] Possible Bug
> 
> I have created base classes for my unit tests.  Everything 
> works fine but in the GUI the items aren't in alphabetical 
> order anymore.  
> 
> For example, before I used base classes the tests were 
> displayed in the
> order:  
> 
> ConditionStatus_Negative, ConditionStatus_Positive, 
> ConditionStatus_Zero, LoadMaximumValue, LoadMinimumValue, LoadZero
> 
> After placing the tests in base classes the tests are displayed in the
> order:
> 
> Load.MaximumValue, Load.MinimumValue, 
> ConditionStatus.Negative, ConditionStatus.Positive, 
> ConditionStatus.Zero, Load.Zero
> 
> If the group considers this a bug, I can gather more detailed 
> information if needed and post a bug report so that this 
> issue can be resolved.
> 
> Thanks,
> 
> Ben


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.