本文整理汇总了C#中VolunteerService类的典型用法代码示例。如果您正苦于以下问题:C# VolunteerService类的具体用法?C# VolunteerService怎么用?C# VolunteerService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VolunteerService类属于命名空间,在下文中一共展示了VolunteerService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register_ValidVolunteer
public void Register_ValidVolunteer()
{
Person moqPerson = new Person()
{
Id = 1,
UserId = null,
FirstName = "Bob",
LastName = "Jones",
Email = "[email protected]",
PhoneNumber = "555-222-9139",
ClusterId = 1
};
var moqDataService = new Mock<IDataService>();
moqDataService.Setup(s => s.AddPerson(It.IsAny<Person>())).Returns(moqPerson);
VolunteerService service = new VolunteerService(moqDataService.Object);
Person actual = service.Register("Bob", "Jones", "[email protected]", "555-222-9139", 1, 5);
Assert.AreEqual(1, actual.Id);
Assert.AreEqual("Bob", actual.FirstName);
Assert.AreEqual("Jones", actual.LastName);
Assert.AreEqual("[email protected]", actual.Email);
Assert.AreEqual("555-222-9139", actual.PhoneNumber);
Assert.AreEqual(1, actual.ClusterId);
}
示例2: Register_UsernameAvailable
public void Register_UsernameAvailable()
{
User moqUser = new User()
{
Id = 1,
UserName = "test123"
};
List<User> users = new List<User>();
users.Add(moqUser);
var moqDataService = new Mock<IDataService>();
moqDataService.Setup(s => s.Users).Returns(users.AsQueryable());
VolunteerService service = new VolunteerService(moqDataService.Object);
//test that the username we created is not available.
Assert.IsFalse(service.UsernameAvailable("test123"), "Username created for this test should report as not available.");
//test that a different username is available.
Assert.IsTrue(service.UsernameAvailable("test456"), "Username that was not added to our data source should report as available.");
}
示例3: GetPersonDetailsForChangeContactInfoReturnsExpectedData
public void GetPersonDetailsForChangeContactInfoReturnsExpectedData()
{
var personOne = new Person
{
Id = 1,
UserId = 6,
FirstName = "Cathy",
LastName = "Jones",
Email = "[email protected]",
PhoneNumber = "555-222-9139",
ClusterId = 1
};
var personTwo = new Person
{
Id = 2,
UserId = 7,
FirstName = "Stan",
LastName = "Smith",
Email = "[email protected]",
PhoneNumber = "111-333-2222"
};
var dataService = new Mock<IDataService>();
var personList = new List<Person>
{
personOne,
personTwo
};
dataService.Setup(x => x.Persons).Returns(personList.AsQueryable());
var underTest = new VolunteerService(dataService.Object);
var result = underTest.GetPersonDetailsForChangeContactInfo(personTwo.UserId.GetValueOrDefault());
Assert.IsNotNull(result);
Assert.AreEqual(personTwo.Email, result.Email);
Assert.AreEqual(personTwo.PhoneNumber, result.PhoneNumber);
}
示例4: Register_NullEmail
public void Register_NullEmail()
{
VolunteerService service = new VolunteerService(new Mock<IDataService>().Object);
service.Register("first", "last", "", "555-333-1111", 1, 3);
}
示例5: WhenDisasterIsNullGetCommitmentsThrowsNullArgumentException
public void WhenDisasterIsNullGetCommitmentsThrowsNullArgumentException()
{
var moqDataService = new Mock<IDataService>();
var underTest = new VolunteerService(moqDataService.Object);
var person = new Person
{
Id = 1,
FirstName = "test",
LastName = "tester"
};
var results = underTest.RetrieveCommitmentsForDisaster(person, default(Disaster));
}
示例6: WhenNoCommitmentsExistEmptyCollectionIsReturned
public void WhenNoCommitmentsExistEmptyCollectionIsReturned()
{
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.RetrieveCommitmentsForDisaster(person, disaster);
Assert.IsTrue(results.Count() == 0);
}
示例7: 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);
}
示例8: Register_NullCluster
public void Register_NullCluster()
{
VolunteerService service = new VolunteerService(new Mock<IDataService>().Object);
service.Register("first", "last", "email", "555-333-1111", 0, 4);
}
示例9: WhenUserIsNullGetAllCommitmentsThrowsNullArgumentException
public void WhenUserIsNullGetAllCommitmentsThrowsNullArgumentException()
{
var moqDataService = new Mock<IDataService>();
var underTest = new VolunteerService(moqDataService.Object);
var results = underTest.RetrieveCommitments(default(Person), false);
}
示例10: Register_EmailAlreadyInUse_ReturnTrue
public void Register_EmailAlreadyInUse_ReturnTrue()
{
Person moqPerson = new Person()
{
Id = 1,
Email = "[email protected]"
};
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);
Assert.IsTrue(service.EmailAlreadyInUse("[email protected]"));
}
示例11: Register_NullLastName
public void Register_NullLastName()
{
VolunteerService service = new VolunteerService(new Mock<IDataService>().Object);
service.Register("first", "", "email", "555-333-1111", 1, 2);
}
示例12: 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.");
}
示例13: 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);
}
示例14: 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);
}
示例15: 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 disaster = new Disaster
{
Id = 1,
Name = "test",
IsActive = true
};
moqDataService.Setup(ds => ds.Disasters)
.Returns(new List<Disaster>
{
disaster
}.AsQueryable());
const int personId = 1;
var results = underTest.RetrieveCommitments(personId, false);
Assert.IsTrue(!results.Any());
}