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> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\MCTGLib\MCTGLib.csproj" /> <ProjectReference Include="..\MCTGLib\MCTGLib.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

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

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

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

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

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

Loading…
Cancel
Save