Ejemplo n.º 1
0
        public Response DeleteMarker(DeleteMarkerRequest request)
        {
            Response response = new DeleteMarkerResponseOk(request);

            try
            {
                _drawingDal.DeleteMarker(request.MarkerId);
            }
            catch (Exception e)
            {
                response = new AppResponseError(e.Message);
            }
            return(response);
        }
        public void TestDeleteMarkerValidId_DeleteMarkerResponseOk()
        {
            var       expectedType = typeof(DeleteMarkerResponseOk);
            const int dataCount    = 5;
            var       random       = new Random();

            //given a database with some markers
            var dummyData = _testUtilitiesImpl
                            .CreateDummyMarkerData(_markerService, dataCount, _createdDocuments[0], _createdUsers[0]);

            var markerIdsBeforeDelete =
                ((GetMarkersResponseOk)_markerService.GetAllMarkers(_createdDocuments[0]))
                .Markers
                .Select(obj => obj.MarkerId)
                .ToArray();

            //when we delete marker with non existing id
            var request = new DeleteMarkerRequest()
            {
                MarkerId = markerIdsBeforeDelete[random.Next(markerIdsBeforeDelete.Length)]
            };
            var result = _markerService.DeleteMarker(request);

            //then we get a DeleteMarkerResponseOk
            //and one marker is deleted from the document
            var markerIdsAfterDelete =
                ((GetMarkersResponseOk)_markerService.GetAllMarkers(_createdDocuments[0]))
                .Markers
                .Select(obj => obj.MarkerId)
                .ToArray();

            Assert.Multiple(() =>
            {
                Assert.That(result, Is.TypeOf(expectedType));
                Assert.That(markerIdsAfterDelete.Length, Is.EqualTo(markerIdsBeforeDelete.Length - 1));
            });

            _testUtilitiesImpl.DestroyMarkersDummyData(_markerService, dummyData.ToArray());
        }
 public DeleteMarkerResponseOk(DeleteMarkerRequest request)
 {
     Request = request;
 }
 public Response DeleteMarkerById([FromBody] DeleteMarkerRequest request)
 {
     return(_markerService.DeleteMarker(request));
 }