Exemplo n.º 1
0
        private static async Task TestWithNoExtraData(IAssemblaClient client, DisposableSpace test)
        {
            const string fileContent = "HelloWorld";
            const string fileName    = "hello-world.txt";

            var uploadedFile = await client.Files.CreateAsync(test.Space.WikiName, FileContent.FromString(fileContent, fileName: fileName));

            uploadedFile.FileName.ShouldBe(fileName);
            uploadedFile.CreatedBy.ShouldBe(test.CurrentUser.Id);
        }
Exemplo n.º 2
0
        private static async Task TestAttachToTicket(IAssemblaClient client, DisposableSpace test)
        {
            var ticket = await client.Tickets.CreateAsync(test.Space.Id, new Ticket { Summary = "Test Ticket" });

            const string fileContent = "HelloWorld";
            const string fileName    = "hello-world.txt";
            var          content     = FileContent.FromString(fileContent, fileName: fileName);
            var          document    = new File {
                AttachableId = ticket.Id, AttachableType = AttachableType.Ticket
            };

            var uploadedFile = await client.Files.CreateAsync(test.Space.WikiName, content, document);

            uploadedFile.TicketId.ShouldBe(ticket.Id);
            uploadedFile.AttachableType.ShouldBe(AttachableType.Ticket);
            uploadedFile.IsAttachedToTicket().ShouldBeTrue();
        }
Exemplo n.º 3
0
        private static async Task TestWithExtraData(IAssemblaClient client, DisposableSpace test)
        {
            var content  = FileContent.FromObjectAsJson(test.CurrentUser, fileName: "user.txt");
            var document = new File {
                Name = "Current User", FileName = "currentUser.txt", Description = "Some text to describe the file"
            };
            var uploadedFile = await client.Files.CreateAsync(test.Space.WikiName, content, document);

            uploadedFile.FileName.ShouldBe(document.FileName);
            uploadedFile.Name.ShouldBe(document.Name);
            uploadedFile.Description.ShouldBe(document.Description);
            uploadedFile.CreatedBy.ShouldBe(test.CurrentUser.Id);

            var downloadedFile = await client.Files.DownloadAsync(test.Space.WikiName, uploadedFile.Id);

            var downloadedUser = JsonConvert.DeserializeObject <User>(Encoding.UTF8.GetString(downloadedFile));

            downloadedUser.Login.ShouldBe(test.CurrentUser.Login);
        }