correction on UT, simplified projects name

pull/24/head
Alexandre Agostinho 2 years ago
parent a38e35d1ed
commit f90a322f45

@ -7,8 +7,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MCTGLib\MCTGLib.csproj" />
<ItemGroup>
<ProjectReference Include="..\MCTGLib\MCTGLib.csproj" />
</ItemGroup>
</Project>

@ -1,6 +1,6 @@
// See https://aka.ms/new-console-template for more information
using MCTGLib;
using Model;
Console.WriteLine("Hello, World!\n");

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MCTGLib
namespace Model
{
public class PreparationStep
{

@ -1,18 +1,18 @@
using System;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace MCTGLib
{
public class Recipe : IEquatable<Recipe>
{
private static int idCreator = 0;
public int Id { get; init; }
public string Description { get; init; }
public string Title { get; set; }
namespace Model
{
public class Recipe : IEquatable<Recipe>
{
private static int idCreator = 0;
public int Id { get; init; }
public string Description { get; init; }
public string Title { get; set; }
public Recipe(string title, string description = "No Description.")
{
Id = idCreator++;
@ -31,5 +31,5 @@ namespace MCTGLib
{
return Id.GetHashCode();
}
}
}
}
}

@ -1,17 +1,17 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace MCTGLib
{
public class RecipeCollection : IList<Recipe>, IEquatable<RecipeCollection>
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Model
{
public class RecipeCollection : IList<Recipe>, IEquatable<RecipeCollection>
{
#region Attributes
#region Attributes
private List<Recipe> _recipes;
#endregion
#endregion
#region Properties
public string Description { get; set; }
@ -27,8 +27,8 @@ namespace MCTGLib
{
_recipes = new List<Recipe>();
Description = description;
}
}
public RecipeCollection(params Recipe[] recipes)
{
_recipes = new List<Recipe>(recipes);
@ -103,5 +103,5 @@ namespace MCTGLib
return Description.GetHashCode() + _recipes.GetHashCode();
}
#endregion
}
}
}
}

@ -1,34 +1,32 @@
using MCTGLib;
using Model;
namespace MCTGLib_UnitTests
namespace Model_UnitTests
{
public class Recipe_UT
{
[Fact]
public void TestConstructorNotNull()
{
Recipe r1 = new Recipe();
Recipe r1 = new Recipe("R1");
Assert.NotNull(r1);
}
[Fact]
public void TestConstructorWithValidDefaults()
{
Recipe r1 = new Recipe();
Assert.Equal("Recipe n10", r1.Title);
Assert.Equal("A recipe.", r1.Description);
Recipe r2 = new Recipe("Recipe n2");
Assert.Equal("Recipe n2", r2.Title);
Assert.Equal("No Description.", r2.Description);
}
[Fact]
public void TestComputeId()
public void TestRecipeId()
{
List<Recipe> lr = new List<Recipe>();
for (int i = 0; i < 11; i++)
lr.Add(new Recipe());
Recipe r3 = new Recipe("R3");
Recipe r4 = new Recipe("R4");
Assert.Equal((uint)18, lr.ElementAt(8).Id);
Assert.Equal((uint)19, lr.ElementAt(9).Id);
Assert.Equal((uint)110, lr.ElementAt(10).Id);
Assert.Equal(2, r3.Id);
Assert.Equal(3, r4.Id);
}
}
}
}

Loading…
Cancel
Save