static async Task Main(string[] args) { Console.WriteLine("Start your calculation journey!"); var calculationContext = new CalculationContext(); ICalculationService service = new CalculationService(new InputFormatService(new InputService()), new OutputService()); await service.Calc(calculationContext); Console.Read(); }
public async Task Calc_Success() { var inputService = new Mock <IInputFormatService>(); var outputService = new Mock <IOutputService>(); var context = new CalculationContext(); inputService.Setup(s => s.GetInput()).ReturnsInOrderAsync(new List <InputDto>() { new InputDto("5", 1), new InputDto("2", 3), new InputDto("-", 5), }, null); var service = new CalculationService(inputService.Object, outputService.Object); await service.Calc(context); context.CalculationData.Count.Should().Be(1); context.CalculationData.Pop().Should().Be(3); }
public async Task Calc_InvalidOperationException() { var inputService = new Mock <IInputFormatService>(); var outputService = new Mock <IOutputService>(); var context = new CalculationContext(); inputService.Setup(s => s.GetInput()).ReturnsInOrderAsync(new List <InputDto>() { new InputDto("5", 1), new InputDto("2", 3), new InputDto("-", 5), new InputDto("abc", 7), }, null); var service = new CalculationService(inputService.Object, outputService.Object); await service.Calc(context); context.CalculationData.Count.Should().Be(1); context.CalculationData.Pop().Should().Be(3); outputService.Verify(s => s.Output("'abc' is not a valid display name in CalculatorDemo.Application.Domain.CalculationOperationType"), Times.Once); }
public async Task Calc_ParameterCountNotMatchExceptions() { var inputService = new Mock <IInputFormatService>(); var outputService = new Mock <IOutputService>(); var context = new CalculationContext(); inputService.Setup(s => s.GetInput()).ReturnsInOrderAsync(new List <InputDto>() { new InputDto("5", 1), new InputDto("2", 3), new InputDto("-", 5), }, new List <InputDto>() { new InputDto("-", 1), }, null); var service = new CalculationService(inputService.Object, outputService.Object); await service.Calc(context); context.CalculationData.Count.Should().Be(1); context.CalculationData.Pop().Should().Be(3); outputService.Verify(s => s.Output("operator - (position: 1): insucient parameters"), Times.Once); }