Пример #1
0
        public void DevOpsManager_Associate_TestMethodsNotAvailableCountIsNotEqualToZero()
        {
            // Arrange
            var outputManagerMock = new Mock <IOutputManager>();
            var devOpsAccessMock  = new Mock <IDevOpsAccess>();

            var fixture   = new Fixture();
            var methods   = fixture.Create <TestMethod[]>();
            var testCases = fixture.Create <TestCase[]>();
            var testMethodsNotAvailable = fixture.Create <List <TestCase> >();

            devOpsAccessMock.Setup(x => x.ListTestCasesWithNotAvailableTestMethods(It.IsAny <TestMethod[]>(), It.IsAny <TestCase[]>())).Returns(testMethodsNotAvailable);
            devOpsAccessMock.Setup(x => x.Associate(It.IsAny <TestMethod[]>(), It.IsAny <Dictionary <string, TestCase> >())).Returns(0);

            var counter = new Counter();

            var target = new DevOpsManagerFactory(devOpsAccessMock.Object, outputManagerMock.Object, counter).Create();

            // Act
            Action actual = () => target.Associate(methods, testCases);

            // Assert
            actual.Should().NotThrow();
            outputManagerMock.Verify(x => x.WriteToConsole(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(DefaultWriteCount + testMethodsNotAvailable.Count));
        }
        public void DevOpsManager_GetTestCases_DuplicateTestCasesCountIsNotEqualToZero()
        {
            // Arrange
            var outputManagerMock = new Mock <IOutputManager>();
            var devOpsAccessMock  = new Mock <IDevOpsAccess>();

            var fixture            = new Fixture();
            var message            = fixture.Create <string>();
            var messageType        = fixture.Create <string>();
            var messageReason      = fixture.Create <string>();
            var duplicateTestCases = fixture.Create <List <DuplicateTestCase> >();
            var workItems          = fixture.Create <List <WorkItem> >();

            workItems.ForEach(x =>
            {
                x.Fields[SystemTitle]          = fixture.Create <string>();
                x.Fields[AutomatedTestName]    = fixture.Create <string>();
                x.Fields[AutomationStatusName] = fixture.Create <string>();
            });

            var counter = new Counter();

            devOpsAccessMock.Setup(x => x.GetTestCaseWorkItems()).Returns(workItems.ToArray);
            devOpsAccessMock.Setup(x => x.ListDuplicateTestCases(It.IsAny <TestCase[]>())).Returns(duplicateTestCases);
            outputManagerMock.Setup(x => x.WriteToConsole(message, messageType, messageReason));

            var target = new DevOpsManagerFactory(devOpsAccessMock.Object, outputManagerMock.Object, counter).Create();

            // Act
            Action actual = () => target.GetTestCases();

            // Assert
            actual.Should().Throw <InvalidOperationException>();
            outputManagerMock.Verify(x => x.WriteToConsole(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(DefaultWriteCount + duplicateTestCases.Count));
        }
        public void DevOpsManager_GetTestCases_TestCasesIsNullOrEmpty()
        {
            // Arrange
            var outputManagerMock = new Mock <IOutputManager>();
            var devOpsAccessMock  = new Mock <IDevOpsAccess>();

            var fixture       = new Fixture();
            var message       = fixture.Create <string>();
            var messageType   = fixture.Create <string>();
            var messageReason = fixture.Create <string>();
            var workItems     = new WorkItem[0];

            var counter = new Counter();

            devOpsAccessMock.Setup(x => x.GetTestCaseWorkItems()).Returns(workItems);
            outputManagerMock.Setup(x => x.WriteToConsole(message, messageType, messageReason));

            var target = new DevOpsManagerFactory(devOpsAccessMock.Object, outputManagerMock.Object, counter).Create();

            // Act
            Action actual = () => target.GetTestCases();

            // Assert
            actual.Should().Throw <InvalidOperationException>();
            outputManagerMock.Verify(x => x.WriteToConsole(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(DefaultWriteCount));
        }
Пример #4
0
        public void DevOpsManager_TestPlanIsEmpty_ReturnsTrue()
        {
            // Arrange
            var outputManagerMock = new Mock <IOutputManager>();
            var devOpsAccessMock  = new Mock <IDevOpsAccess>();

            devOpsAccessMock.Setup(x => x.GetTestCasesId()).Returns(new int[0]);

            var target = new DevOpsManagerFactory(devOpsAccessMock.Object, outputManagerMock.Object).Create();

            // Act
            Action actual = () => target.TestPlanIsEmpty();

            // Assert
            actual.Should().NotThrow();
            actual.Should().Equals(true);
        }
        public void Program_Associate_TestMethodsNotAvailableCountIsNotEqualToZero()
        {
            // Arrange
            var devOpsAccessMock   = new Mock <IDevOpsAccess>();
            var outputAccessMock   = new Mock <IOutputAccess>();
            var outputManagerMock  = new Mock <IOutputManager>();
            var testCaseAccessMock = new Mock <ITestCaseAccess>();

            const bool validateOnly = true;

            var fixture  = new Fixture();
            var testType = string.Empty;
            var messages = new Messages();
            var methods  = new MethodInfo[]
            {
                GetType().GetMethod(MethodBase.GetCurrentMethod().Name),
                GetType().GetMethod(MethodBase.GetCurrentMethod().Name),
                GetType().GetMethod(MethodBase.GetCurrentMethod().Name)
            };

            var testCases = fixture.Create <List <TestCase> >();
            var testMethodsNotAvailable = fixture.Create <List <TestCase> >();

            devOpsAccessMock.Setup(x => x.ListTestCasesWithNotAvailableTestMethods(It.IsAny <List <TestCase> >(), It.IsAny <List <TestMethod> >())).Returns(testMethodsNotAvailable);
            devOpsAccessMock.Setup(x => x.Associate(It.IsAny <List <TestMethod> >(), It.IsAny <List <TestCase> >(), It.IsAny <ITestCaseAccess>(), It.IsAny <bool>(), It.IsAny <string>())).Returns(0);

            var counter = new Counter();

            var target = new DevOpsManagerFactory(devOpsAccessMock.Object, outputManagerMock.Object, outputAccessMock.Object, testCaseAccessMock.Object, counter, messages).Create();

            // Act
            Action actual = () => target.Associate(methods, testCases, validateOnly, testType);

            // Assert
            actual.Should().NotThrow <InvalidOperationException>();
            outputAccessMock.Verify(x => x.WriteToConsole(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(DefaultWriteCount + testMethodsNotAvailable.Count));
        }
        public void DevOpsManager_GetTestCases_Success()
        {
            // Arrange
            var outputManagerMock = new Mock <IOutputManager>();
            var devOpsAccessMock  = new Mock <IDevOpsAccess>();

            var fixture            = new Fixture();
            var message            = fixture.Create <string>();
            var messageType        = fixture.Create <string>();
            var messageReason      = fixture.Create <string>();
            var duplicateTestCases = new List <DuplicateTestCase>();
            var workItems          = fixture.Create <List <WorkItem> >();

            workItems.ForEach(x =>
            {
                x.Fields[SystemTitle]          = fixture.Create <string>();
                x.Fields[AutomatedTestName]    = fixture.Create <string>();
                x.Fields[AutomationStatusName] = fixture.Create <string>();
            });

            var counter = new Counter();

            devOpsAccessMock.Setup(x => x.GetTestCaseWorkItems()).Returns(workItems.ToArray());
            devOpsAccessMock.Setup(x => x.ListDuplicateTestCases(It.IsAny <TestCase[]>())).Returns(duplicateTestCases);
            outputManagerMock.Setup(x => x.WriteToConsole(message, messageType, messageReason));

            var target = new DevOpsManagerFactory(devOpsAccessMock.Object, outputManagerMock.Object, counter).Create();

            // Act
            var actual = target.GetTestCases();

            // Assert
            actual.Should().NotBeNullOrEmpty();
            actual.Length.Should().Be(workItems.Count);
            outputManagerMock.Verify(x => x.WriteToConsole(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(DefaultWriteCount));
        }