Ejemplo n.º 1
1
        public void PostsToTheCorrectUrl()
        {
            var connection = Substitute.For<IApiConnection>();
            var client = new GistsClient(connection);

            var updateGist = new GistUpdate();
            updateGist.Description = "my newly updated gist";
            var gistFileUpdate = new GistFileUpdate 
            { 
                NewFileName = "myNewGistTestFile.cs",
                Content = "new GistsClient(connection).Edit();"
            };

            updateGist.Files.Add("myGistTestFile.cs", gistFileUpdate);

            client.Edit("1", updateGist);

            connection.Received().Patch<Gist>(Arg.Is<Uri>(u => u.ToString() == "gists/1"), Arg.Any<object>());
        }
Ejemplo n.º 2
0
    public async Task CanCreateEditAndDeleteAGist()
    {
        var newGist = new NewGist { Description = "my new gist", Public = true };

        newGist.Files.Add("myGistTestFile.cs", "new GistsClient(connection).Create();");

        var createdGist = await _fixture.Create(newGist);

        Assert.NotNull(createdGist);
        Assert.Equal(newGist.Description, createdGist.Description);
        Assert.Equal(newGist.Public, createdGist.Public);

        var gistUpdate = new GistUpdate { Description = "my newly updated gist" };
        var gistFileUpdate = new GistFileUpdate
        {
            NewFileName = "myNewGistTestFile.cs",
            Content = "new GistsClient(connection).Edit();"
        };

        gistUpdate.Files.Add("myGistTestFile.cs", gistFileUpdate);

        var updatedGist = await _fixture.Edit(createdGist.Id, gistUpdate);

        Assert.NotNull(updatedGist);
        Assert.Equal(updatedGist.Description, gistUpdate.Description);

        await _fixture.Delete(createdGist.Id);
    }