Files
2026-04-20 14:47:24 -05:00

73 lines
2.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using LCU.API.Collections.CollectionsApiLib.Models;
using LCU.API.Collections.RepoApi.Services;
using LCU.Shared.Collections.RepoApiLib.Models;
using LCU.API.Collections.RepoApi.DataAccess;
using LCU.Shared.Collections.RepoApiLib.Repositories;
using Moq;
using Xunit;
namespace LCU.API.Collections.RepoApiTests.Services
{
public class RepoLetterServiceTest
{
[Fact]
public async void ListByRepoId_Ok()
{
var mockLetterRepository = new Mock<ILetterRepository>();
var mockCollectionsDao = new Mock<ICollectionsDao>();
var collectionsLetters = new List<TemenosHistory>
{
new TemenosHistory()
{
Name= "Comment",
Message= "Sent letter(s): Repo Assignment Form.",
UserId= 56,
Created = DateTime.Parse("2015-05-09"),
Type = (HistoryType)2
},
new TemenosHistory()
{
Name= "Comment",
Message= "asdfasdfsda",
UserId= 56,
Created = DateTime.Parse("2015-05-09"),
Type = (HistoryType)1
}
};
var letters = new List<Letter>
{
new Letter
{
ActionCode = "RTC 3",
DaysToWait = 10,
LetterDescription = "Sent letter(s): Repo Assignment Form."
}
};
mockCollectionsDao.Setup(x => x.RetrieveHistoryAsync(It.IsAny<int>())).ReturnsAsync(collectionsLetters);
mockLetterRepository.Setup(x => x.ListAsync()).ReturnsAsync(letters);
// arrange
var service = new RepoLetterService( mockLetterRepository.Object, mockCollectionsDao.Object);
// act
var result = await service.ListByAccountIdAsync(1234567);
Assert.NotNull(result);
Assert.Single(result);
RepoLetter first = result.First();
Assert.Equal("Sent letter(s): Repo Assignment Form.", first.NoticeType);
Assert.Equal(DateTime.Parse("2015-05-09"), first.DateSent);
Assert.Equal(DateTime.Parse("2015-05-19"), first.DateExpired);
Assert.Equal(10, first.DaysToRedeem);
Assert.Equal("RTC 3", first.ActionCode);
}
}
}