-
Notifications
You must be signed in to change notification settings - Fork 0
SK Ticket #767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RossStewart
wants to merge
2
commits into
main
Choose a base branch
from
febTicket1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
SK Ticket #767
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...t/Domain.LinnApps.Tests/PurchaseOrderServiceTests/WhenUpdatingAndNegativeBaseUnitPrice.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| namespace Linn.Purchasing.Domain.LinnApps.Tests.PurchaseOrderServiceTests | ||
| { | ||
| using System; | ||
| using System.Collections.Generic; | ||
|
|
||
| using FluentAssertions; | ||
|
|
||
| using Linn.Purchasing.Domain.LinnApps.Exceptions; | ||
| using Linn.Purchasing.Domain.LinnApps.PurchaseLedger; | ||
| using Linn.Purchasing.Domain.LinnApps.PurchaseOrders; | ||
|
|
||
| using NSubstitute; | ||
|
|
||
| using NUnit.Framework; | ||
|
|
||
| public class WhenUpdatingAndNegativeBaseUnitPrice : ContextBase | ||
| { | ||
| private readonly int orderNumber = 600179; | ||
|
|
||
| private PurchaseOrder updated; | ||
|
|
||
| private Action act; | ||
|
|
||
| [SetUp] | ||
| public void SetUp() | ||
| { | ||
| this.updated = new PurchaseOrder | ||
| { | ||
| OrderNumber = this.orderNumber, | ||
| Details = | ||
| new List<PurchaseOrderDetail> | ||
| { | ||
| new PurchaseOrderDetail | ||
| { | ||
| Cancelled = "N", | ||
| Line = 1, | ||
| BaseNetTotal = 100m, | ||
| NetTotalCurrency = 120m, | ||
| BaseOrderUnitPrice = -100m, | ||
| OrderNumber = this.orderNumber, | ||
| OurQty = 99m, | ||
| OrderQty = 12m, | ||
| PartNumber = "P" | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| this.MockAuthService.HasPermissionFor(AuthorisedAction.PurchaseOrderUpdate, Arg.Any<IEnumerable<string>>()) | ||
| .Returns(true); | ||
|
|
||
| this.PurchaseLedgerMaster.GetRecord().Returns(new PurchaseLedgerMaster { OkToRaiseOrder = "Y" }); | ||
|
|
||
| this.act = () => this.Sut.UpdateOrder(new PurchaseOrder(), this.updated, new List<string>()); | ||
| } | ||
|
|
||
|
|
||
| [Test] | ||
| public void ShouldThrow() | ||
| { | ||
| this.act.Should().Throw<PurchaseOrderException>("Prices must be positive numbers"); | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.