public void Create_NoDuplicatedPoints_ReturnsCreatedPointsListObjWithAllPoints() { // Arrange var service = this.CreateService(); CreatePointsListRequest model = new CreatePointsListRequest { Points = threePoints }; mockPointsListRepository.Setup(r => r.Add(It.IsAny <PointsList>())); // Act var result = service.Create(model); // Assert mockPointsListRepository.Verify(r => r.Add(It.IsAny <PointsList>()), Times.Exactly(1)); }
public PointsList Create(CreatePointsListRequest model) { var newPointsList = new PointsList { Points = new List <Point>() }; if (model.Points != null && model.Points.Any()) { foreach (var point in model.Points) { if (!newPointsList.Points.Contains(point)) { newPointsList.Points.Add(point); } } } _unitOfWork.PointsListRepository.Add(newPointsList); _unitOfWork.Commit(); return(newPointsList); }
public void SetUp() { mockedPointsListEmpty = new PointsList { Id = 1, Points = new List <Point>(), Squares = new List <Square>(), IsSquaresUpdateNeeded = false }; mockedPointsListOneSquare = new PointsList { Id = 2, Points = simpleSquare, Squares = new List <Square>() { new Square { Points = simpleSquare } }, IsSquaresUpdateNeeded = false }; validCreatePointsListRequest = new CreatePointsListRequest { Points = simpleSquare }; this.mockRepository = new MockRepository(MockBehavior.Strict); this.mockPointsListService = this.mockRepository.Create <IPointsListService>(); }
public IActionResult Create(CreatePointsListRequest model) { return(Ok(_pointsListService.Create(model))); }