|
|
@ -1,22 +1,22 @@
|
|
|
|
using Data;
|
|
|
|
using Data;
|
|
|
|
using Data.EF;
|
|
|
|
using Data.EF;
|
|
|
|
using Microsoft.Data.Sqlite;
|
|
|
|
using Microsoft.Data.Sqlite;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
using Model.Dice;
|
|
|
|
using Model.Dice;
|
|
|
|
using Model.Dice.Faces;
|
|
|
|
using Model.Dice.Faces;
|
|
|
|
using Model.Games;
|
|
|
|
using Model.Games;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Xunit;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Tests.Data_UTs.Dice
|
|
|
|
namespace Tests.Data_UTs.Dice
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class DiceGroupManagerTest
|
|
|
|
public class DiceGroupManagerTest
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private static readonly Task<MasterOfCeremonies> stubGameRunner = new Stub().LoadApp();
|
|
|
|
private static readonly Task<MasterOfCeremonies> stubGameRunner = new Stub().LoadApp();
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
@ -43,18 +43,18 @@ namespace Tests.Data_UTs.Dice
|
|
|
|
public async Task TestAddWhenDiceGroupThenDoAddAndReturnDiceGroup()
|
|
|
|
public async Task TestAddWhenDiceGroupThenDoAddAndReturnDiceGroup()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Arrange
|
|
|
|
// Arrange
|
|
|
|
DiceGroupManager dgm = new();
|
|
|
|
DiceGroupManager dgm = new();
|
|
|
|
DiceGroup group1 = new("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
|
|
|
|
DiceGroup group1 = new("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
|
|
|
|
DiceGroup group2 = new("Scrabble", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
|
|
|
|
DiceGroup group2 = new("Scrabble", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
|
|
|
|
|
|
|
|
|
|
|
|
//...storing the results of DiceGroupManager.Add() in variables
|
|
|
|
//...storing the results of DiceGroupManager.Add() in variables
|
|
|
|
Collection<DiceGroup> expected = new() {group1,group2 };
|
|
|
|
Collection<DiceGroup> expected = new() {group1,group2 };
|
|
|
|
Collection<DiceGroup> actual = new()
|
|
|
|
Collection<DiceGroup> actual = new()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await dgm.Add(group1),
|
|
|
|
await dgm.Add(group1),
|
|
|
|
await dgm.Add(group2)
|
|
|
|
await dgm.Add(group2)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
// Assert
|
|
|
|
// Assert
|
|
|
|
Xunit.Assert.Equal(expected, actual);
|
|
|
|
Xunit.Assert.Equal(expected, actual);
|
|
|
|
Xunit.Assert.Equal(expected, actual);
|
|
|
|
Xunit.Assert.Equal(expected, actual);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -68,8 +68,8 @@ namespace Tests.Data_UTs.Dice
|
|
|
|
async Task actionAsync() => await dgm.Add(expected);// Add() returns the added element if succesful
|
|
|
|
async Task actionAsync() => await dgm.Add(expected);// Add() returns the added element if succesful
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
// Assert
|
|
|
|
Xunit.Assert.Null(expected);
|
|
|
|
Xunit.Assert.Null(expected);
|
|
|
|
await Xunit.Assert.ThrowsAsync<ArgumentNullException>(actionAsync);
|
|
|
|
await Xunit.Assert.ThrowsAsync<ArgumentNullException>(actionAsync);
|
|
|
|
Xunit.Assert.DoesNotContain(expected, await dgm.GetAll());
|
|
|
|
Xunit.Assert.DoesNotContain(expected, await dgm.GetAll());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
[Fact]
|
|
|
|
[Fact]
|
|
|
@ -77,13 +77,13 @@ namespace Tests.Data_UTs.Dice
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DiceGroupManager dgm = new();
|
|
|
|
DiceGroupManager dgm = new();
|
|
|
|
|
|
|
|
|
|
|
|
await dgm.Add(new("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) }));
|
|
|
|
await dgm.AddCheckName(new("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) }));
|
|
|
|
DiceGroup group1 = new("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
|
|
|
|
DiceGroup group1 = new("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
|
|
|
|
|
|
|
|
|
|
|
|
async Task actionAsync() => await dgm.Add(group1);
|
|
|
|
async Task actionAsync() => await dgm.AddCheckName(group1);
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
// Assert
|
|
|
|
await Xunit.Assert.ThrowsAsync<Exception>(actionAsync);
|
|
|
|
await Xunit.Assert.ThrowsAsync<ArgumentException>(actionAsync);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -112,7 +112,7 @@ namespace Tests.Data_UTs.Dice
|
|
|
|
DiceGroup toAdd = new("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
|
|
|
|
DiceGroup toAdd = new("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
|
|
|
|
|
|
|
|
|
|
|
|
await dgm.Add(toAdd);
|
|
|
|
await dgm.Add(toAdd);
|
|
|
|
async Task action() => dgm.GetOneByName(name);
|
|
|
|
async Task action() => await dgm.GetOneByName(name);
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
// Assert
|
|
|
|
await Xunit.Assert.ThrowsAsync<ArgumentNullException>(action);
|
|
|
|
await Xunit.Assert.ThrowsAsync<ArgumentNullException>(action);
|
|
|
@ -237,5 +237,5 @@ namespace Tests.Data_UTs.Dice
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|