Compare commits

..

1 Commits

Author SHA1 Message Date
Maxence LANONE b012449058 uncomment code
continuous-integration/drone/push Build is failing Details
2 years ago

@ -8,33 +8,33 @@ namespace TestUnitaireLOL
{
public class TestAPI
{
//[Theory]
//[InlineData("Beatrice", "sdfsdfd", "icon.png")]
//[InlineData("Maurice", "Ahri est un champion de League of Legends", "icon.png")]
//[InlineData("Loupiotte", "Akali est un champion de League of Legends", "icon.png")]
//public async Task TestPostChampion(string name, string bio, string icon)
//{
// // Arrange
// var data = new StubData();
// var logger = new NullLogger<ChampionController>();
// var controller = new ChampionController(data, logger);
// var champDTO = new ChampionDTO()
// {
// Name = name,
// Bio = bio,
// Icon = icon
// };
[Theory]
[InlineData("Beatrice", "sdfsdfd", "icon.png")]
[InlineData("Maurice", "Ahri est un champion de League of Legends", "icon.png")]
[InlineData("Loupiotte", "Akali est un champion de League of Legends", "icon.png")]
public async Task TestPostChampion(string name, string bio, string icon)
{
// Arrange
var data = new StubData();
var logger = new NullLogger<ChampionController>();
var controller = new ChampionController(data, logger);
var champDTO = new ChampionDTO()
{
Name = name,
Bio = bio,
Icon = icon
};
// // Act
// var nbInListBefore = data.ChampionsMgr.GetNbItems().Result;
// var result = await controller.AddChampion(champDTO);
// var nbInListAfter = data.ChampionsMgr.GetNbItems().Result;
// Act
var nbInListBefore = data.ChampionsMgr.GetNbItems().Result;
var result = await controller.AddChampion(champDTO);
var nbInListAfter = data.ChampionsMgr.GetNbItems().Result;
// // Assert
// // IS the champion added to the list, number of champions in the list + 1
// Assert.Equal(nbInListBefore + 1, nbInListAfter);
// // Test le code de retour
//}
// Assert
// IS the champion added to the list, number of champions in the list + 1
Assert.Equal(nbInListBefore + 1, nbInListAfter);
// Test le code de retour
}
}
}

