changes to test to task, to check sequence equal
continuous-integration/drone/push Build is failing Details

test_dice_group_manager
mzjeeawody 3 years ago
parent 69821cea42
commit 5432a07e9e

@ -87,56 +87,97 @@ namespace Tests.Data_UTs.Dice
} }
/*
[Fact] [Fact]
public void TestAddIfAlreadyExistsThrowsException() public async Task TestGetOneByIdThrowsException()
{ {
// Arrange
DiceGroupManager dgm = new(); DiceGroupManager dgm = new();
// Act // Act
KeyValuePair<string, IEnumerable<Die>> toAdd = new("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
DiceGroup diceGroup = new DiceGroup("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
dgm.Add(diceGroup);
void action() => dgm.Add(diceGroup); async Task action() => dgm.GetOneByID(new("9657b6f0-9431-458e-a2bd-4bb0c7d4a6ed"));
// Assert // Assert
Xunit.Assert.Throws<ArgumentException>(action); await Xunit.Assert.ThrowsAsync<NotImplementedException>(action);
}
[Theory]
[InlineData("")]
[InlineData(null)]
[InlineData(" ")]
public async Task TestGetOneByNameIfInvalidThrowsException(string name)
{
// Arrange
DiceGroupManager dgm = new();
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);
async Task action() => dgm.GetOneByName(name);
// Assert
await Xunit.Assert.ThrowsAsync<ArgumentNullException>(action);
} }
[Fact] [Fact]
public void TestGetOneByIdThrowsException() public async Task TestRemoveWorksIfExists()
{ {
// Arrange // Arrange
DiceGroupManager dgm = new(); DiceGroupManager dgm = new();
// KeyValuePair<string, IEnumerable<Die>> toAdd = new("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
DiceGroup diceGroup = new ("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
// Act await dgm.Add(diceGroup);
dgm.Remove(diceGroup);
Xunit.Assert.DoesNotContain(diceGroup, await dgm.GetAll());
}
void action() => dgm.GetOneByID(new("9657b6f0-9431-458e-a2bd-4bb0c7d4a6ed")); [Fact]
public async void TestRemoveFailsSilentlyIfGivenNonExistent()
{
DiceGroupManager dgm = new();
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);
DiceGroup toAdd2 = new("Scrabble", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
// Act
dgm.Remove(toAdd2);
// Assert // Assert
Xunit.Assert.Throws<NotImplementedException>(action); Xunit.Assert.DoesNotContain(toAdd2, await dgm.GetAll());
} }
[Theory] [Fact]//To check sequence equal does not work properly
[InlineData("")] public async Task TestUpdateWorksIfValid()
[InlineData(null)] {
[InlineData(" ")] // Arrange
public void TestGetOneByNameIfInvalidThrowsException(string name) DiceGroupManager dgm = new();
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);
DiceGroup toAdd2 = new("Scrabble", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
await dgm.Update(toAdd, toAdd2);
Xunit.Assert.DoesNotContain(toAdd, await dgm.GetAll());
Xunit.Assert.Contains(toAdd2, await dgm.GetAll());
}
/* [Fact]
public void TestUpdateWorksIfValid()
{ {
// Arrange // Arrange
DiceGroupManager dgm = new(); DiceGroupManager dgm = new();
KeyValuePair<string, IEnumerable<Die>> toAdd = new("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) }); KeyValuePair<string, IEnumerable<Die>> toAdd = new("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
DiceGroup diceGroup = new DiceGroup("Monopoly", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) }); dgm.Add(toAdd);
KeyValuePair<string, IEnumerable<Die>> toAdd2 = new("Scrabble", new List<NumberDie> { new NumberDie(new NumberFace(5), new NumberFace(7)), new NumberDie(new NumberFace(5), new NumberFace(7)) });
dgm.Update(toAdd, toAdd2);
dgm.Add(diceGroup); Xunit.Assert.DoesNotContain(toAdd, dgm.GetAll());
void action() => dgm.GetOneByName(name); Xunit.Assert.Contains(toAdd2, dgm.GetAll());
Xunit.Assert.True(dgm.GetAll().Count() == 1);
}*/
/*
// Assert
Xunit.Assert.Throws<ArgumentNullException>(action);
}
[Fact] [Fact]
public void TestRemoveWorksIfExists() public void TestRemoveWorksIfExists()

Loading…
Cancel
Save