public void SaveRouteCommnad_ThrowCostRequiredBiggerThanZero()
        {
            //Arrenge
            SaveRouteRequest request = new SaveRouteRequest
            {
                Cost = 0,
                Time = 10
            };

            //Act
            new SaveRouteCommand(_routedataMock.Object).Execute(request);
        }
Beispiel #2
0
        public ActionResult SaveRoute(SaveRouteRequest saveRouteRequest)
        {
            SaveRouteResponse saveRouteResponse = new SaveRouteResponse();

            try
            {
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
            return(Ok(saveRouteResponse));
        }
        public void SaveRouteCommnad_ThrowRouteAlreadyExists()
        {
            //Arrenge
            SaveRouteRequest request = new SaveRouteRequest
            {
                PointFromCode = "test_from",
                PointToCode   = "teste_to",
                Cost          = 1,
                Time          = 10
            };

            _routedataMock.Setup(p => p.GetRoute(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new Route());

            //Act
            new SaveRouteCommand(_routedataMock.Object).Execute(request);
        }
        public void SaveRouteCommnad_Ok_LowerCase()
        {
            //Arrenge
            SaveRouteRequest request = new SaveRouteRequest
            {
                PointFromCode = "TEST_FROM",
                PointToCode   = "TESTE_TO",
                Cost          = 1,
                Time          = 10
            };

            _routedataMock.Setup(p => p.GetRoute(It.IsIn(request.PointFromCode), It.IsIn(request.PointToCode)))
            .Returns(new Route());

            //Act
            new SaveRouteCommand(_routedataMock.Object).Execute(request);

            //Assert
            _routedataMock.Verify(p => p.Save(It.Is((Route r) =>
                                                    r.PointFromCode.Equals(request.PointFromCode.ToLower()) &&
                                                    r.PointToCode.Equals(request.PointToCode.ToLower())
                                                    )));
        }
        public void SaveRouteCommnad_Ok()
        {
            //Arrenge
            SaveRouteRequest request = new SaveRouteRequest
            {
                PointFromCode = "test_from",
                PointToCode   = "teste_to",
                Cost          = 1,
                Time          = 10
            };

            _routedataMock.Setup(p => p.GetRoute(It.IsIn(request.PointFromCode), It.IsIn(request.PointToCode)));

            //Act
            new SaveRouteCommand(_routedataMock.Object).Execute(request);

            //Assert
            _routedataMock.Verify(p => p.Save(It.Is((Route r) =>
                                                    r.PointFromCode.Equals(request.PointFromCode) &&
                                                    r.PointToCode.Equals(request.PointToCode) &&
                                                    r.Cost == request.Cost &&
                                                    r.Time == request.Time
                                                    )));
        }
Beispiel #6
0
        public IActionResult Save([FromBody] SaveRouteRequest request)
        {
            _saveRouteCommand.Execute(request);

            return(NoContent());
        }