本文整理汇总了C#中VolunteerService.RetrieveCommitments方法的典型用法代码示例。如果您正苦于以下问题:C# VolunteerService.RetrieveCommitments方法的具体用法?C# VolunteerService.RetrieveCommitments怎么用?C# VolunteerService.RetrieveCommitments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VolunteerService
的用法示例。
在下文中一共展示了VolunteerService.RetrieveCommitments方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenUserIsNullGetAllCommitmentsThrowsNullArgumentException
public void WhenUserIsNullGetAllCommitmentsThrowsNullArgumentException()
{
var moqDataService = new Mock<IDataService>();
var underTest = new VolunteerService(moqDataService.Object);
var results = underTest.RetrieveCommitments(default(Person), false);
}
示例2: WhenQueryingReturnCommitmentsForThisUser
public void WhenQueryingReturnCommitmentsForThisUser()
{
var moqDataService = new Mock<IDataService>();
var disaster = new Disaster
{
Id = 1,
Name = "test",
IsActive = true
};
moqDataService.Setup(ds => ds.Disasters)
.Returns(new List<Disaster>
{
disaster
}.AsQueryable());
moqDataService.Setup(ds => ds.Commitments)
.Returns(new List<Commitment>
{
new Commitment
{
DisasterId=1,
Id = 1,
PersonId=1,
StartDate=new DateTime(2013, 8, 1),
EndDate = new DateTime(2013, 9, 1),
Disaster=disaster
},
new Commitment
{
DisasterId=1,
Id = 2,
PersonId=2,
StartDate=new DateTime(2013, 8, 1),
EndDate = new DateTime(2013, 9, 1),
Disaster=disaster
}
}.AsQueryable());
var underTest = new VolunteerService(moqDataService.Object);
var person = new Person
{
Id = 1,
FirstName = "test",
LastName = "tester"
};
var results = underTest.RetrieveCommitments(person, false);
Assert.IsTrue(results.Count() == 1);
}
示例3: WhenQueryingInactiveDisastersAllCommitmentsReturned
public void WhenQueryingInactiveDisastersAllCommitmentsReturned()
{
var moqDataService = new Mock<IDataService>();
var disaster = new Disaster
{
Id = 1,
Name = "test",
IsActive = false
};
moqDataService.Setup(ds => ds.Disasters)
.Returns(new List<Disaster>
{
disaster
}.AsQueryable());
moqDataService.Setup(ds => ds.Commitments)
.Returns(new List<Commitment>
{
new Commitment
{
DisasterId=1,
Id = 1,
PersonId=1,
StartDate=new DateTime(2013, 8, 1),
EndDate = new DateTime(2013, 9, 1),
Disaster=disaster
}
}.AsQueryable());
var underTest = new VolunteerService(moqDataService.Object);
const int personId = 1;
var results = underTest.RetrieveCommitments(personId, true);
Assert.IsTrue(results.Count() == 1);
Assert.IsTrue(results.Single().Id == 1);
}
示例4: WhenNoCommitmentsExistAnywhereEmptyCollectionIsReturned
public void WhenNoCommitmentsExistAnywhereEmptyCollectionIsReturned()
{
var moqDataService = new Mock<IDataService>();
moqDataService.Setup(ds => ds.Commitments)
.Returns(new List<Commitment>().AsQueryable());
var underTest = new VolunteerService(moqDataService.Object);
var person = new Person
{
Id = 1,
FirstName = "test",
LastName = "tester"
};
var disaster = new Disaster
{
Id = 1,
Name = "test",
IsActive = true
};
moqDataService.Setup(ds => ds.Disasters)
.Returns(new List<Disaster>
{
disaster
}.AsQueryable());
var results = underTest.RetrieveCommitments(person, false);
Assert.IsTrue(results.Count() == 0);
}
示例5: WhenPersonIdDoesNotExistReturnsEmptyList
public void WhenPersonIdDoesNotExistReturnsEmptyList()
{
var moqDataService = new Mock<IDataService>();
moqDataService.Setup(service => service.Commitments).Returns(new List<Commitment>().AsQueryable);
var underTest = new VolunteerService(moqDataService.Object);
var results = underTest.RetrieveCommitments(0, false);
}