Exemple #1
0
        public void TfsSinkUpdateWorkItemShouldUpdateFieldsEvenIfWorkItemTypeIsNull()
        {
            var fieldMap = new Dictionary <string, object>
            {
                { "Title", "{{Topic}}" },
                { "Description", "{{Description}}" },
                { "IdField", "{{Id}}" },
                { "ActivityCount", "{{Activity}}" }
            };
            var tfsSink = new TestableTfsSink(this.tfsServiceSimulator, new NetworkCredential(), this.parentWorkItemId, null, fieldMap);
            var issue   = new Issue {
                Id = "issue2", Topic = "issue1Topic", Activity = 1, Description = "descr"
            };

            tfsSink.Configure();

            tfsSink.UpdateWorkItem(issue).Should().BeTrue();

            var workItem = this.tfsServiceSimulator.GetWorkItemForIssue("issue2", 1).Item as TfsServiceProviderSimulator.InMemoryWorkItem;

            Assert.IsNotNull(workItem);
            workItem["Title"].Should().Be("issue1Topic");
            workItem["Description"].Should().Be("descr");
            workItem["IdField"].Should().Be("issue2");
            workItem["ActivityCount"].Should().Be("1");
        }
Exemple #2
0
        public void TfsSinkUpdateWorkItemShouldNotUpdateAllFields()
        {
            var fieldMap = new Dictionary <string, object>
            {
                { "Title", "Dummy Title" },                    // Title is a mandatory field for simulator
                { "Foo", "{{Topic1}}" },
                { "Description", "{{deScriptIon}}" },
                { "AreaPath", "Something" }
            };
            var tfsSink = new TestableTfsSink(this.tfsServiceSimulator, new NetworkCredential(), this.parentWorkItemId, "Task", fieldMap);
            var issue   = new Issue {
                Id = "issue2", Topic = "issue1Topic", Activity = 1
            };

            tfsSink.Configure();

            tfsSink.UpdateWorkItem(issue).Should().BeTrue();

            var workItem = this.tfsServiceSimulator.GetWorkItemForIssue("issue2", 1).Item as TfsServiceProviderSimulator.InMemoryWorkItem;

            Assert.IsNotNull(workItem);
            workItem["Title"].Should().Be("Dummy Title");
            workItem["Foo"].Should().Be("{{Topic1}}");
            workItem["Description"].Should().Be("{{deScriptIon}}");

            workItem["AreaPath"] = "nothing"; // someone updates in the background
            var issue2 = new Issue {
                Id = "issue2", Topic = "issue1Topic", Activity = 2
            };

            tfsSink.UpdateWorkItem(issue2).Should().BeTrue();
            workItem["AreaPath"].Should().Be("nothing"); // supa does not revert to "something"
        }
Exemple #3
0
        public void TfsSinkConfigureShouldThrowIfParentWorkItemDoesNotExist()
        {
            var tfsSink = new TestableTfsSink(
                this.tfsServiceSimulator,
                new NetworkCredential(),
                -205,
                "Task",
                new Dictionary <string, object>());
            Action action = () => tfsSink.Configure();

            action.ShouldThrow <Exception>();
        }
Exemple #4
0
        public void TfsSinkConfigureShouldThrowIfParentWorkItemDoesNotExist()
        {
            var tfsSink = new TestableTfsSink(
                this.tfsServiceSimulator,
                new NetworkCredential(),
                -205,
                "Task",
                new Dictionary<string, object>());
            Action action = () => tfsSink.Configure();

            action.ShouldThrow<Exception>();
        }
Exemple #5
0
        public void TfsSinkUpdateWorkItemShouldUpdateFieldsIfTemplateTextDoesNotMatch()
        {
            var fieldMap = new Dictionary <string, object>
            {
                { "Title", "Dummy Title" },                    // Title is a mandatory field for simulator
                { "Foo", "{{Topic1}}" },
                { "Description", "{{deScriptIon}}" }
            };
            var tfsSink = new TestableTfsSink(this.tfsServiceSimulator, new NetworkCredential(), this.parentWorkItemId, "Task", fieldMap);
            var issue   = new Issue {
                Id = "issue2", Topic = "issue1Topic", Activity = 1
            };

            tfsSink.Configure();

            tfsSink.UpdateWorkItem(issue).Should().BeTrue();

            var workItem = this.tfsServiceSimulator.GetWorkItemForIssue("issue2", 1).Item as TfsServiceProviderSimulator.InMemoryWorkItem;

            Assert.IsNotNull(workItem);
            workItem["Title"].Should().Be("Dummy Title");
            workItem["Foo"].Should().Be("{{Topic1}}");
            workItem["Description"].Should().Be("{{deScriptIon}}");
        }
