using System; using System.Collections.Generic; using Xunit; using Moq; using LCU.Shared.Collections.RepoApiLib.Repositories; using LCU.API.Collections.RepoApi.Services; using LCU.API.Collections.RepoApi.Exceptions; using LCU.Shared.Collections.RepoApiLib.Models; namespace LCU.API.Collections.RepoApiTests.Services { public class RepoStatusChangeServiceTest { private readonly Mock _mockStatusChangeRepo; private readonly RepoStatusChangeService _changeService; public RepoStatusChangeServiceTest() { _mockStatusChangeRepo = new Mock(); _changeService = new RepoStatusChangeService(_mockStatusChangeRepo.Object); } [Fact] public async void ListByAccount_Exception() { _mockStatusChangeRepo.Setup(repo => repo.ListForAccountAsync(It.IsAny())) .ThrowsAsync(new Exception("oops")); var res = await Assert.ThrowsAsync(async () => { await _changeService.ListByAccount(5); }); } [Fact] public async void ListByAccount_Ok() { _mockStatusChangeRepo.Setup(repo => repo.ListForAccountAsync(It.IsAny())) .ReturnsAsync(new List() {new RepoStatusChange() { }}); var res = await _changeService.ListByAccount(5); Assert.NotNull(res); Assert.Single(res); } } }