예제 #1
0
        public async Task GetProjectTestException()
        {
            _projectsResourceMock.Request(p => p.Get(It.IsAny <string>()))
            .Response <Project>()
            .Throws(s_googleApiException);

            await Assert.ThrowsExceptionAsync <DataSourceException>(
                () => _objectUnderTest.GetProjectAsync(SomeProjectId));
        }
        public async Task GetProjectTestException()
        {
            // Empty response list triggers GoogleApiException.
            var responses = new Project[0];
            CloudResourceManagerService service = GetMockedService(
                (CloudResourceManagerService s) => s.Projects, p => p.Get(It.IsAny <string>()), responses);
            var dataSource = new ResourceManagerDataSource(null, init => service, null);

            await dataSource.GetProjectAsync(SomeProjectId);
        }
        public async Task GetProjectTestSuccess()
        {
            var responses = new[]
            {
                s_someProject
            };
            CloudResourceManagerService service = GetMockedService(
                (CloudResourceManagerService s) => s.Projects, p => p.Get(It.IsAny <string>()), responses);
            var dataSource = new ResourceManagerDataSource(null, init => service, null);

            Project project = await dataSource.GetProjectAsync(SomeProjectId);

            Assert.AreEqual(s_someProject, project);
            Mock <ProjectsResource> projectsResource = Mock.Get(service.Projects);

            projectsResource.Verify(r => r.Get(SomeProjectId), Times.Once);
            projectsResource.Verify(r => r.Get(It.IsNotIn(SomeProjectId)), Times.Never);
        }