-
-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
23 changed files
with
218 additions
and
131 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
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,83 +1,97 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
// This file was auto-generated based on version 1.0.1 of the canonical data. | ||
|
||
using Xunit; | ||
|
||
public class BookStoreTest | ||
{ | ||
[Fact] | ||
public void Basket_with_single_book() | ||
public void Only_a_single_book() | ||
{ | ||
Assert.Equal(8, BookStore.CalculateTotalCost(MakeList(1))); | ||
var input = new[] { 1 }; | ||
Assert.Equal(8, BookStore.Total(input)); | ||
} | ||
|
||
[Fact(Skip = "Remove to run test")] | ||
public void Basket_with_two_of_same_book() | ||
public void Two_of_the_same_book() | ||
{ | ||
Assert.Equal(16, BookStore.CalculateTotalCost(MakeList(2, 2))); | ||
var input = new[] { 2, 2 }; | ||
Assert.Equal(16, BookStore.Total(input)); | ||
} | ||
|
||
[Fact(Skip = "Remove to run test")] | ||
public void Empty_basket() | ||
{ | ||
Assert.Equal(0, BookStore.CalculateTotalCost(MakeList())); | ||
var input = new int[0]; | ||
Assert.Equal(0, BookStore.Total(input)); | ||
} | ||
|
||
[Fact(Skip = "Remove to run test")] | ||
public void Basket_with_two_different_books() | ||
public void Two_different_books() | ||
{ | ||
Assert.Equal(15.2, BookStore.CalculateTotalCost(MakeList(1, 2))); | ||
var input = new[] { 1, 2 }; | ||
Assert.Equal(15.2, BookStore.Total(input)); | ||
} | ||
|
||
[Fact(Skip = "Remove to run test")] | ||
public void Basket_with_three_different_books() | ||
public void Three_different_books() | ||
{ | ||
Assert.Equal(21.6, BookStore.CalculateTotalCost(MakeList(1, 2, 3))); | ||
var input = new[] { 1, 2, 3 }; | ||
Assert.Equal(21.6, BookStore.Total(input)); | ||
} | ||
|
||
[Fact(Skip = "Remove to run test")] | ||
public void Basket_with_four_different_books() | ||
public void Four_different_books() | ||
{ | ||
Assert.Equal(25.6, BookStore.CalculateTotalCost(MakeList(1, 2, 3, 4))); | ||
var input = new[] { 1, 2, 3, 4 }; | ||
Assert.Equal(25.6, BookStore.Total(input)); | ||
} | ||
|
||
[Fact(Skip = "Remove to run test")] | ||
public void Basket_with_five_different_books() | ||
public void Five_different_books() | ||
{ | ||
Assert.Equal(30, BookStore.CalculateTotalCost(MakeList(1, 2, 3, 4, 5))); | ||
var input = new[] { 1, 2, 3, 4, 5 }; | ||
Assert.Equal(30, BookStore.Total(input)); | ||
} | ||
|
||
[Fact(Skip = "Remove to run test")] | ||
public void Basket_with_eight_books() | ||
public void Two_groups_of_four_is_cheaper_than_group_of_five_plus_group_of_three() | ||
{ | ||
Assert.Equal(51.20, BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 5))); | ||
var input = new[] { 1, 1, 2, 2, 3, 3, 4, 5 }; | ||
Assert.Equal(51.2, BookStore.Total(input)); | ||
} | ||
|
||
[Fact(Skip = "Remove to run test")] | ||
public void Basket_with_nine_books() | ||
public void Group_of_four_plus_group_of_two_is_cheaper_than_two_groups_of_three() | ||
{ | ||
Assert.Equal(55.60, BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 4, 5))); | ||
var input = new[] { 1, 1, 2, 2, 3, 4 }; | ||
Assert.Equal(40.8, BookStore.Total(input)); | ||
} | ||
|
||
[Fact(Skip = "Remove to run test")] | ||
public void Basket_with_ten_books() | ||
public void Two_each_of_first_4_books_and_1_copy_each_of_rest() | ||
{ | ||
Assert.Equal(60, BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5))); | ||
var input = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5 }; | ||
Assert.Equal(55.6, BookStore.Total(input)); | ||
} | ||
|
||
[Fact(Skip = "Remove to run test")] | ||
public void Basket_with_eleven_books() | ||
public void Two_copies_of_each_book() | ||
{ | ||
Assert.Equal(68, BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1))); | ||
var input = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 }; | ||
Assert.Equal(60, BookStore.Total(input)); | ||
} | ||
|
||
[Fact(Skip = "Remove to run test")] | ||
public void Basket_with_twelve_books() | ||
public void Three_copies_of_first_book_and_2_each_of_remaining() | ||
{ | ||
Assert.Equal(75.20, BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2))); | ||
var input = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1 }; | ||
Assert.Equal(68, BookStore.Total(input)); | ||
} | ||
|
||
private static List<int> MakeList(params int[] values) | ||
[Fact(Skip = "Remove to run test")] | ||
public void Three_each_of_first_2_books_and_2_each_of_remaining_books() | ||
{ | ||
return values.ToList(); | ||
var input = new[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2 }; | ||
Assert.Equal(75.2, BookStore.Total(input)); | ||
} | ||
} | ||
} |
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
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 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 |
---|---|---|
@@ -1,13 +1,11 @@ | ||
using Generators.Output; | ||
|
||
namespace Generators.Exercises | ||
namespace Generators.Exercises | ||
{ | ||
public class BeerSong : Exercise | ||
{ | ||
public BeerSong() | ||
{ | ||
foreach (var canonicalDataCase in CanonicalData.Cases) | ||
canonicalDataCase.Expected = new MultiLineString(canonicalDataCase.Expected.ToString()); | ||
canonicalDataCase.UseExpectedParameter = true; | ||
} | ||
} | ||
} |
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,16 @@ | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Generators.Exercises | ||
{ | ||
public class BookStore : Exercise | ||
{ | ||
public BookStore() | ||
{ | ||
foreach (var canonicalDataCase in CanonicalData.Cases) | ||
{ | ||
canonicalDataCase.Input = ((JArray)canonicalDataCase.Properties["basket"]).Values<int>(); | ||
canonicalDataCase.UseInputParameters = true; | ||
} | ||
} | ||
} | ||
} |
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
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,25 +1,21 @@ | ||
using System; | ||
using Generators.Output; | ||
using Humanizer; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Generators.Exercises | ||
{ | ||
public class PerfectNumbers : Exercise | ||
{ | ||
public PerfectNumbers() | ||
{ | ||
Configuration.ExceptionType = typeof(ArgumentOutOfRangeException); | ||
|
||
foreach (var canonicalDataCase in CanonicalData.Cases) | ||
{ | ||
canonicalDataCase.ExceptionThrown = canonicalDataCase.Expected is JObject ? typeof(ArgumentOutOfRangeException) : null; | ||
|
||
if (canonicalDataCase.Expected is string classificationType) | ||
canonicalDataCase.Expected = Enum.Parse(typeof(Classification), classificationType, true); | ||
canonicalDataCase.Expected = new UnescapedValue($"Classification.{classificationType.Transform(To.SentenceCase)}"); | ||
} | ||
} | ||
|
||
private enum Classification | ||
{ | ||
Abundant, | ||
Deficient, | ||
Perfect, | ||
} | ||
} | ||
} |
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
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,10 +1,13 @@ | ||
namespace Generators.Exercises | ||
using System; | ||
|
||
namespace Generators.Exercises | ||
{ | ||
public class Wordy : Exercise | ||
{ | ||
public Wordy() | ||
{ | ||
Configuration.ThrowExceptionWhenExpectedValueEquals = x => x is bool; | ||
foreach (var canonicalDataCase in CanonicalData.Cases) | ||
canonicalDataCase.ExceptionThrown = canonicalDataCase.Expected is bool ? typeof(ArgumentException) : null; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.