public void CreateUpdateDelete()
        {
            Project proj = null;

            try {
                CreateProject(out proj, "Test Create Hook");

                var hooks = Config.Connect().GetRepository(proj.Id).ProjectHooks;

                var toCreate = new ProjectHookInsert {
                    MergeRequestsEvents = true,
                    PushEvents          = true,
                    Url = new Uri("http://scooletz.com"),
                    Id  = proj.Id
                };

                var createdHook = hooks.Create(toCreate);
                hooks.All.Count().ShouldBe(1);

                createdHook.MergeRequestsEvents.ShouldBe(toCreate.MergeRequestsEvents);
                createdHook.PushEvents.ShouldBe(toCreate.PushEvents);
                createdHook.Url.ShouldBe(toCreate.Url);

                var toUpdate = new ProjectHookUpdate {
                    MergeRequestsEvents = true,
                    PushEvents          = true,
                    TagPushEvents       = true,
                    Url    = new Uri("http://scooletz.com"),
                    Id     = proj.Id,
                    HookId = createdHook.Id
                };

                var updated = hooks.Update(toUpdate);

                hooks.All.Count().ShouldBe(1);

                Assert.AreEqual(toUpdate.MergeRequestsEvents, updated.MergeRequestsEvents);
                Assert.AreEqual(toUpdate.PushEvents, updated.PushEvents);
                Assert.AreEqual(toUpdate.Url, updated.Url);

                hooks.Delete(updated.Id);

                hooks.All.ShouldBeEmpty();
            }
            finally {
                if (proj != null)
                {
                    projects.Delete(proj.Id);
                }
            }
        }
Ejemplo n.º 2
0
 public ProjectHook Create(ProjectHookInsert hook)
 {
     return(api.Post().With(hook).To <ProjectHook>(path));
 }