public void Display_ServiceResultMessageIsInvalid_NothingIsWrittenToUserInterface(string resultMessage) { // Arrange var userInterface = new Mock<IUserInterface>(); IServiceResult serviceResult = new ServiceResult(ServiceResultType.Success, resultMessage); // Act this.serviceResultVisualizer.Display(userInterface.Object, serviceResult); // Assert userInterface.Verify(u => u.WriteLine(It.IsAny<string>()), Times.Never()); }
public void Display_ServiceResultIsValid_InnerResultIsEmpty_MessageIsWrittenToUserInterface(ServiceResultType resultType) { // Arrange var userInterface = new Mock<IUserInterface>(); string resultMessage = "Yada Yada"; IServiceResult serviceResult = new ServiceResult(resultType, resultMessage); // Act this.serviceResultVisualizer.Display(userInterface.Object, serviceResult); // Assert userInterface.Verify(u => u.WriteLine(It.Is<string>(message => message.EndsWith(resultMessage))), Times.Once()); }
public void Display_ServiceResultIsValid_ContainsResultArtefact_MessageIsWrittenToUserInterface() { // Arrange var userInterface = new Mock<IUserInterface>(); string resultArtefact = "Bla Bla"; IServiceResult serviceResult = new ServiceResult(ServiceResultType.Success, "Yada Yada") { ResultArtefact = resultArtefact }; // Act this.serviceResultVisualizer.Display(userInterface.Object, serviceResult); // Assert userInterface.Verify(u => u.WriteLine(It.Is<string>(message => message.EndsWith(resultArtefact))), Times.Once()); }
public void Display_ServiceResultIsValid_InnerResultIsEmpty_ContainsResultArtefact_MessageIsWrittenToUserInterface() { // Arrange var userInterface = new Mock<IUserInterface>(); IServiceResult innerResult2 = new ServiceResult(ServiceResultType.Success, Guid.NewGuid().ToString()); IServiceResult innerResult1 = new ServiceResult(ServiceResultType.Failure, Guid.NewGuid().ToString()) { InnerResult = innerResult2 }; IServiceResult mainResult = new ServiceResult(ServiceResultType.Success, Guid.NewGuid().ToString()) { InnerResult = innerResult1 }; // Act this.serviceResultVisualizer.Display(userInterface.Object, mainResult); // Assert userInterface.Verify(u => u.WriteLine(It.Is<string>(message => message.EndsWith(innerResult1.Message))), Times.Once()); userInterface.Verify(u => u.WriteLine(It.Is<string>(message => message.EndsWith(innerResult2.Message))), Times.Once()); userInterface.Verify(u => u.WriteLine(It.Is<string>(message => message.EndsWith(mainResult.Message))), Times.Once()); }
public void UserInterfaceContent_ContainsTextThatIsWrittenUsing_Display_ServiceResult() { // Arrange string text = "Some Message"; var serviceResult = new ServiceResult(ServiceResultType.Success, text); var textManipulation = new Mock<IConsoleTextManipulation>(); var logger = new Mock<IActionLogger>(); var serviceResultVisualizer = new ConsoleServiceResultVisualizer(); var consoleUserInterface = new ConsoleUserInterface(textManipulation.Object, logger.Object, serviceResultVisualizer); // Act consoleUserInterface.Display(serviceResult); var result = consoleUserInterface.UserInterfaceContent; // Assert Assert.IsTrue(result.Contains(text)); }