add first tests
continuous-integration/drone/push Build was killed Details
continuous-integration/drone Build is failing Details

master
maxime.BATISTA@etu.uca.fr 2 years ago
parent 30c4637a5e
commit c4fe9350d4

@ -9,7 +9,7 @@ namespace LocalServices.Data
/// Database implementation with catastrophic performances.
/// This database implementation persists data in json and will save all the data in their files for each mutable requests.
/// </summary>
internal class CatastrophicPerformancesDatabase : IDatabase
public class CatastrophicPerformancesDatabase : IDatabase
{
private static readonly string RECIPES_FILENAME = "recipes_data.xml";

@ -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);
}
}
}
Loading…
Cancel
Save