英文:
Unit Testing in Test Explorer says "not run" despite producing no errors and only warning messages
问题
以下是代码的翻译部分:
初学者在这里 - 我正在尝试测试以下代码:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace PersonCreator
    {
        public class Person
        {
            public string Name { get; set; } = "";
            public DateTime BirthDate { get; set; } = new DateTime(1900, 1, 1);
            public double Height { get; set; } = 0.0;
            public Boolean IsMarried { get; set; } = false;
            public int NoOfChildren { get; set; } = 0;
    
            public Person(string name, DateTime birthdate, double height, Boolean isMarried, int noOfChildren)
            {
                this.Name = name;   
                this.BirthDate = birthdate;
                this.Height = height;
                this.IsMarried = isMarried;
                this.NoOfChildren = noOfChildren;
            }
    
            public string MakeTitle()
            {
                string title = ($"{Name};{BirthDate};{Height};{IsMarried};{NoOfChildren}");
                return title;
            }
        }
    }
使用以下单元测试:
    using PersonCreator;
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void CheckPersonConstructor()
        {
            // #### ARRANGE ####
            Person person = new Person("John Doe", new DateTime(1975, 8, 24), 175.9, true, 3);
    
            // #### ACT ####
            string title = person.MakeTitle();
    
            // #### ASSERT ####
            Assert.AreEqual("John Doe;24-08-1975 00:00:00;175,9;True;3", title);
           }
    }
请注意,上述内容中的 " 是 HTML 实体,代表双引号字符 "。在实际代码中,你应该使用双引号而不是 "。
英文:
Beginner here - I am trying to test the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PersonCreator
{
    public class Person
    {
        public string Name { get; set; } = "";
        public DateTime BirthDate { get; set; } = new DateTime(1900, 1, 1);
        public double Height { get; set; } = 0.0;
        public Boolean IsMarried { get; set; } = false;
        public int NoOfChildren { get; set; } = 0;
        public Person(string name, DateTime birthdate, double height, Boolean isMarried, int noOfChildren)
        {
            this.Name = name;   
            this.BirthDate = birthdate;
            this.Height = height;
            this.IsMarried = isMarried;
            this.NoOfChildren = noOfChildren;
        }
        public string MakeTitle()
        {
            string title = ($"{Name};{BirthDate};{Height};{IsMarried};{NoOfChildren}");
            return title;
        }
    }
}
With the following unit test:
using PersonCreator;
[TestClass]
public class UnitTest1
{
    [TestMethod]
    public void CheckPersonConstructor()
    {
        // #### ARRANGE ####
        Person person = new Person("John Doe", new DateTime(1975, 8, 24), 175.9, true, 3);
        // #### ACT ####
        string title = person.MakeTitle();
        // #### ASSERT ####
        Assert.AreEqual("John Doe;24-08-1975 00:00:00;175,9;True;3", title);
       }
}
Running the Test Explorer in Visual Studio simply says "1 not run test" and running "dotnet test" provides the following errors:

What could be the issue for the test not running and the warning messages?
答案1
得分: 1
问题已解决,已更新NuGet包。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论