public void AddAndDeletePersonalLocationForUser() { Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(Constants.UserName), new string[] { }); using (PersonalLocationsController controller = new PersonalLocationsController(this.DomainContext, null)) { // Get initial count var locations = controller.GetPersonalLocationsForCurrentUser(); int nitialLocationCount = locations.Count; // Add one string newLocationDescription = "Home2"; controller.AddPersonalLocationForCurrentUser(newLocationDescription, 44.00, -79.732728); // Get current list and check count is now +1 locations = controller.GetPersonalLocationsForCurrentUser(); Assert.AreEqual(nitialLocationCount + 1, locations.Count); // Find the new location's GUID PersonalLocation newLocation = null; foreach (var location in locations) { if (location.Description == newLocationDescription) { newLocation = location; } } // Remove the new one controller.DeletePersonalLocationForCurrentUser(newLocation.Id); // Get current list and check count is now the original value locations = controller.GetPersonalLocationsForCurrentUser(); Assert.AreEqual(nitialLocationCount, locations.Count); } }
public void GetPersonalLocationsForUser() { Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity(Constants.UserName), new string[] { }); using (PersonalLocationsController controller = new PersonalLocationsController(this.DomainContext, null)) { List<PersonalLocation> locations = controller.GetPersonalLocationsForCurrentUser(); Assert.AreEqual(2, locations.Count); Assert.AreEqual(Constants.PersonalLocationId, locations[0].Id); } }