public void ItValidatesLastInstructinoLineOnce() { var lines = new List <string>() { "add 3", "multiply 5", "apply 3" }; var instructionSetService = new InstructionSetService(mockValidator.Object); instructionSetService.GetInstructionSet(lines); mockValidator.Verify(v => v.ValidateLastLine(It.IsAny <string>()), Times.Once); }
public void ItValidatesAllInstructionLines() { var lines = new List <string>() { "add 3", "multiply 5", "apply 3" }; var instructionSetService = new InstructionSetService(mockValidator.Object); instructionSetService.GetInstructionSet(lines); mockValidator.Verify(v => v.Validate(It.IsAny <string>()), Times.Exactly(3)); }
public void ItValidatesTrimmedInstructionLine(string instruction, string validatedInstruction) { var lines = new List <string>() { instruction }; var instructionSetService = new InstructionSetService(mockValidator.Object); var validatedInput = ""; mockValidator.Setup(v => v.Validate(It.IsAny <string>())).Callback <string>(l => validatedInput = l); instructionSetService.GetInstructionSet(lines); Assert.Equal(validatedInstruction, validatedInput); }
public void ItValidatesLastInstructionLine(string applyLine) { var lines = new List <string>() { "add 3", "multiply 5", applyLine }; var instructionSetService = new InstructionSetService(mockValidator.Object); var expectedLastline = ""; mockValidator.Setup(v => v.ValidateLastLine(It.IsAny <string>())) .Callback <string>(l => expectedLastline = l); instructionSetService.GetInstructionSet(lines); mockValidator.Verify(v => v.ValidateLastLine(It.IsAny <string>()), Times.Once); Assert.Equal(applyLine, expectedLastline); }
public void ItTrimsLinesInTheInputDataFile() { var lines = new List <string>() { "add 3 \r \n", "subtract 5 ", "apply 3 \r " }; var instructionSetService = new InstructionSetService(mockValidator.Object); var set = instructionSetService.GetInstructionSet(lines); var addInstruction = set.Instructions.SingleOrDefault(i => i.Operator == "add"); var subtractInstruction = set.Instructions.SingleOrDefault(i => i.Operator == "subtract"); Assert.Equal(3, set.ApplyNumber); Assert.Equal(2, set.Instructions.Count()); Assert.NotNull(addInstruction); Assert.Equal(3, addInstruction.Number); Assert.False(addInstruction.IsApplyNumber); Assert.NotNull(subtractInstruction); Assert.Equal(5, subtractInstruction.Number); Assert.False(subtractInstruction.IsApplyNumber); }