-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated AspNet sample tests, switched from Machine.Specifications to …
…Xunit/FluentAssertions
- Loading branch information
1 parent
4cef580
commit f528287
Showing
13 changed files
with
124 additions
and
182 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
11 changes: 11 additions & 0 deletions
11
Samples/ASP.NET.Specs/Kitchen/for_Kitchen/given/a_kitchen.cs
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,11 @@ | ||
// Copyright (c) Dolittle. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Dolittle.SDK.Testing.Aggregates; | ||
|
||
namespace Specs.Kitchen.for_Kitchen.given; | ||
|
||
public abstract class a_kitchen(): AggregateRootTests<global::Kitchen.Kitchen>(kitchen_name) | ||
{ | ||
const string kitchen_name = "Dolittle Tacos"; | ||
} |
24 changes: 0 additions & 24 deletions
24
Samples/ASP.NET.Specs/Kitchen/for_Kitchen/given/a_kitchen_with_no_prepared_dishes.cs
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
...ASP.NET.Specs/Kitchen/for_Kitchen/when_preparing_dish/and_there_are_enough_ingredients.cs
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
...NET.Specs/Kitchen/for_Kitchen/when_preparing_dish/and_there_are_not_enough_ingredients.cs
This file was deleted.
Oops, something went wrong.
50 changes: 26 additions & 24 deletions
50
...chen/for_Kitchen/when_preparing_dish/in_one_operation/and_there_are_enough_ingredients.cs
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,38 +1,40 @@ | ||
// Copyright (c) Dolittle. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using FluentAssertions; | ||
using Kitchen; | ||
using Machine.Specifications; | ||
using Xunit; | ||
|
||
namespace Specs.Kitchen.for_Kitchen.when_preparing_dish.in_one_operation; | ||
|
||
class and_there_are_enough_ingredients : given.a_kitchen_with_no_prepared_dishes | ||
public class and_there_are_enough_ingredients : given.a_kitchen | ||
{ | ||
static string chef, dish; | ||
Establish context = () => | ||
string chef, dish; | ||
|
||
public and_there_are_enough_ingredients() | ||
{ | ||
chef = "Sindre"; | ||
dish = "Tacos"; | ||
}; | ||
|
||
Because of = async () => await OnKitchen().Perform(_ => | ||
{ | ||
_.PrepareDish(chef, dish); | ||
_.PrepareDish(chef, dish); | ||
}); | ||
|
||
It should_after_last_operation_only_prepare_one_dish = () => KitchenAfterLastOperation().ShouldHaveEvent<DishPrepared>() | ||
.CountOf(2) | ||
.WhereAll( | ||
_ => _.Chef.ShouldEqual(chef), | ||
_ => _.Dish.ShouldEqual(dish)); | ||
|
||
It should_only_prepare_one_dish = () => KitchenWithAllEvents().ShouldHaveEvent<DishPrepared>() | ||
.CountOf(2) | ||
.AtEnd().Where( | ||
_ => _.Chef.ShouldEqual(chef), | ||
_ => _.Dish.ShouldEqual(dish)); | ||
|
||
It should_have_done_nothing_else = () => KitchenWithAllEvents().ShouldHaveNumberOfEvents(2); | ||
WithAggregateInState(kitchen => | ||
{ | ||
kitchen.PrepareDish(chef, dish); | ||
}); | ||
} | ||
|
||
[Fact] | ||
public void should_prepare_dish() | ||
{ | ||
WhenPerforming(kitchen => | ||
{ | ||
kitchen.PrepareDish(chef, dish); | ||
}); | ||
|
||
AssertThat | ||
.ShouldHaveEvent<DishPrepared>() | ||
.CountOf(1) | ||
.WhereAll( | ||
evt => evt.Chef.Should().Be(chef), | ||
evt => evt.Dish.Should().Be(dish)); | ||
} | ||
} |
37 changes: 17 additions & 20 deletions
37
.../for_Kitchen/when_preparing_dish/in_one_operation/and_there_are_not_enough_ingredients.cs
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,30 +1,27 @@ | ||
// Copyright (c) Dolittle. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Linq; | ||
using Dolittle.SDK.Aggregates; | ||
using Machine.Specifications; | ||
using FluentAssertions; | ||
using Kitchen; | ||
using Xunit; | ||
|
||
namespace Specs.Kitchen.for_Kitchen.when_preparing_dish.in_one_operation; | ||
|
||
class and_there_are_not_enough_ingredients : given.a_kitchen_with_no_prepared_dishes | ||
public class and_there_are_not_enough_ingredients : given.a_kitchen | ||
{ | ||
static Exception failure; | ||
|
||
Because of = async () => failure = await Catch.ExceptionAsync(() => OnKitchen().Perform(customer => | ||
public and_there_are_not_enough_ingredients() | ||
{ | ||
var num_ingredients = 2; | ||
foreach (var _ in Enumerable.Range(0, num_ingredients + 1)) | ||
WithAggregateInState(kitchen => | ||
{ | ||
customer.PrepareDish("chef", "dish"); | ||
} | ||
})); | ||
|
||
It should_after_last_operation_not_have_done_anything = () => KitchenAfterLastOperation().ShouldHaveNoEvents(); | ||
|
||
It should_only_not_have_done_anything_at_all = () => KitchenWithAllEvents().ShouldHaveNoEvents(); | ||
|
||
It should_fail_because_operation_failed = () => failure.ShouldBeOfExactType<AggregateRootOperationFailed>(); | ||
|
||
kitchen.PrepareDish("chef", "dish"); | ||
kitchen.PrepareDish("chef", "dish"); | ||
}); | ||
} | ||
|
||
[Fact] | ||
public void should_fail_if_preparing_dish() => | ||
WhenPerforming(kitchen => kitchen.Invoking( | ||
it => it.PrepareDish("chef", "dish") | ||
) | ||
.Should().Throw<OutOfIngredients>()); | ||
} |
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
Oops, something went wrong.