English 中文(简体)
DivideByZero Inhuman in NUnit TestFixture on WP7.1
原标题:DivideByZero Exception in NUnit TestFixture on WP7.1

我正在为我的WP7.1应用实施一个数据储存接入班。

课程的一般继承结构如下:

IDataStore——接口,使应用狗类的逻辑操作脱节。

http://www.ohchr.org。

<代码>摘要方法 缩略语

public abstract void CreateDataStore();

public abstract void OpenDataStore();

public abstract void SaveChanges();

此外,一个抽象的类别包含由继承人使用的一系列定义:

protected const string xmlRoot = "Data";
protected const string booksRoot = "Records";
protected const string settingsRoot = "Settings";

<代码>有两个继承人 XmlDataStore:IsolatedStorageDataStoreInMemoryDataStore

之后是出于测试目的建立的,因此,我可以测试在<条码>上实施的XmlDataStore的腐蚀性。

I have added a Windows Phone Class Library to my solution. References NUnit via NuGet and have implemented one [TestFixture]:

[TestFixture]
public class XmlDataStoreTest
{
        private IDataStore _store;

        public XmlBookProgressStoreTest()
        {
            _store = new InMemoryXmlDataStore();
        }

        [Test]
        public void TestRegisterBookView()
        {
            _store.RegisterBookView(BookId, "TestBook");
        }
}

An InMemoryDataStore currently is the following class:

public class InMemoryDataStore : XmlDataStore
    {
        private XDocument _inMemDoc;

        public InMemoryDataStore()
        {
            CreateDataStore();
            OpenDataStore();
        }

        public override void CreateDataStore()
        {
            try
            {
                var root = new XElement(xmlRoot);
                root.Add(new XElement(booksRoot));
                root.Add(new XElement(settingsRoot));

                _inMemDoc = new XDocument(root);
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

        public override void OpenDataStore()
        {
            _deusBookDataFile = _inMemDoc;
        }

        public override void SaveChanges()
        {}
    }
}

现在,当我用简单的申请表对这个类别进行辩论时,InMemoryDataStoreinstanciates予以罚款,但当我对我的单位进行测试时,我收到了一份“的编码:var fundamental =个新的XElement(xmlRoot);

Clearly the problem only happens in unit test execution so it must be somehow connected to it. Why is the exception there and how can I fix it?

最佳回答

到目前为止,这是一个共同的问题。 对于测试银灯,目前应使用银灯检测框架,并在仪器屏幕上看到测试结果。

Things should change with the release of NUnit 3 which is to feature a Silverlight support.

问题回答

暂无回答




相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签