Conversation
|
|
||
| using NUnit.Framework; | ||
|
|
||
| public class WhenUpdatingAndNegativeBaseUnitPrice : ContextBase |
There was a problem hiding this comment.
is this testing a scenario that can ever actually happen? The only code I can see in the service under test (the purchase order service) that actually sets detail.BaseOrderUnitPrice is
current.BaseOrderUnitPrice = Math.Round(
current.OrderUnitPriceCurrency.GetValueOrDefault() / exchangeRate,
5,
MidpointRounding.AwayFromZero);
In this test you are just explicitly setting it to be negative via the detail constructor which I don't think matches reality, so not sure how much value this test adds?
Is this PR to fix a bug?
There was a problem hiding this comment.
It's happened a few times over the past few months and each time it seems to be that the base order unit price has somehow been set to a negative value. I can remove the test but I do think it should be a thing that we be checking it in that valid prices method.
There was a problem hiding this comment.
yeah - How do we recreate that bug? i.e. under what scenario can the derived BaseOrderUnitPrice field on a detail end up being set to be a negative number by the Sut? Could that exact scenario be arranged by the test? That way the the test will provide full confidence that the bug is squished
There was a problem hiding this comment.
Stewart really isn't sure how he's managed to do it and I followed the creation and update logic last week but it's not exactly clear how it could ever get into that state. I personally think it's potentially been the thing we've seen in the past where a user will scroll down the page and the focus is still on the field so it will mark it down to a negative number. Not an ideal scenario but this check should at least report the fault. Really scratching my head how he could have got the form into that state.
|
just noticed this branch was never merged - delete? |
I suppose it can be. I do still think that we should be guarding against this value being null but with Stewart not knowing how he's managed to get the form into that state (and from going through the code and seeing no possible way for it to get like that) it's a little hard to know how to test it. |
Plugging a hole
http://rndsupport.linn.co.uk/scp/tickets.php?id=21584