You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
3.5 KiB
73 lines
3.5 KiB
using Model.Classes;
|
|
using Newtonsoft.Json.Bson;
|
|
using NuGet.Frameworks;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace TestProject1
|
|
{
|
|
public class TestBateau
|
|
{
|
|
[Fact]
|
|
public void Bateau_PremierChapEtPremierEpSuperieurOuEgalAZero_ReturnTrue()
|
|
{
|
|
Bateau test = new Bateau("Sunny", "Sauzando Sani-go", -10, -10, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...");
|
|
bool resultat = (test.PremierChap >= 0 && test.PremierEp >= 0);
|
|
Assert.True(resultat, "Les paramètre PremierChap et PremierEp doivent être supérieur ou égale à 0");
|
|
}
|
|
[Fact]
|
|
public void ConstructeurBateau_ImageEgaleValeurParDefaut_ReturnTrue()
|
|
{
|
|
Bateau test = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...");
|
|
bool resultat = (test.Image == "baseimage.png");
|
|
Assert.True(resultat, "L'image devrait avoir la valeur : baseimage.png");
|
|
}
|
|
[Fact]
|
|
public void ConstructeurBateau2_ImageEgaleValeurParDefaut_ReturnTrue()
|
|
{
|
|
Bateau test = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...","");
|
|
bool resultat = (test.Image == "baseimage.png");
|
|
Assert.True(resultat, "L'image devrait avoir la valeur : baseimage.png");
|
|
}
|
|
[Fact]
|
|
public void SurchargeEqualsBateau_Bateau1EgaleBateau2()
|
|
{
|
|
Bateau bateau1 = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", " ");
|
|
Bateau bateau2 = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", " ");
|
|
Bateau? bateau3 = null;
|
|
Equipage equipage = new Equipage("Équipage du poux", "Akagami Kalzokudan", "East Blue", -1, 0, true, "L'équipage du Roux ...", "");
|
|
|
|
bool resultat =(bateau1.Equals(bateau2));
|
|
bool resultat2 =(bateau1.Equals(equipage));
|
|
bool resultat3 =(bateau1.Equals(bateau3));
|
|
|
|
Assert.True(resultat, "Les deux bateaux devraient etre égaux car ils onts le meme nom");
|
|
Assert.False(resultat2);
|
|
Assert.False(resultat3);
|
|
}
|
|
[Fact]
|
|
public void GetHashCode_BateauWithSameProperties_ReturnsSameHashCode()
|
|
{
|
|
Bateau obj1 = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", " ");
|
|
Bateau obj2 = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", " ");
|
|
|
|
var hashCode1 = obj1.GetHashCode();
|
|
var hashCode2 = obj2.GetHashCode();
|
|
|
|
Assert.True(hashCode1 == hashCode2);
|
|
}
|
|
[Fact]
|
|
public void ToString_ReturnsCorrectStringRepresentation()
|
|
{
|
|
Bateau obj1 = new Bateau("Sunny", "Sauzando Sani-go", 435, 321, "Le Thousand Sunny est...", "Ce bateau a pour particularités ...", " ");
|
|
|
|
var result = obj1.ToString();
|
|
|
|
Assert.True("Bateau : Sunny False Sauzando Sani-go 435 321 Le Thousand Sunny est... Ce bateau a pour particularités ... " == result);
|
|
}
|
|
}
|
|
}
|