public void ThrowsArgumentExceptionWhereCharacterNameParameterEmptyForGetAllThrows() { var sut = new DefaultMoveService(new Mock <IRepository <IMove> >().Object, new GameParameterParserService("Smash4")); Assert.Throws <ArgumentNullException>(() => { sut.GetAllThrowsWhereCharacterNameIs(string.Empty); }); }
public void VerifyGetAllThrowsForCharacterCallsGetAllWhere() { var items = new List <Move> { new Move { Name = "test", Owner = "testowner" } }; var mockRepository = new Mock <IRepository <IMove> >(); ConfigureGetAllWhereOnMockRepository(mockRepository, items); var sut = new DefaultMoveService(mockRepository.Object, new GameParameterParserService("Smash4")); sut.GetAllThrowsWhereCharacterNameIs("dummyValue"); mockRepository.VerifyAll(); }
public void GetThrowsForCharacterGetsOnlyThrowMovesForThatCharacter() { const string expectedCharacterName = "mario"; const string throwName = "throw"; const string grabName = "grab"; var items = new List <Move> { new Move { Name = "fthrow", MoveType = MoveType.Throw.GetEnumDescription(), Owner = expectedCharacterName }, new Move { Name = "dash grab", MoveType = MoveType.Throw.GetEnumDescription(), Owner = "ganondorf" }, new Move { Name = "nair", MoveType = MoveType.Aerial.GetEnumDescription(), Owner = expectedCharacterName } }; var mockRepository = new Mock <IRepository <IMove> >(); ConfigureGetAllWhereOnMockRepository(mockRepository, items); var sut = new DefaultMoveService(mockRepository.Object, new GameParameterParserService("Smash4")); var results = sut.GetAllThrowsWhereCharacterNameIs(expectedCharacterName).ToList(); Assert.That(results.Count, Is.EqualTo(1), $"{nameof(results.Count)}"); results.ForEach(result => { Assert.That(result.Owner, Is.EqualTo(expectedCharacterName), $"{result.Owner}"); Assert.That(result.MoveType, Is.EqualTo(MoveType.Throw.GetEnumDescription()), $"{nameof(result.MoveType)}"); Assert.That(result.Name.Contains(throwName) || result.Name.Contains(grabName), $"expecting name '{result.Name} to contain {throwName} or '{grabName}'"); }); }
public void ReturnsEmptyEnumerableForNoThrowMovesForValidCharacter() { const string expectedCharacterName = "testCharacter"; var items = new List <Move> { new Move { Name = "test", Owner = expectedCharacterName, MoveType = MoveType.Aerial.GetEnumDescription() } }; var mockRepository = new Mock <IRepository <IMove> >(); ConfigureGetAllWhereOnMockRepository(mockRepository, items); var sut = new DefaultMoveService(mockRepository.Object, new GameParameterParserService("Smash4")); var results = sut.GetAllThrowsWhereCharacterNameIs(expectedCharacterName); // ReSharper disable once PossibleMultipleEnumeration Assert.That(results, Is.Not.Null, "should not be null."); // ReSharper disable once PossibleMultipleEnumeration Assert.That(results, Is.Empty, "should be empty."); }