public void Constructor_GivenNullSequencesRetriever_ShouldThrowError() { ISequencesRetriever sequencesRetriever = null; var exception = Record.Exception(() => new SequenceController(sequencesRetriever)); Assert.IsType <ArgumentNullException>(exception); }
public void LoadSequence_GivenMoves_ReturnSequence() { var moves = new char[] { 'a' }; Mock <ISequencesRetriever> mockSequencesRetriever = new Mock <ISequencesRetriever>(); mockSequencesRetriever.Setup(m => m.GetNextSequenceOfMoves()).Returns(moves); ISequencesRetriever sequencesRetriever = mockSequencesRetriever.Object; var sut = new SequenceController(sequencesRetriever); var result = sut.LoadSequence(); Assert.IsType <Sequence>(result); }
public void LoadSequence_GivenEmptyMoves_ReturnNull() { char[] moves = Array.Empty <char>(); Mock <ISequencesRetriever> mockSequencesRetriever = new Mock <ISequencesRetriever>(); mockSequencesRetriever.Setup(m => m.GetNextSequenceOfMoves()).Returns(moves); ISequencesRetriever sequencesRetriever = mockSequencesRetriever.Object; var sut = new SequenceController(sequencesRetriever); var result = sut.LoadSequence(); Assert.Null(result); }
public void LoadSequence_GivenMoreMoves_ReturnSequenceIdIncremented() { var moves = new char[] { 'a' }; Mock <ISequencesRetriever> mockSequencesRetriever = new Mock <ISequencesRetriever>(); mockSequencesRetriever.Setup(m => m.GetNextSequenceOfMoves()).Returns(moves); ISequencesRetriever sequencesRetriever = mockSequencesRetriever.Object; var sut = new SequenceController(sequencesRetriever); var firstResult = (Sequence)sut.LoadSequence(); var secondResult = (Sequence)sut.LoadSequence(); Assert.Equal(firstResult.SequenceId + 1, secondResult.SequenceId); }
public SequenceController(ISequencesRetriever sequencesRetriever) { _sequencesRetriever = sequencesRetriever ?? throw new System.ArgumentNullException(nameof(sequencesRetriever)); }