clean code and try to add some tests
continuous-integration/drone/push Build is failing Details

pull/24/head
Alexandre Agostinho 2 years ago
parent 50f2cb43a4
commit 522f169128

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

@ -3,7 +3,7 @@ using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
namespace Model
namespace MCTGLib
{
/// <summary>
/// Define the base structure of any Items.<br/>

@ -1,4 +1,4 @@
namespace Model
namespace MCTGLib
{
/// <summary>
/// Define an Item that can be displayed.

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
namespace Model
namespace MCTGLib
{
/// <summary>
/// A Recipe is a description of step and maybe some techniques, with an ingredient list to make a meal.<br/>

@ -3,7 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace Model
namespace MCTGLib
{
/// <summary>
/// A Recipe collection is a group of recipe.<br/>
@ -15,7 +15,7 @@ namespace Model
private const int CAT_ITEM = 2; // the first number of the item full id : the item category.
private static uint _idCreator = 0; // stand for the creation of a new id. It is incremented each time a new Recipe is instantiated.
private ICollection<Recipe> _recipes = new List<Recipe>(); // main composent of this class.
private readonly ICollection<Recipe> _recipes = new List<Recipe>(); // main composent of this class.
#endregion

@ -22,4 +22,8 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\MCTGLib\MCTGLib.csproj" />
</ItemGroup>
</Project>

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

@ -1,11 +0,0 @@
namespace MCTGLib_UnitTests
{
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}
}
Loading…
Cancel
Save