50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using LCU.API.Internal.MemberPreferencesApi.Services;
|
|
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
|
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
|
using Infrastructure.Services;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using LCU.API.Internal.MemberPreferencesApiLib.Persistence;
|
|
using LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
|
|
|
namespace LCU.API.Internal.MemberPreferencesApi.UnitTests.Repository
|
|
{
|
|
public class UnifiedOptInRepositoryTest
|
|
{
|
|
private ApplicationDbContext _context;
|
|
private UnifiedOptInRepository _optInRepository;
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
var mockDateTime = new DateTimeService();
|
|
var options = new DbContextOptionsBuilder<ApplicationDbContext>()
|
|
.UseInMemoryDatabase(Guid.NewGuid().ToString())
|
|
.EnableSensitiveDataLogging()
|
|
.Options;
|
|
_context = new ApplicationDbContext(options);
|
|
_optInRepository = new UnifiedOptInRepository(_context);
|
|
}
|
|
|
|
[Test]
|
|
public async Task Basic_Flow_Test()
|
|
{
|
|
var memberResult = await _optInRepository.GetMemberOptInSettings("99");
|
|
Assert.Null(memberResult);
|
|
|
|
memberResult = await _optInRepository.GetOrCreateMemberOptinSettings("99");
|
|
await _context.SaveChangesAsync();
|
|
Assert.NotNull(memberResult);
|
|
|
|
// Make sure our Auditable is working.
|
|
Assert.NotNull(memberResult.CreatedBy);
|
|
Assert.NotNull(memberResult.Created);
|
|
Assert.NotNull(memberResult.LastUpdatedBy);
|
|
Assert.NotNull(memberResult.LastUpdated);
|
|
}
|
|
}
|
|
}
|