本文整理汇总了C#中VolunteerService.UpdateDetails方法的典型用法代码示例。如果您正苦于以下问题:C# VolunteerService.UpdateDetails方法的具体用法?C# VolunteerService.UpdateDetails怎么用?C# VolunteerService.UpdateDetails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VolunteerService
的用法示例。
在下文中一共展示了VolunteerService.UpdateDetails方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateDetails_Valid
public void UpdateDetails_Valid()
{
Person moqPerson = new Person()
{
Id = 1,
UserId = null,
FirstName = "Cathy",
LastName = "Jones",
Email = "[email protected]",
PhoneNumber = "555-222-9139",
ClusterId = 1
};
List<Person> people = new List<Person>();
people.Add(moqPerson);
var moqDataService = new Mock<IDataService>();
moqDataService.Setup(s => s.Persons).Returns(people.AsQueryable());
moqDataService.Setup(s => s.UpdatePerson(It.IsAny<Person>())).Returns(new Person() {
Id = 1,
Email = "[email protected]",
FirstName = "Cathy",
LastName = "CHANGED",
PhoneNumber = "555-222-9139",
ClusterId = 1
});
VolunteerService service = new VolunteerService(moqDataService.Object);
var actual = service.UpdateDetails(new Person()
{
Id = 1, Email = "[email protected]", FirstName = "Cathy", LastName = "CHANGED", PhoneNumber = "555-222-9139", ClusterId = 1
});
// Only Last Name has been updated
Assert.AreEqual("CHANGED", actual.LastName);
Assert.AreEqual("Cathy", actual.FirstName);
}
示例2: UpdateDetails_PersonNotFound
public void UpdateDetails_PersonNotFound()
{
Person moqPerson = new Person()
{
Id = 1,
UserId = null,
FirstName = "Cathy",
LastName = "Jones",
Email = "[email protected]",
PhoneNumber = "555-222-9139"
};
List<Person> people = new List<Person>();
people.Add(moqPerson);
var moqDataService = new Mock<IDataService>();
moqDataService.Setup(s => s.Persons).Returns(people.AsQueryable());
VolunteerService service = new VolunteerService(moqDataService.Object);
service.UpdateDetails(new Person()
{
Id = 25,
Email = "[email protected]"
});
}
示例3: UpdateDetails_PersonEmailAlreadyInUse
public void UpdateDetails_PersonEmailAlreadyInUse()
{
Person moqPersonOne = new Person()
{
Id = 1,
UserId = null,
FirstName = "Cathy",
LastName = "Jones",
Email = "[email protected]",
PhoneNumber = "555-222-9139"
};
Person moqPersonTwo = new Person()
{
Id = 2,
UserId = null,
FirstName = "Stan",
LastName = "Smith",
Email = "[email protected]",
PhoneNumber = "111-333-2222"
};
List<Person> people = new List<Person>();
people.Add(moqPersonOne);
people.Add(moqPersonTwo);
var moqDataService = new Mock<IDataService>();
moqDataService.Setup(s => s.Persons).Returns(people.AsQueryable());
VolunteerService service = new VolunteerService(moqDataService.Object);
// Try to change Cathy Jones' email to Stan Smith's email...
service.UpdateDetails(new Person()
{
Id = 1,
Email = "[email protected]",
FirstName = "Cathy",
LastName = "Jones"
});
}
示例4: UpdateDetails_NullPerson
public void UpdateDetails_NullPerson()
{
var moqDataService = new Mock<IDataService>();
VolunteerService service = new VolunteerService(moqDataService.Object);
service.UpdateDetails(null);
}
示例5: UpdateDetails_ChangeEmailToUnusuedEmail_DoesNotThrowPersonEmailAlreadyInUseException
public void UpdateDetails_ChangeEmailToUnusuedEmail_DoesNotThrowPersonEmailAlreadyInUseException()
{
Person moqPersonOne = new Person()
{
Id = 1,
UserId = null,
FirstName = "Cathy",
LastName = "Jones",
Email = "[email protected]",
PhoneNumber = "555-222-9139"
};
List<Person> people = new List<Person>();
people.Add(moqPersonOne);
var moqDataService = new Mock<IDataService>();
moqDataService.Setup(s => s.Persons).Returns(people.AsQueryable());
VolunteerService service = new VolunteerService(moqDataService.Object);
// Try to change Cathy Jones' email to something not in use...
service.UpdateDetails(new Person()
{
Id = 1,
Email = "[email protected]",
FirstName = "Cathy",
LastName = "Jones"
});
}
示例6: UpdateDetails_DoesNotClearFirstOrLastNameIfBlank
public void UpdateDetails_DoesNotClearFirstOrLastNameIfBlank()
{
var moqPersonOne = new Person
{
Id = 1,
UserId = 6,
FirstName = "Cathy",
LastName = "Jones",
Email = "[email protected]",
PhoneNumber = "555-222-9139"
};
var people = new List<Person> {moqPersonOne};
var moqDataService = new Mock<IDataService>();
moqDataService.Setup(s => s.Persons).Returns(people.AsQueryable());
moqDataService.Setup(s => s.UpdatePerson(It.IsAny<Person>())).Returns((Person p) => p);
var service = new VolunteerService(moqDataService.Object);
Person actual = service.UpdateDetails(new Person
{
Id = 1,
UserId = 6,
FirstName = null,
LastName = null,
Email = "[email protected]",
PhoneNumber = "555-222-9139"
});
Assert.IsNotNull(actual);
Assert.IsFalse(string.IsNullOrEmpty(actual.FirstName), "Expected First Name not to be null or empty.");
Assert.IsFalse(string.IsNullOrEmpty(actual.LastName), "Expected Last Name not to be null or empty.");
}