C# asp.net web表单单元测试解析xml测试返回的集合

C# asp.net web表单单元测试解析xml测试返回的集合,c#,asp.net,xml,unit-testing,C#,Asp.net,Xml,Unit Testing,我有一个web表单应用程序,它解析一些xml并返回一个集合。我使用一个实用的类来解析xml。我正在尝试编写一个单元测试来检查返回的对象集合。这是我的密码 using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using Web_Application.Models; using System.Collections.Generic; namespace _Web_Application.Tests { [Te

我有一个web表单应用程序,它解析一些xml并返回一个集合。我使用一个实用的类来解析xml。我正在尝试编写一个单元测试来检查返回的对象集合。这是我的密码

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Web_Application.Models;
using System.Collections.Generic;

namespace _Web_Application.Tests
{
    [TestClass]
    public class UnitTest1
    {
        string source = @"C:\Users\F\Desktop\Web Application\Web    Application.Tests\LunchTest.xml";

        [TestMethod]
        public void ParseXml()
        {
            XmlUlitilyClass x = new XmlUlitilyClass();
            x.ParseXml(source);

            Assert.AreEqual(x.ParseXml(source).Last(), 4);
            Assert.AreEqual(x.ParseXml(source).Last().Name, "Roast of the day");
            Assert.AreEqual(x.ParseXml(source).Last().DesertIncluded, true);
        }
    }
}

是这样做的正确方法还是我走得太远了谢谢这是一个很好的方法。我唯一关心的是源文件@C:\Users\F\Desktop\Web Application\Web Application.Tests\午餐测试.xml;必须在运行测试的每台计算机上


XmlUlitilyClass是否接受XML字符串而不是文件名?如果是这样,请将午餐测试.xml的内容传递给它。

我没有引用ulility类properlyError 30的System.Collections.Generic.List'不包含'Last'的定义,并且找不到接受'System.Collections.Generic.List'类型的第一个参数的扩展方法'Last'或程序集引用?C:\Users\Francis\Desktop\Francis Gallagher Web Application\Web Application.Tests\UnitTest1.cs 23 48Web Application.Tests