public void GetEventReceiverTest()
        {
            using (var scope = new PSTestScope(true))
            {
                EventReceiverDefinition receiver = null;
                using (var ctx = TestCommon.CreateClientContext())
                {
                    receiver = ctx.Web.AddRemoteEventReceiver("TestEventReceiver", "https://testserver.com/testeventreceiver.svc", EventReceiverType.ListAdded, EventReceiverSynchronization.Asynchronous, true);
                }

                var results = scope.ExecuteCommand("Get-PnPEventReceiver");

                Assert.IsTrue(results.Any());

                Assert.IsTrue(results[0].BaseObject.GetType() == typeof(EventReceiverDefinition));


                results = scope.ExecuteCommand("Get-PnPEventReceiver",
                                               new CommandParameter("Identity", receiver.ReceiverId));

                Assert.IsTrue(results.Any());

                using (var ctx = TestCommon.CreateClientContext())
                {
                    receiver = ctx.Web.GetEventReceiverByName("TestEventReceiver");

                    receiver.DeleteObject();
                    ctx.ExecuteQueryRetry();
                }
            }
        }
 private void DeleteReceiver(ClientContext clientContext, EventReceiverDefinition receiver)
 {
     try
     {
         Trace.WriteLine("Removing ItemAdded receiver at " + receiver.ReceiverUrl);
         receiver.DeleteObject();
         clientContext.ExecuteQuery();
     }
     catch (Exception ex)
     {
         Trace.TraceError(ex.Message);
         Trace.TraceInformation("DeleteReceiver failed");
     }
 }
 public void Delete()
 {
     _erd.DeleteObject();
     _parentCollection.Context.ExecuteQuery();
 }