You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Xunit;
|
|
|
|
|
using Moq;
|
|
|
|
|
using Moq.Internals;
|
|
|
|
|
using Moq.Language;
|
|
|
|
|
using Moq.Protected;
|
|
|
|
|
using xUnitStudy.IBll;
|
|
|
|
|
using xUnitStudy.Bll;
|
|
|
|
|
using xUnitStudy.IDal;
|
|
|
|
|
using xUnitStudy.Model;
|
|
|
|
|
|
|
|
|
|
namespace xUnitStudy.WebApi.Test
|
|
|
|
|
{
|
|
|
|
|
public class StudentBllTest:IDisposable
|
|
|
|
|
{
|
|
|
|
|
private StudentBll bll;
|
|
|
|
|
public StudentBllTest()
|
|
|
|
|
{
|
|
|
|
|
bll = new Bll.StudentBll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void GetTuitionTest()
|
|
|
|
|
{
|
|
|
|
|
Mock<IStudentDal> mockStudentDal = new Mock<IStudentDal>();
|
|
|
|
|
mockStudentDal
|
|
|
|
|
.Setup(m => m.GetStudentById(2))
|
|
|
|
|
.Returns
|
|
|
|
|
(
|
|
|
|
|
new Student() { Id = 2, Name = "小小张", Age = 95 }
|
|
|
|
|
);
|
|
|
|
|
//属性注入
|
|
|
|
|
bll.dal = mockStudentDal.Object;
|
|
|
|
|
|
|
|
|
|
var student = bll.GetStudentById(2);
|
|
|
|
|
var tuition = bll.GetTuition(2);
|
|
|
|
|
|
|
|
|
|
Assert.Equal(student.Id + student.Age, tuition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|