@ -10,69 +10,69 @@ namespace TestUnitaireLOL
{
public class TestEf
{
//[Theory]
//[InlineData(0, "Zeus", "Dieu de la foudre", true)]
//[InlineData(10, "Hades", "Dieu des enfers", true)]
//[InlineData(1, "Aphrodite", "Déesse de l'amour", true)]
////[InlineData(10, "AresAresAresAresAresAresAresAresAresAres",
//// "Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre" +
//// "Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre" +
//// "Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre", false)]
//public async Task TestAddChampionInMemory(int id, String name, String bio, bool expected)
//{
// var connection = new SqliteConnection("DataSource=:memory:");
// connection.Open();
// var options = new DbContextOptionsBuilder<LolContext>()
// .UseSqlite(connection)
// .Options;
// using (var context = new LolContext(options))
// {
// await context.Database.EnsureCreatedAsync();
// SkinEntity black = new SkinEntity { Name = "Black", Description = "Black skin", Icon = "black.png", Price = 0.99f };
// SkinEntity white = new SkinEntity { Name = "White", Description = "White skin", Icon = "white.png", Price = 150.99f };
// SkinEntity green = new SkinEntity { Name = "Green", Description = "Green skin", Icon = "green.png", Price = 4.99f };
// RunePageEntity runePage1 = new RunePageEntity { Id = 1, Name = "runepage1" };
// var Dieu = new ChampionEntity
// {
// UniqueId = id,
// Name = name,
// Bio = bio,
// Skins = new Collection<SkinEntity>(new List<SkinEntity> { black, white, green }),
// ListRunePages = new Collection<RunePageEntity>(new List<RunePageEntity> { { runePage1 } })
// };
// ChampionEntity found = await context.Champions.SingleOrDefaultAsync(c => c.Name == "Zeus");
// Assert.Null(found);
// await context.Champions.AddAsync(Dieu);
// await context.SaveChangesAsync();
// found = await context.Champions.SingleOrDefaultAsync(c => c.Name == name);
// Assert.NotNull(found);
// Assert.Equal(1, await context.Champions.CountAsync());
// Assert.Equal(name, found.Name);
// Assert.Equal(3, found.Skins.Count);
// Assert.Equal(1, found.ListRunePages.Count);
// // Test if the max length of the name is respected (30) and the max length of the bio is respected (256)
// if (expected)
// {
// Assert.True(found.Name.Length <= 30);
// Assert.True(found.Bio.Length <= 256);
// }
// else
// {
// Assert.False(found.Name.Length <= 30);
// Assert.False(found.Bio.Length <= 256);
// }
// }
//}
[Theory]
[InlineData(0, "Zeus", "Dieu de la foudre", true)]
[InlineData(10, "Hades", "Dieu des enfers", true)]
[InlineData(1, "Aphrodite", "Déesse de l'amour", true)]
//[InlineData(10, "AresAresAresAresAresAresAresAresAresAres",
// "Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre" +
// "Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre" +
// "Dieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerreDieu de la guerre", false)]
public async Task TestAddChampionInMemory(int id, String name, String bio, bool expected)
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
var options = new DbContextOptionsBuilder<LolContext>()
.UseSqlite(connection)
.Options;
using (var context = new LolContext(options))
{
await context.Database.EnsureCreatedAsync();
SkinEntity black = new SkinEntity { Name = "Black", Description = "Black skin", Icon = "black.png", Price = 0.99f };
SkinEntity white = new SkinEntity { Name = "White", Description = "White skin", Icon = "white.png", Price = 150.99f };
SkinEntity green = new SkinEntity { Name = "Green", Description = "Green skin", Icon = "green.png", Price = 4.99f };
RunePageEntity runePage1 = new RunePageEntity { Id = 1, Name = "runepage1" };
var Dieu = new ChampionEntity
{
UniqueId = id,
Name = name,
Bio = bio,
Skins = new Collection<SkinEntity>(new List<SkinEntity> { black, white, green }),
ListRunePages = new Collection<RunePageEntity>(new List<RunePageEntity> { { runePage1 } })
};
ChampionEntity found = await context.Champions.SingleOrDefaultAsync(c => c.Name == "Zeus");
Assert.Null(found);
await context.Champions.AddAsync(Dieu);
await context.SaveChangesAsync();
found = await context.Champions.SingleOrDefaultAsync(c => c.Name == name);
Assert.NotNull(found);
Assert.Equal(1, await context.Champions.CountAsync());
Assert.Equal(name, found.Name);
Assert.Equal(3, found.Skins.Count);
Assert.Equal(1, found.ListRunePages.Count);
// Test if the max length of the name is respected (30) and the max length of the bio is respected (256)
if (expected)
{
Assert.True(found.Name.Length <= 30);
Assert.True(found.Bio.Length <= 256);
}
else
{
Assert.False(found.Name.Length <= 30);
Assert.False(found.Bio.Length <= 256);
}
}
}
[Fact]
public void TestModifyChampionInMemory()
@ -127,52 +127,52 @@ namespace TestUnitaireLOL
}
}
//[Theory]
[Theory]
//[InlineData(0, "black", "super Skin", "icon1.png", 190000000.2f, true)]
//[InlineData(1, "White", "skin1", "icon1", 19, true)]
//[InlineData(2, "Green", "skin", "icon1.jpg", -1, false)]
//public async Task TestAddSkinToChampionInMemory(int id, String name, String description, String icon, float price, bool expected)
//{
// var connection = new SqliteConnection("DataSource=:memory:");
// connection.Open();
[InlineData(0, "black", "super Skin", "icon1.png", 190000000.2f, true)]
[InlineData(1, "White", "skin1", "icon1", 19, true)]
[InlineData(2, "Green", "skin", "icon1.jpg", -1, false)]
public async Task TestAddSkinToChampionInMemory(int id, String name, String description, String icon, float price, bool expected)
{
var connection = new SqliteConnection("DataSource=:memory:");
connection.Open();
// var options = new DbContextOptionsBuilder<LolContext>()
// .UseSqlite(connection)
// .Options;
var options = new DbContextOptionsBuilder<LolContext>()
.UseSqlite(connection)
.Options;
// using (var context = new LolContext(options))
// {
// await context.Database.EnsureCreatedAsync();
using (var context = new LolContext(options))
{
await context.Database.EnsureCreatedAsync();
// var Dieu = new ChampionEntity
// {
// UniqueId = 0,
// Name = "Zeus",
// Bio = "Dieu de la foudre",
// Skins = new Collection<SkinEntity>()
// };
var Dieu = new ChampionEntity
{
UniqueId = 0,
Name = "Zeus",
Bio = "Dieu de la foudre",
Skins = new Collection<SkinEntity>()
};
// SkinEntity item = new SkinEntity
// {
// Name = name,
// Description = description,
// Icon = icon,
// Price = price
// };
SkinEntity item = new SkinEntity
{
Name = name,
Description = description,
Icon = icon,
Price = price
};
// Dieu.Skins.Add(item);
Dieu.Skins.Add(item);
// ChampionEntity found = await context.Champions.SingleOrDefaultAsync(c => c.Name == "Zeus");
// Assert.Null(found);
ChampionEntity found = await context.Champions.SingleOrDefaultAsync(c => c.Name == "Zeus");
Assert.Null(found);
// await context.Champions.AddAsync(Dieu);
// await context.SaveChangesAsync();
await context.Champions.AddAsync(Dieu);
await context.SaveChangesAsync();
// found = await context.Champions.SingleOrDefaultAsync(c => c.Name == name);
// }
found = await context.Champions.SingleOrDefaultAsync(c => c.Name == name);
}
//}
}
}
}

Loading…
Cancel
Save