Exemple #6
0
        public void TfsSinkUpdateWorkItemShouldUpdateFieldsIfWorkItemForIssueDoesNotExist()
        {
            var fieldMap = new Dictionary<string, object>
                               {
                                   { "Title", "{{Topic}}" },
                                   { "Description", "{{Description}}" },
                                   { "IdField", "{{Id}}" },
                                   { "ActivityCount", "{{Activity}}" }
                               };
            var tfsSink = new TestableTfsSink(this.tfsServiceSimulator, new NetworkCredential(), this.parentWorkItemId, "Task", fieldMap);
            var issue = new Issue { Id = "issue2", Topic = "issue1Topic", Activity = 1, Description = "descr" };
            tfsSink.Configure();

            tfsSink.UpdateWorkItem(issue).Should().BeTrue();

            var workItem = this.tfsServiceSimulator.GetWorkItemForIssue("issue2", 1).Item as TfsServiceProviderSimulator.InMemoryWorkItem;
            Assert.IsNotNull(workItem);
            workItem["Title"].Should().Be("issue1Topic");
            workItem["Description"].Should().Be("descr");
            workItem["IdField"].Should().Be("issue2");
            workItem["ActivityCount"].Should().Be("1");
        }
Exemple #7
0
        public void TfsSinkUpdateWorkItemShouldUpdateFieldsIfTemplateTextDoesNotMatch()
        {
            var fieldMap = new Dictionary<string, object>
                               {
                                   { "Title", "Dummy Title" }, // Title is a mandatory field for simulator
                                   { "Foo", "{{Topic1}}" },
                                   { "Description", "{{deScriptIon}}" }
                               };
            var tfsSink = new TestableTfsSink(this.tfsServiceSimulator, new NetworkCredential(), this.parentWorkItemId, "Task", fieldMap);
            var issue = new Issue { Id = "issue2", Topic = "issue1Topic", Activity = 1 };
            tfsSink.Configure();

            tfsSink.UpdateWorkItem(issue).Should().BeTrue();

            var workItem = this.tfsServiceSimulator.GetWorkItemForIssue("issue2", 1).Item as TfsServiceProviderSimulator.InMemoryWorkItem;
            Assert.IsNotNull(workItem);
            workItem["Title"].Should().Be("Dummy Title");
            workItem["Foo"].Should().Be("{{Topic1}}");
            workItem["Description"].Should().Be("{{deScriptIon}}");
        }
Exemple #8
0
        public void TfsSinkUpdateWorkItemShouldNotUpdateAllFields()
        {
            var fieldMap = new Dictionary<string, object>
                               {
                                   { "Title", "Dummy Title" }, // Title is a mandatory field for simulator
                                   { "Foo", "{{Topic1}}" },
                                   { "Description", "{{deScriptIon}}" },
                                   { "AreaPath", "Something"}
                               };
            var tfsSink = new TestableTfsSink(this.tfsServiceSimulator, new NetworkCredential(), this.parentWorkItemId, "Task", fieldMap);
            var issue = new Issue { Id = "issue2", Topic = "issue1Topic", Activity = 1 };
            tfsSink.Configure();

            tfsSink.UpdateWorkItem(issue).Should().BeTrue();

            var workItem = this.tfsServiceSimulator.GetWorkItemForIssue("issue2", 1).Item as TfsServiceProviderSimulator.InMemoryWorkItem;
            Assert.IsNotNull(workItem);
            workItem["Title"].Should().Be("Dummy Title");
            workItem["Foo"].Should().Be("{{Topic1}}");
            workItem["Description"].Should().Be("{{deScriptIon}}");

            workItem["AreaPath"] = "nothing"; // someone updates in the background
            var issue2 = new Issue { Id = "issue2", Topic = "issue1Topic", Activity = 2 };
            tfsSink.UpdateWorkItem(issue2).Should().BeTrue();
            workItem["AreaPath"].Should().Be("nothing"); // supa does not revert to "something"
        }