public void AcceptAccountPlaceRequestTest()
        {
            // convince ourselves that the user cannot edit the place
            WebPlaceService.TransitPlace t_place = _place.EndPoint.GetPlaceById(_user.ticket, _place_id);
            Console.WriteLine("Place: {0}", t_place.Name);
            try
            {
                EndPoint.CreateOrUpdatePlace(_user.ticket, t_place);
                Assert.IsTrue(false, "Expected an access denied.");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Expected exception: {0}", ex.Message);
                Assert.IsTrue(ex.Message.StartsWith("System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> SnCore.Services.ManagedAccount+AccessDeniedException: Access denied"));
            }
            // create a request
            WebPlaceService.TransitAccountPlaceRequest t_instance = GetTransitInstance();
            t_instance.Id = Create(_user.ticket, t_instance);
            // admin accepts the request
            EndPoint.AcceptAccountPlaceRequest(GetAdminTicket(), t_instance.Id, GetNewString());
            // check that requester is owner
            WebPlaceService.TransitAccountPlace[] places = EndPoint.GetAccountPlaces(GetAdminTicket(), _user.id, null);
            Console.WriteLine("Places: {0}", places.Length);
            Assert.IsTrue(places.Length > 0);
            bool bFound = false;

            foreach (WebPlaceService.TransitAccountPlace place in places)
            {
                if (place.PlaceId == t_instance.PlaceId)
                {
                    bFound = true;
                    break;
                }
            }
            Assert.IsTrue(bFound);
            // the requester can now edit the place
            EndPoint.CreateOrUpdatePlace(_user.ticket, t_place);
            // the requester can now add an alternate name
            WebPlaceService.TransitPlaceName t_name = new WebPlaceService.TransitPlaceName();
            t_name.Name    = GetNewString();
            t_name.PlaceId = _place_id;
            t_name.Id      = EndPoint.CreateOrUpdatePlaceName(_user.ticket, t_name);
            EndPoint.DeletePlaceName(_user.ticket, t_name.Id);
            // the requester can now delete a picture
            WebPlaceService.TransitPlacePicture t_pic = new WebPlaceService.TransitPlacePicture();
            t_pic.AccountId = GetAdminAccount().Id;
            t_pic.Bitmap    = GetNewBitmap();
            t_pic.Name      = GetNewString();
            t_pic.PlaceId   = _place_id;
            t_pic.Id        = EndPoint.CreateOrUpdatePlacePicture(GetAdminTicket(), t_pic);
            EndPoint.DeletePlacePicture(_user.ticket, t_pic.Id);
        }
Пример #2
0
 public void GetNewPlacesTest()
 {
     WebPlaceService.TransitPlace t_instance = GetTransitInstance();
     t_instance.Id = Create(GetAdminTicket(), t_instance);
     WebPlaceService.TransitPlacePicture t_picture = new WebPlaceService.TransitPlacePicture();
     t_picture.AccountId   = _user.id;
     t_picture.Bitmap      = GetNewBitmap();
     t_picture.Description = GetNewString();
     t_picture.Name        = GetNewString();
     t_picture.PlaceId     = t_instance.Id;
     t_picture.Id          = EndPoint.CreateOrUpdatePlacePicture(_user.ticket, t_picture);
     Assert.IsTrue(t_picture.Id > 0);
     WebPlaceService.TransitPlace[] places = EndPoint.GetNewPlaces(GetAdminTicket(), null);
     Assert.IsNotNull(places);
     Console.WriteLine("Places: {0}", places.Length);
     Assert.IsTrue(places.Length > 0);
     Delete(GetAdminTicket(), t_instance.Id);
 }