-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feature/ci (#18) * test ci * try to release on github * deploy only in master * beautify readme * try to fix deploy in master only * Feature/ci (#20) * test * test * fix * fix * dont deploy in pr * fix base url * fix warnings * update packages * Bug/23 (#27) * #23 add tests * add matcher * ignore rider files * add more tests * fix one case, break another * fix #23
- Loading branch information
1 parent
1e1f355
commit fa760d5
Showing
9 changed files
with
217 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# User files | ||
*.user | ||
.idea |
This file contains 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
This file contains 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,40 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Izzy.Web.Model; | ||
using Newtonsoft.Json; | ||
using NHamcrest; | ||
using Xunit; | ||
|
||
namespace Izzy.Web.Tests.Matchers | ||
{ | ||
public class HasTransfer : IMatcher<List<Transfer>> | ||
{ | ||
private Transfer _expected; | ||
|
||
public HasTransfer(Transfer expected) | ||
{ | ||
_expected = expected; | ||
} | ||
|
||
public void DescribeTo(IDescription description) | ||
{ | ||
description.AppendText("From DescribeTo"); | ||
} | ||
|
||
public bool Matches(List<Transfer> actual) | ||
{ | ||
return actual | ||
.Any( | ||
t => | ||
t.From == _expected.From | ||
&& t.To == _expected.To | ||
&& t.Roubles == _expected.Roubles | ||
); | ||
} | ||
|
||
public void DescribeMismatch(List<Transfer> item, IDescription description) | ||
{ | ||
description.AppendText("From DescribeMismatch").AppendText(JsonConvert.SerializeObject(item)); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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,31 @@ | ||
using System.Collections.Generic; | ||
using Izzy.Web.Model; | ||
using Izzy.Web.Tests.Matchers; | ||
using NHamcrest; | ||
using Xunit; | ||
|
||
namespace Izzy.Web.Tests.Receipts.OneMoreThanMiddle | ||
{ | ||
public class ThreePersons | ||
{ | ||
[Fact] | ||
public void Test() | ||
{ | ||
// Act | ||
var receipt = new Receipt( | ||
new List<Person>{ | ||
new Person("Alice", 100), | ||
new Person("Bob", 30), | ||
new Person("Carol", 20) | ||
} | ||
); | ||
|
||
var transfers = receipt.Transfers(); | ||
|
||
// Assert | ||
NHamcrest.XUnit.Assert.That(transfers, Is.OfLength(2)); | ||
NHamcrest.XUnit.Assert.That(transfers, new HasTransfer(new Transfer("Bob", "Alice", 20m))); | ||
NHamcrest.XUnit.Assert.That(transfers, new HasTransfer(new Transfer("Carol", "Alice", 30m))); | ||
} | ||
} | ||
} |
This file contains 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,29 @@ | ||
using System.Collections.Generic; | ||
using Izzy.Web.Model; | ||
using Izzy.Web.Tests.Matchers; | ||
using NHamcrest; | ||
using Xunit; | ||
|
||
namespace Izzy.Web.Tests.Receipts.OneMoreThanMiddle | ||
{ | ||
public class TwoPersons | ||
{ | ||
[Fact] | ||
public void Test1() | ||
{ | ||
// Act | ||
var receipt = new Receipt( | ||
new List<Person>{ | ||
new Person("Alice", 100), | ||
new Person("Bob", 0) | ||
} | ||
); | ||
|
||
var transfers = receipt.Transfers(); | ||
|
||
// Assert | ||
NHamcrest.XUnit.Assert.That(transfers, Is.OfLength(1)); | ||
NHamcrest.XUnit.Assert.That(transfers, new HasTransfer(new Transfer("Bob", "Alice", 50m))); | ||
} | ||
} | ||
} |
This file contains 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,35 @@ | ||
using System.Collections.Generic; | ||
using Izzy.Web.Model; | ||
using Izzy.Web.Tests.Matchers; | ||
using NHamcrest; | ||
using Xunit; | ||
|
||
namespace Izzy.Web.Tests.Receipts.TwoMoreThanMiddle | ||
{ | ||
public class FivePerson | ||
{ | ||
[Fact] | ||
public void TwoMoreThanMiddle_Calculate_ValidTransfers() | ||
{ | ||
// Act | ||
var receipt = new Receipt( | ||
new List<Person>{ | ||
new Person("Alice", 6800), | ||
new Person("Bob", 2900), | ||
new Person("Carol", 1500), | ||
new Person("Dave", 6400), | ||
new Person("Eve", 100) | ||
} | ||
); | ||
|
||
var transfers = receipt.Transfers(); | ||
|
||
// Assert | ||
NHamcrest.XUnit.Assert.That(transfers, Is.OfLength(4)); | ||
NHamcrest.XUnit.Assert.That(transfers, new HasTransfer(new Transfer("Bob", "Dave", 640m))); | ||
NHamcrest.XUnit.Assert.That(transfers, new HasTransfer(new Transfer("Eve", "Dave", 180m))); | ||
NHamcrest.XUnit.Assert.That(transfers, new HasTransfer(new Transfer("Eve", "Alice", 3260m))); | ||
NHamcrest.XUnit.Assert.That(transfers, new HasTransfer(new Transfer("Carol", "Dave", 2040m))); | ||
} | ||
} | ||
} |
This file contains 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,32 @@ | ||
using System.Collections.Generic; | ||
using Izzy.Web.Model; | ||
using Izzy.Web.Tests.Matchers; | ||
using NHamcrest; | ||
using Xunit; | ||
|
||
|
||
namespace Izzy.Web.Tests.Receipts.TwoMoreThanMiddle | ||
{ | ||
public class TwoMoreThanMiddleTests | ||
{ | ||
[Fact] | ||
public void TwoMoreThanMiddle_Calculate_ValidTransfers() | ||
{ | ||
// Act | ||
var receipt = new Receipt( | ||
new List<Person>{ | ||
new Person("Alice", 600), | ||
new Person("Bob", 1100), | ||
new Person("Carol", 0) | ||
} | ||
); | ||
|
||
var transfers = receipt.Transfers(); | ||
|
||
// Assert | ||
NHamcrest.XUnit.Assert.That(transfers, Is.OfLength(2)); | ||
NHamcrest.XUnit.Assert.That(transfers, new HasTransfer(new Transfer("Carol", "Alice", 33.33m))); | ||
NHamcrest.XUnit.Assert.That(transfers, new HasTransfer(new Transfer("Carol", "Bob", 533.33m))); | ||
} | ||
} | ||
} |
This file contains 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