小编use*_*073的帖子

CollectionAssert.AreEqual失败.(索引0处的元素不匹配.)

我似乎无法找出为什么我得到这个错误,actualexpected在索引0返回相同的值,并具有完全相同的属性.可能是这个问题的可能原因是什么?我环顾四周但却找不到任何可行的解决方案.

[TestMethod()]
        public void unSortedLeadsTest()
        {
            List<CustomerLead> expected = new List<CustomerLead>();
            List<CustomerLead> actual = new List<CustomerLead>();
            CustomerLeads target = new CustomerLeads(); // TODO: Initialize to an appropriate value
            string xml = "C:/Users/Admin/Downloads/potentialcustomers.xml"; // TODO: Initialize to an appropriate value

            actual = target.unSortedLeads(xml);
            CustomerLead lead = new CustomerLead()
            {
                FirstName = actual[0].FirstName,
                LastName=actual[0].LastName,
                EmailAddress=actual[0].EmailAddress

            };
            CustomerLead lead1 = new CustomerLead()
            {
                FirstName = actual[1].FirstName,
                LastName = actual[1].LastName,
                EmailAddress = actual[1].EmailAddress

            };
            CustomerLead lead2 = new CustomerLead()
            { …
Run Code Online (Sandbox Code Playgroud)

.net c# collections nunit unit-testing

2
推荐指数
2
解决办法
5664
查看次数

如何处理具有不实现IDisposable的属性的类?

不确定如何处理这个类,因为我需要释放资源,因为应用程序中的内存泄漏会导致速度变慢.我不知道如何处理下面的类,因为一些属性没有实现IDisposable.我对c#相当新,所以尽量不要让回复过于复杂.

public class CellItem: IDisposable
    {
        private Timer foo = new Timer();

        public int MedicationDispenseId { get; set; }
        public Enumerations.Timeslot Timeslot { get; set; }
        public DateTime DateAdministered { get; set; }

        protected override void Dispose(bool disposing)
        {
            disposing = true;
            Dispose(disposing);
        }

    }
Run Code Online (Sandbox Code Playgroud)

.net c# garbage-collection memory-leaks .net-4.0

1
推荐指数
1
解决办法
1112
查看次数