コード例 #1
0
        public async Task TestGetProject_WhenStatusIsSucceededButProjectIsAbsent_ReturnsNull()
        {
            var connection = Substitute.For <ITfsConnection>();

            connection.GetProjects().Returns(Enumerable.Empty <ITfProject>());
            _connectionFactory.Create(_testUri).Returns(connection);
            var systemUnderTest = new TfProjectCollection(_testUri, _connectionFactory, _logger);

            await systemUnderTest.RetrieveProjects();

            Assert.That(systemUnderTest.GetProject(Guid.NewGuid()), Is.Null);
        }
コード例 #2
0
        public async Task TestGetProject_WhenStatusIsSucceededAndProjectIsPresent_ReturnsProject()
        {
            var connection      = Substitute.For <ITfsConnection>();
            var expectedProject = Substitute.For <ITfProject>();
            var projectId       = Guid.NewGuid();

            expectedProject.Id.Returns(projectId);
            var projects = new [] { expectedProject };

            connection.GetProjects().Returns(projects);
            _connectionFactory.Create(_testUri).Returns(connection);
            var systemUnderTest = new TfProjectCollection(_testUri, _connectionFactory, _logger);
            await systemUnderTest.RetrieveProjects();

            var actualProject = systemUnderTest.GetProject(projectId);

            Assert.That(actualProject, Is.EqualTo(expectedProject));
        }
コード例 #3
0
        public void TestGetProject_WhenStatusIsUnstarted_ThrowsInvalidOperation()
        {
            var systemUnderTest = new TfProjectCollection(_testUri, _connectionFactory, _logger);

            Assert.That(() => systemUnderTest.GetProject(Arg.Any <Guid>()), Throws.InvalidOperationException);
        }