public async void GetTaskProvidersByType_ReturnEmpty() { _taskProviderRepository.Setup(r => r.GetBySpec(It.IsAny <ISpecification <TaskProvider> >(), It.IsAny <CancellationToken>())) .ReturnsAsync(new List <TaskProvider>()); var service = new TaskProviderService(_taskProviderRepository.Object, _externalServiceTypeRepository.Object, _tagRepository.Object); var results = await service.GetTaskProviders(TaskProviderType.HostingProvider); Assert.Empty(results); }
public async void DeleteTaskProvider_Success() { _taskProviderRepository.Setup(r => r.Delete(1, It.IsAny <CancellationToken>())) .Returns(Task.CompletedTask); var service = new TaskProviderService(_taskProviderRepository.Object, _externalServiceTypeRepository.Object, _tagRepository.Object); await service.DeleteTaskProvider(1); _taskProviderRepository.Verify(r => r.Delete(1, It.IsAny <CancellationToken>()), Times.Once); }
public async void GetTaskProviderByName_ReturnNull() { _taskProviderRepository .Setup(r => r.GetSingleBySpec(It.IsAny <ISpecification <TaskProvider> >(), It.IsAny <CancellationToken>())) .ReturnsAsync((TaskProvider)null); var service = new TaskProviderService(_taskProviderRepository.Object, _externalServiceTypeRepository.Object, _tagRepository.Object); var result = await service.GetTaskProviderByName("HostingProvider1"); Assert.Null(result); }
public async void GetTaskProviderById_ReturnNull() { _taskProviderRepository .Setup(r => r.GetById(4, It.IsAny <CancellationToken>())) .ReturnsAsync((TaskProvider)null); var service = new TaskProviderService(_taskProviderRepository.Object, _externalServiceTypeRepository.Object, _tagRepository.Object); var result = await service.GetTaskProviderById(4); Assert.Null(result); }
public void AddTaskProvider_RequiredServiceNotSupporedException() { _taskProviderRepository.Setup(r => r.Create(It.IsAny <TaskProvider>(), It.IsAny <CancellationToken>())).ReturnsAsync(4); _taskProviderRepository.Setup(r => r.GetById(It.IsAny <int>(), It.IsAny <CancellationToken>())) .ReturnsAsync((int id, CancellationToken cancellationToken) => new TaskProvider { Id = id, Name = "HostingProvider1" }); var service = new TaskProviderService(_taskProviderRepository.Object, _externalServiceTypeRepository.Object, _tagRepository.Object); var exception = Record.ExceptionAsync(() => service.AddTaskProvider("HostingProvider1", TaskProviderType.HostingProvider, "Frandi", "1.0", new string[] { "Service" }, null, null, null, null, DateTime.UtcNow, null)); Assert.IsType <RequiredServicesNotSupportedException>(exception?.Result); }
public async void AddTaskProvider_Success() { _taskProviderRepository.Setup(r => r.Create(It.IsAny <TaskProvider>(), It.IsAny <CancellationToken>())).ReturnsAsync(4); _taskProviderRepository.Setup(r => r.GetById(It.IsAny <int>(), It.IsAny <CancellationToken>())) .ReturnsAsync((int id, CancellationToken cancellationToken) => new TaskProvider { Id = id, Name = "HostingProvider1" }); var service = new TaskProviderService(_taskProviderRepository.Object, _externalServiceTypeRepository.Object, _tagRepository.Object); var result = await service.AddTaskProvider("HostingProvider1", TaskProviderType.HostingProvider, "Frandi", "1.0", null, null, null, null, null, DateTime.UtcNow, null); Assert.Equal(4, result.Id); }
public async void GetTaskProviderById_ReturnItem() { _taskProviderRepository .Setup(r => r.GetSingleBySpec(It.IsAny <TaskProviderFilterSpecification>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new TaskProvider { Id = 1, Name = "GeneratorProvider1" }); var service = new TaskProviderService(_taskProviderRepository.Object, _externalServiceTypeRepository.Object, _tagRepository.Object); var result = await service.GetTaskProviderById(1); Assert.NotNull(result); Assert.Equal("GeneratorProvider1", result.Name); }
public async void GetTaskProvidersByType_ReturnItems() { _taskProviderRepository.Setup(r => r.GetBySpec(It.IsAny <ISpecification <TaskProvider> >(), It.IsAny <CancellationToken>())) .ReturnsAsync(new List <TaskProvider> { new TaskProvider { Id = 3, Name = "BuildProvider1", Type = TaskProviderType.BuildProvider } }); var service = new TaskProviderService(_taskProviderRepository.Object, _externalServiceTypeRepository.Object, _tagRepository.Object); var results = await service.GetTaskProviders(TaskProviderType.BuildProvider); Assert.Single(results); Assert.Equal("BuildProvider1", results.First().Name); }
public async void GetTaskProviders_ReturnItems() { _taskProviderRepository.Setup(r => r.GetBySpec(It.IsAny <ISpecification <TaskProvider> >(), It.IsAny <CancellationToken>())) .ReturnsAsync(new List <TaskProvider> { new TaskProvider { Id = 1, Name = "GeneratorProvider1", Type = TaskProviderType.GeneratorProvider }, new TaskProvider { Id = 2, Name = "RepositoryProvider1", Type = TaskProviderType.RepositoryProvider }, new TaskProvider { Id = 3, Name = "BuildProvider1", Type = TaskProviderType.BuildProvider } }); var service = new TaskProviderService(_taskProviderRepository.Object, _externalServiceTypeRepository.Object, _tagRepository.Object); var results = await service.GetTaskProviders(); Assert.Equal(3, results.Count); }