public void DevOpsAccess_Associate_OperationSuccessIsFalse()
        {
            // Arrange
            var testManagementHttpClient   = new Mock <TestManagementHttpClient>(new Uri("http://dummy.url"), new VssCredentials());
            var workItemTrackingHttpClient = new Mock <WorkItemTrackingHttpClient>(new Uri("http://dummy.url"), new VssCredentials());

            var outputAccess = new Mock <IOutputAccess>();

            var fixture     = new Fixture();
            var messages    = new Messages();
            var testMethods = fixture.Create <TestMethod[]>();
            var testCases   = testMethods.Select(x => new TestCase(fixture.Create <int>(), x.Name, NotAutomatedName, string.Empty)).ToArray();

            var methodName      = fixture.Create <string>();
            var assemblyName    = fixture.Create <string>();
            var automatedTestId = fixture.Create <string>();
            var result          = new Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItem
            {
                Fields = new Dictionary <string, object>()
                {
                    { AutomationStatusName, AutomatedName },
                    { AutomatedTestIdName, automatedTestId },
                    { AutomatedTestStorageName, assemblyName },
                    { AutomatedTestName, methodName }
                }
            };

            workItemTrackingHttpClient
            .Setup(x => x.UpdateWorkItemAsync(It.IsAny <JsonPatchDocument>(), It.IsAny <int>(), It.IsAny <bool?>(), null, null, null, null, default))
            .ReturnsAsync(result);

            var options = new InputOptions()
            {
                ValidationOnly = true,
                VerboseLogging = true
            };
            var counter = new Counter();

            var azureDevOpsHttpClients = new AzureDevOpsHttpClients()
            {
                TestManagementHttpClient   = testManagementHttpClient.Object,
                WorkItemTrackingHttpClient = workItemTrackingHttpClient.Object
            };

            var target = new DevOpsAccessFactory(azureDevOpsHttpClients, messages, outputAccess.Object, options, counter).Create();

            // Act
            var errorCount = target.Associate(testMethods, testCases.ToDictionary(v => v.Title, t => t));

            // Assert
            errorCount.Should().Be(testMethods.Length);
            counter.Total.Should().Be(0);
            counter.Success.FixedReference.Should().Be(0);
            counter.Error.TestCaseNotFound.Should().Be(0);
            counter.Error.OperationFailed.Should().Be(testMethods.Length);
            outputAccess.Verify(x => x.WriteToConsole(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(testMethods.Length));
        }
        public void DevOpsAccess_Associate_TestCaseIsNull()
        {
            // Arrange
            var testManagementHttpClient   = new Mock <TestManagementHttpClient>(new Uri("http://dummy.url"), new VssCredentials());
            var workItemTrackingHttpClient = new Mock <WorkItemTrackingHttpClient>(new Uri("http://dummy.url"), new VssCredentials());

            var outputAccess = new Mock <IOutputAccess>();

            var fixture     = new Fixture();
            var messages    = new Messages();
            var testCases   = fixture.Create <TestCase[]>();
            var testMethods = fixture.Create <TestMethod[]>();

            var options = new InputOptions()
            {
                ValidationOnly = true,
                VerboseLogging = true
            };
            var counter = new Counter();

            var azureDevOpsHttpClients = new AzureDevOpsHttpClients()
            {
                TestManagementHttpClient   = testManagementHttpClient.Object,
                WorkItemTrackingHttpClient = workItemTrackingHttpClient.Object
            };

            var target = new DevOpsAccessFactory(azureDevOpsHttpClients, messages, outputAccess.Object, options, counter).Create();

            // Act
            var errorCount = target.Associate(testMethods, testCases.ToDictionary(v => v.Title, t => t));

            // Assert
            errorCount.Should().Be(testMethods.Length);
            counter.Error.Total.Should().Be(testMethods.Length);
            counter.Error.TestCaseNotFound.Should().Be(testMethods.Length);
            outputAccess.Verify(x => x.WriteToConsole(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(testMethods.Length));
        }