mirror of
https://github.com/sphildreth/roadie
synced 2024-11-14 00:17:12 +00:00
72 lines
2.5 KiB
C#
72 lines
2.5 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Logging;
|
|
using Roadie.Library.Caching;
|
|
using Roadie.Library.Configuration;
|
|
using Roadie.Library.Data;
|
|
using Roadie.Library.Engines;
|
|
using Roadie.Library.Factories;
|
|
using Roadie.Library.MetaData.ID3Tags;
|
|
using Roadie.Library.Processors;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Xunit;
|
|
|
|
namespace Roadie.Library.Tests
|
|
{
|
|
public class ArtistLookupEngineTests
|
|
{
|
|
private IEventMessageLogger MessageLogger { get; }
|
|
private ILogger Logger
|
|
{
|
|
get
|
|
{
|
|
return this.MessageLogger as ILogger;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private IRoadieSettings Configuration { get; }
|
|
public DictionaryCacheManager CacheManager { get; }
|
|
private Encoding.IHttpEncoder HttpEncoder { get; }
|
|
|
|
public ArtistLookupEngineTests()
|
|
{
|
|
this.MessageLogger = new EventMessageLogger();
|
|
this.MessageLogger.Messages += MessageLogger_Messages;
|
|
|
|
var settings = new RoadieSettings();
|
|
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
|
|
configurationBuilder.AddJsonFile("appsettings.test.json");
|
|
IConfiguration configuration = configurationBuilder.Build();
|
|
configuration.GetSection("RoadieSettings").Bind(settings);
|
|
this.Configuration = settings;
|
|
this.CacheManager = new DictionaryCacheManager(this.Logger, new CachePolicy(TimeSpan.FromHours(4)));
|
|
this.HttpEncoder = new Encoding.DummyHttpEncoder();
|
|
}
|
|
|
|
private void MessageLogger_Messages(object sender, EventMessage e)
|
|
{
|
|
Console.WriteLine($"Log Level [{ e.Level }] Log Message [{ e.Message }] ");
|
|
}
|
|
|
|
[Fact]
|
|
public void Get_Artist_By_Name()
|
|
{
|
|
var optionsBuilder = new DbContextOptionsBuilder<RoadieDbContext>();
|
|
optionsBuilder.UseMySql("server=voyager;userid=roadie;password=MenAtW0rk668;persistsecurityinfo=True;database=roadie;ConvertZeroDateTime=true");
|
|
|
|
using (var context = new RoadieDbContext(optionsBuilder.Options))
|
|
{
|
|
IArtistLookupEngine artistLookupEngine = new ArtistLookupEngine(this.Configuration, this.HttpEncoder, context, this.CacheManager, this.Logger);
|
|
var a = artistLookupEngine.DatabaseQueryForArtistName("Nas");
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}
|