相关疑难解决方法(0)

单元测试中单步调试代码

我无法调试或单步测试.

这是我的示例测试代码......

using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DomainModel.Entities;
using DomainModel.Abstract;
using WebUI.Controllers;

namespace Tests
{
    [TestClass]
    public class PeopleControllerTests
    {

        static IPeopleRepository MockPeopleRepository(params Person[] people)
        {
            var mockPeopleRepos = new Moq.Mock<IPeopleRepository>();
            mockPeopleRepos.Setup(x => x.People).Returns(people.AsQueryable());
            return mockPeopleRepos.Object;
        }

        [TestMethod]

        public void Count_Of_People()
        {
            IPeopleRepository repository = MockPeopleRepository(
                new Person { Age = 31, Gender = "Male", Name = "Tom" },
                new Person { Age = 25, Gender = "Female", Name = "Sally" },
                new Person …
Run Code Online (Sandbox Code Playgroud)

c# unit-testing mstest visual-studio

47
推荐指数
4
解决办法
5万
查看次数

什么是SUT,它来自哪里?

我看到很多人都在谈论SUT这个术语,但不明白为什么他们使用这个术语.

SUT是你想要测试的吗?

这个术语来自哪里,它意味着什么?

例如,在这个测试中,我的SUT是什么?

[TestMethod]
public void UsersAction_should_return_IndexAction()
{
    const long id = 1;

    UsersViewModel viewModel = new UsersViewModel()
    {
        SelectedUsers = new long[] { 1, 2, 3, 4 }
    };

    ActionResult result = _controller.Users(id, viewModel);

    result.AssertActionRedirect().ToAction("Index");
}
Run Code Online (Sandbox Code Playgroud)

.net c# unit-testing naming terminology

39
推荐指数
4
解决办法
3万
查看次数

标签 统计

c# ×2

unit-testing ×2

.net ×1

mstest ×1

naming ×1

terminology ×1

visual-studio ×1