public string Run() { _console.WriteLine("Please input base (as a double): "); string inputBase = _console.ReadLine(); _console.WriteLine("Please input height (as a double): "); string inputHeight = _console.ReadLine(); double base_ = _dubl.Parse(inputBase); double height = _dubl.Parse(inputHeight); return($"Triangle with base {base_} and height {height} area is {(base_ * height) / 2}"); }
public void ParsesBaseAndHeight() { var first = "5.0"; var second = "8.0"; _console.ReadLine().Returns(first, second); Run(); Received.InOrder(() => { _double.Parse(first); _double.Parse(second); }); }
public string Run() { _console.WriteLine("Please input radius (as a double): "); string line = _console.ReadLine(); double radius = _dubl.Parse(line); return($"Circle area for radius of {radius} is {Math.PI * radius * radius}"); }
public string Run() { _console.WriteLine("Please input width (as a double): "); string input = _console.ReadLine(); double parsed = _dubl.Parse(input); return($"Square of width {parsed} is {parsed * parsed}"); }
public void OutputsResult() { var parsedWidth = 5.0; _double.Parse(Arg.Any <string>()).Returns(parsedWidth); string result = Run(); Assert.That(result, Is.EqualTo($"Square of width {parsedWidth} is {parsedWidth*parsedWidth}")); }
public void OutputsResult() { // real app would have separate calculation and tests var parsedRadius = 3.5; _double.Parse(Arg.Any <string>()).Returns(parsedRadius); var result = Run(); Assert.That(result, Is.EqualTo($"Circle area for radius of {parsedRadius} is {Math.PI * parsedRadius * parsedRadius}")); }