Files
monorepo/LCU.API.Collections.RepoApi-old/LCU.API.Collections.RepoApiTests/Services/RepoStatusChangeServiceTest.cs
T
2026-04-20 14:47:24 -05:00

46 lines
1.5 KiB
C#

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<IRepoStatusChangeRepository> _mockStatusChangeRepo;
private readonly RepoStatusChangeService _changeService;
public RepoStatusChangeServiceTest()
{
_mockStatusChangeRepo = new Mock<IRepoStatusChangeRepository>();
_changeService = new RepoStatusChangeService(_mockStatusChangeRepo.Object);
}
[Fact]
public async void ListByAccount_Exception()
{
_mockStatusChangeRepo.Setup(repo => repo.ListForAccountAsync(It.IsAny<int>()))
.ThrowsAsync(new Exception("oops"));
var res = await Assert.ThrowsAsync<ServerErrorException>(async () =>
{
await _changeService.ListByAccount(5);
});
}
[Fact]
public async void ListByAccount_Ok()
{
_mockStatusChangeRepo.Setup(repo => repo.ListForAccountAsync(It.IsAny<int>()))
.ReturnsAsync(new List<RepoStatusChange>() {new RepoStatusChange() { }});
var res = await _changeService.ListByAccount(5);
Assert.NotNull(res);
Assert.Single(res);
}
}
}