Example #1
0
            public void PostsToTheCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new StagesClient(connection);

                var newStage = new NewStage("name", 1);

                client.Create(newStage);

                connection.Received().Post <Stage>(Arg.Is <Uri>(u => u.ToString() == "stages"),
                                                   Arg.Is <NewStage>(nc => nc.Name == "name" && nc.PipelineId == 1));
            }
            public async Task CanCreate()
            {
                var pipedrive = Helper.GetAuthenticatedClient();
                var fixture   = pipedrive.Stage;

                var newStage = new NewStage("name", 1);

                var stage = await fixture.Create(newStage);

                Assert.NotNull(stage);

                // Cleanup
                await fixture.Delete(stage.Id);
            }
            public async Task CanDelete()
            {
                var pipedrive = Helper.GetAuthenticatedClient();
                var fixture   = pipedrive.Stage;

                var newStage = new NewStage("new-name", 1);
                var stage    = await fixture.Create(newStage);

                var createdStage = await fixture.Get(stage.Id);

                Assert.NotNull(createdStage);

                await fixture.Delete(createdStage.Id);

                await Assert.ThrowsAsync <NotFoundException>(() => fixture.Get(stage.Id));
            }
Example #4
0
        public Stage Map(NewStage model)
        {
            var stage = new Stage
            {
                Id          = Guid.NewGuid(),
                Description = model.Description,
                Index       = model.Index,
                RecipeId    = model.RecipeId
            };

            if (model.Image != null)
            {
                stage.Image = GetImage(model.Image);
            }

            return(stage);
        }
            public async Task CanEdit()
            {
                var pipedrive = Helper.GetAuthenticatedClient();
                var fixture   = pipedrive.Stage;

                var newStage = new NewStage("new-name", 1);
                var stage    = await fixture.Create(newStage);

                var editStage = stage.ToUpdate();

                editStage.Name       = "updated-name";
                editStage.RottenFlag = true;
                editStage.RottenDays = 100;

                var updatedStage = await fixture.Edit(stage.Id, editStage);

                Assert.Equal("updated-name", updatedStage.Name);
                Assert.True(updatedStage.RottenFlag);
                Assert.Equal(100, updatedStage.RottenDays);

                // Cleanup
                await fixture.Delete(updatedStage.Id);
            }