Skip to content

Commit 6e96034

Browse files
author
Tharindu Abeygunawardana
committed
Fix for broken unit tests
1 parent 7528446 commit 6e96034

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

Ndot/Controllers/Sr1FormController.cs

+6-11
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ public HttpResponseMessage Post(Sr1ClientFormData clientFormData)
4848
{
4949
_logger.Write("New Form Received");
5050
Sr1FormData form = null;
51-
try
52-
{
51+
5352
ValidateClientFormData(clientFormData);
5453

5554
form = new Sr1FormData
@@ -77,12 +76,12 @@ public HttpResponseMessage Post(Sr1ClientFormData clientFormData)
7776
if (!String.IsNullOrEmpty(clientActor.DlBarCode))
7877
{
7978
var byteArray = Convert.FromBase64String(clientActor.DlBarCode);
80-
var a = Image.FromStream(new MemoryStream(byteArray));
81-
a.Save(
79+
var img = Image.FromStream(new MemoryStream(byteArray));
80+
/* img.Save(
8281
Path.Combine(AppDomain.CurrentDomain.GetData("DataDirectory").ToString(),
8382
Guid.NewGuid() + ".jpg"),
84-
ImageFormat.Jpeg);
85-
var bmp = (Bitmap) a;
83+
ImageFormat.Jpeg);*/
84+
var bmp = (Bitmap) img;
8685

8786
var barCodeDecoderResult = reader.Decode(bmp);
8887
if (barCodeDecoderResult != null)
@@ -123,11 +122,7 @@ public HttpResponseMessage Post(Sr1ClientFormData clientFormData)
123122
var hubContext = GlobalHost.ConnectionManager.GetHubContext<IncidentsHub>();
124123
hubContext.Clients.All.addNewMarkerToPage(form.Latitude, form.Longitude,
125124
form.Street, form.CreatedDate.ToString(), form.Actors.Count);
126-
}
127-
catch (Exception e)
128-
{
129-
_logger.Write(String.Format("Some Error occurred in Sr1FormController. Exception: {0}", e));
130-
}
125+
131126

132127
var response = Request.CreateResponse(HttpStatusCode.Created, form);
133128
var url = Url.Link("DefaultApi", new {id = form.Id});

Ndot/Controllers/ValidateDlImageController.cs

+2-6
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,9 @@ public bool Post([FromBody]string image)
3333
reader.Options.TryHarder = true;
3434
reader.Options.PossibleFormats = new List<BarcodeFormat> {BarcodeFormat.PDF_417};
3535
var byteArray = Convert.FromBase64String(image);
36-
var a = Image.FromStream(new MemoryStream(byteArray));
37-
var bmp = (Bitmap) a ;
38-
/*bmp.Save(Guid.NewGuid() + ".jpg",ImageFormat.Jpeg);*/
39-
a.Save(Path.Combine(AppDomain.CurrentDomain.GetData("DataDirectory").ToString(), Guid.NewGuid() + ".jpg"),
40-
ImageFormat.Jpeg);
36+
var img = Image.FromStream(new MemoryStream(byteArray));
37+
var bmp = (Bitmap) img ;
4138
barCodeDecoderResult = reader.Decode(bmp);
42-
4339
validationResult = barCodeDecoderResult != null;
4440
}
4541
catch (Exception e)

0 commit comments

Comments
 (0)