aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.UnitTesting/TFS_TST.cs
blob: 2727ad00e5f95a2fccb24f487755f09ef8b6c47b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Helpers;
using Tango.TFS;

namespace Tango.UnitTesting
{
    [TestClass]
    [TestCategory("Team Foundation Service")]
    public class TFS_TST
    {
        private ITeamFoundationServiceClient CreateClient()
        {
            ITeamFoundationServiceClient client = new TeamFoundationServiceClient(

                                                  "https://twinetfs.visualstudio.com/DefaultCollection",
                                                  "Roy",
                                                  "szzfokrceo4rhd4eqi5qpmxn3pa5iwl3q7tlqd36l2m7smz2ynoa");
            return client;
        }

        [TestMethod]
        public void Get_Tango_Project()
        {
            ITeamFoundationServiceClient client = CreateClient();

            var project = client.GetProject("Tango").Result;

            Assert.IsNotNull(project);
        }

        [TestMethod]
        public void Get_Work_Item()
        {
            ITeamFoundationServiceClient client = CreateClient();

            var project = client.GetProject("Tango").Result;

            Assert.IsNotNull(project);

            var workItem = client.GetWorkItem(project, 153).Result;

            Assert.IsNotNull(workItem);
        }

        [TestMethod]
        public void Upload_Work_Item()
        {
            ITeamFoundationServiceClient client = CreateClient();

            var project = client.GetProject("Tango").Result;

            Assert.IsNotNull(project);

            WorkItem item = new WorkItem();
            item.Area = project.Areas.First();
            item.AssignedTo = project.Members.Single(x => x.DisplayName.Contains("Roy"));
            item.CreatedBy = project.Members.Single(x => x.DisplayName.Contains("Shlomo"));
            item.ChangedBy = project.Members.Single(x => x.DisplayName.Contains("Shlomo"));
            item.AuthorizedAs = project.Members.Single(x => x.DisplayName.Contains("Shlomo"));

            String tempFile = PathHelper.GetTempFilePath();
            File.AppendAllText(tempFile, "This is a test text file...");

            item.Attachments.Add(new Attachment()
            {
                Description = "Test Attachment",
                FilePath = tempFile,
                Name = "TestDocument.txt"
            });

            item.Description = "This is a test description";
            item.FoundInBuild = "1.0.0.9";
            item.Iteration = project.Iterations.First();
            item.Priority = Priority.Priority3;
            item.Severity = Severity.Medium;
            item.State = State.New;
            item.StepsToReproduce = "Step 1" + Environment.NewLine + "Step 2";
            item.SystemInformation = "This is the system information";
            item.Tags.Add(project.Tags.First());
            item.Title = "Test Bug";
            item.Type = WorkItemType.Bug;

            var workItem = client.UploadWorkItem(project, item).Result;

            Assert.IsNotNull(workItem);
        }
    }
}