public void when_the_input_is_correct_then_it_should_return_a_successfull_response() { String shapeName = ApplicationConstants.ShapeName.SQUARE; OutputDto expectedOutput = new OutputDto( shapeName, ApplicationConstants.Operation.AREA, 4, ApplicationConstants.Status.SUCCESS, "Operation ran successfully"); List <Double> values = new List <Double>(); values.Add(2); Shape shape = ModuleConfig.createShape(shapeName, values); InputAdapterDto input = new InputAdapterDto(shape, "area", values); Interactor shapeInteractor = new ShapeInteractor(); OutputDto response = shapeInteractor.execute(input); Assert.IsNotNull(response); Assert.AreEqual(expectedOutput.Shape, response.Shape); Assert.AreEqual(expectedOutput.Operation, response.Operation); Assert.AreEqual(expectedOutput.ResponseStatus, response.ResponseStatus); Assert.AreEqual(expectedOutput.ValueResponse, response.ValueResponse); Assert.AreEqual(expectedOutput.Message, response.Message); }
public void when_the_path_is_not_correct_then_it_should_return_an_error_response() { List <VialDto> list = new List <VialDto>(); list.Add(expectedVial); String fileName = "vial-tst.csv"; String expectedMessage = "There was an exception while trying to access the data. Message: Could not find file '" + Path.GetFullPath(ApplicationConstants.Resources.VIAL_CSV_FOLDER + "\\" + fileName) + "'."; Output output = new OutputVialDto( new List <VialDto>(), ApplicationConstants.Status.ERROR, expectedMessage); OutputVialDto expectedOutput = (OutputVialDto)output; String absolutePath = Path.GetFullPath(ApplicationConstants.Resources.VIAL_CSV_FOLDER + "\\" + fileName); InputAdapterDto inputDto = new InputAdapterDto(); inputDto.Path = absolutePath; Interactor interactor = new FileVialReader(); Output result = interactor.execute(inputDto); OutputVialDto resultOutput = (OutputVialDto)result; Assert.IsNotNull(result); Assert.AreEqual(expectedOutput.getResponseStatus(), resultOutput.getResponseStatus()); Assert.AreEqual(expectedOutput.getMessage(), resultOutput.getMessage()); }
private void addAdaptedListsToInputAdapter(InputAdapterDto input, List <String> listColors, List <String> listRemovedColors) { List <List <String> > listAdapter = new List <List <String> >(); listAdapter.Add(listColors); listAdapter.Add(listRemovedColors); input.setValue(listAdapter); }
public void execute(Input input) { String text = (String)input.getValue(); Input inputAdapter = new InputAdapterDto(); List <String> listWords = convertTextToList(text); List <String> listWithoutEmpty = getListWithoutEmpty(listWords); inputAdapter.setValue(listWithoutEmpty); performResponse(inputAdapter); }
public Output execute(Input input) { InputAdapterDto inputAdapter = (InputAdapterDto)input; List <List <String> > listString = (List <List <String> >)inputAdapter.getValue(); if (inputAdapter.getOperation().Equals(ApplicationConstants.Operation.COMPLETED_LIST)) { return(new OutputListDto(listString[0], "printing completed list")); } else { List <String> removedList = getRemovedList(listString[0], listString[1]); return(new OutputListDto(removedList, "printing removed list")); } }
public Output execute(InputAdapterDto input) { try { this.input = input; getAllVialRepository = createGetAllVialRepository(); List <VialDto> listVialDto = getAllVialRepository.execute(input.Path); return(prepareSuccessfullResponse(listVialDto)); } catch (Exception e) { return(prepareErrorResponse(e.Message)); } }
public void execute(InputAdapterDto inputAdapterDto) { String shapeName = inputAdapterDto.Shape.getName(); List <Double> values = inputAdapterDto.Values; if ((shapeName.Equals(ApplicationConstants.ShapeName.SQUARE, StringComparison.InvariantCultureIgnoreCase) && values.Count != 1) || (shapeName.Equals(ApplicationConstants.ShapeName.TRIANGLE, StringComparison.InvariantCultureIgnoreCase) && values.Count != 3) || (shapeName.Equals(ApplicationConstants.ShapeName.RECTANGLE, StringComparison.InvariantCultureIgnoreCase) && values.Count != 2) ) { throw new InvalidAmountOfSidesException(shapeName); } }
public void execute(InputDto input) { presenter = new ConsoleListPresenter(); inputAdapter = new InputAdapterDto(); String[] colors = input.Colors; String[] removeColors = input.Removecolors; List <String> listColors = convertToList(colors); List <String> listRemoveColors = convertToList(removeColors); addAdaptedListsToInputAdapter(inputAdapter, listColors, listRemoveColors); performOperation(ApplicationConstants.Operation.COMPLETED_LIST); performOperation(ApplicationConstants.Operation.REMOVED_LIST); }
public Output execute(InputAdapterDto input) { try { this.input = input; getAllNetflixRatingRepository = createGetAllNetflixRatingRepository(); List <NetflixRating> listNetflixRating = getAllNetflixRatingRepository.execute(input.Path); Dictionary <int, int> userMoreRatings = prepareUserWithRating(listNetflixRating); return(prepareSuccessfullResponse(userMoreRatings)); } catch (Exception e) { return(prepareErrorResponse(e.Message)); } }
public OutputDto execute(InputAdapterDto input) { try { this.input = input; invokeValidations(); shape = input.Shape; double response = isAreaOperation(input.Operation) ? callAreaCalculation() : callPerimeterCalculation(); return(prepareSuccessfullResponse(response)); } catch (Exception e) { return(prepareErrorResponse(e.Message)); } }
public void when_the_input_is_not_correct_then_it_should_return_an_error_response() { String shapeName = "triangle"; String operation = "area"; OutputDto expectedOutput = new OutputDto( shapeName, ApplicationConstants.Operation.AREA, 0, ApplicationConstants.Status.ERROR, "The values of the sides must not be negative"); double valueA = 2; double valueB = -1; double valueC = 2; List <Double> values = new List <Double>(); values.Add(valueA); values.Add(valueB); values.Add(valueC); Shape shape = new Triangle(valueA, valueB, valueC); InputAdapterDto input = new InputAdapterDto(shape, operation, values); Interactor shapeInteractor = new ShapeInteractor(); OutputDto response = shapeInteractor.execute(input); Assert.IsNotNull(response); Assert.AreEqual(expectedOutput.Shape, response.Shape); Assert.AreEqual(expectedOutput.Operation, response.Operation); Assert.AreEqual(expectedOutput.ResponseStatus, response.ResponseStatus); Assert.AreEqual(expectedOutput.ValueResponse, response.ValueResponse); Assert.AreEqual(expectedOutput.Message, response.Message); }
public void when_the_input_is_correct_then_it_should_return_a_successfull_response() { List <VialDto> list = new List <VialDto>(); list.Add(expectedVial); Output output = new OutputVialDto(list, ApplicationConstants.Status.SUCCESS, "Operation ran successfully"); OutputVialDto expectedOutput = (OutputVialDto)output; String absolutePath = Path.GetFullPath(ApplicationConstants.Resources.VIAL_CSV_FOLDER + "\\" + "vial-test.csv"); InputAdapterDto inputDto = new InputAdapterDto(); inputDto.Path = absolutePath; Interactor interactor = new FileVialReader(); Output result = interactor.execute(inputDto); OutputVialDto resultOutput = (OutputVialDto)result; VialDto resultVial = ((List <VialDto>)resultOutput.getResponse())[0]; Assert.IsNotNull(result); Assert.AreEqual(expectedVial.N_sheet, resultVial.N_sheet); Assert.AreEqual(expectedVial.ObjectType, resultVial.ObjectType); Assert.AreEqual(expectedVial.IdSection, resultVial.IdSection); Assert.AreEqual(expectedVial.PathType, resultVial.PathType); Assert.AreEqual(expectedVial.Lenght, resultVial.Lenght); Assert.AreEqual(expectedOutput.getResponseStatus(), resultOutput.getResponseStatus()); Assert.AreEqual(expectedOutput.getMessage(), resultOutput.getMessage()); }
public ControllerShape(InputDto inputDto) { this.inputAdapterDto = new InputAdapterDto(); this.inputDto = inputDto; }
public FileController(InputDto inputDto) { this.inputAdapterDto = new InputAdapterDto(); this.inputDto = inputDto; }