|
|
|
@ -0,0 +1,44 @@
|
|
|
|
|
using LocalServices.Data;
|
|
|
|
|
using Models;
|
|
|
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
|
|
|
|
|
|
|
|
namespace Tests
|
|
|
|
|
{
|
|
|
|
|
public class CatastrophicPreformancesDatabaseTests
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private static readonly User SAMPLE_USER = new User(new Uri("https://www.referenseo.com/wp-content/uploads/2019/03/image-attractive-960x540.jpg"), "user", Guid.NewGuid());
|
|
|
|
|
private static readonly Recipe SAMPLE_RECIPE = new RecipeBuilder("foo", SAMPLE_USER).Build();
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestInsertRecipe()
|
|
|
|
|
{
|
|
|
|
|
var db = new CatastrophicPerformancesDatabase("/tmp");
|
|
|
|
|
db.InsertUser(SAMPLE_USER);
|
|
|
|
|
db.InsertRecipe(SAMPLE_RECIPE);
|
|
|
|
|
Assert.Contains(SAMPLE_RECIPE, db.ListAllRecipes());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestInsertRate()
|
|
|
|
|
{
|
|
|
|
|
var db = new CatastrophicPerformancesDatabase("/tmp");
|
|
|
|
|
var rate = new RecipeRate(true, 4);
|
|
|
|
|
db.InsertUser(SAMPLE_USER);
|
|
|
|
|
db.InsertRate(SAMPLE_USER.Id, SAMPLE_RECIPE.Info.Id, rate);
|
|
|
|
|
Assert.Equal(rate, db.GetRecipeRate(SAMPLE_USER.Id, SAMPLE_RECIPE.Info.Id));
|
|
|
|
|
Assert.True(db.ListRatesOf(SAMPLE_USER.Id)[SAMPLE_USER.Id] == rate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestInsertWeeklyList()
|
|
|
|
|
{
|
|
|
|
|
var db = new CatastrophicPerformancesDatabase("/tmp");
|
|
|
|
|
db.InsertUser(SAMPLE_USER);
|
|
|
|
|
db.InsertRecipe(SAMPLE_RECIPE);
|
|
|
|
|
db.InsertInUserList(SAMPLE_USER.Id, SAMPLE_RECIPE.Info.Id, 99);
|
|
|
|
|
Assert.True(db.GetRecipeListOf(SAMPLE_USER.Id)[SAMPLE_RECIPE.Info.Id] == 99);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|