-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTradingFixture.cs
72 lines (58 loc) · 2.87 KB
/
TradingFixture.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System.Diagnostics;
using FluentAssertions;
using Gwtdo.Scenarios;
using Gwtdo.Scenarios.Attributes;
namespace Gwtdo.Sample;
/// <summary>
/// Gwtdo attribute mapping strategy
/// </summary>
public class TradingFixture : ScenarioFixture<TradingContext>
{
[Given(@"Eu tenho :x ações da :y")]
[Given("I have :x shares of :y stock")]
public void HaveDynamicSharesOfMsftStock() =>
Context?.Trading.Buy(new TradingOrder(Let["y"].As<string>(), Let["x"].As<int>(),
new DateTime(2023, 1, 1, 10, 0, 0)));
[Given("I have 100 shares of MSFT stock")]
public void Have100SharesOfMsftStock() =>
Context?.Trading.Buy(new TradingOrder("MSFT", 100,
new DateTime(2023, 1, 1, 10, 0, 0)));
[Given("The time is before close of trading")]
public void teste() => Context.Clock.UpdateLimit(new DateTime(2023, 1, 1, 18, 0, 0));
[Given("I have 150 shares of APPL stock")]
public void Have150SharesOfApplStock() =>
Context?.Trading.Buy(new TradingOrder("APPL", 150,
new DateTime(2023, 1, 1, 10, 0, 0)));
[When(@"Peço para vender :z ações da :y")]
[When("I ask to sell :z shares of :y stock")]
public void AskToSellDynamicSharesOfMsftStock() =>
Context?.Trading.Sell(new TradingOrder(Let["y"].As<string>(), Let["z"].As<int>(),
new DateTime(2023, 1, 1, 10, 0, 0)));
[When("I ask to sell 20 shares of MSFT stock")]
public void AskToSell20SharesOfMsftStock() =>
Context?.Trading.Sell(new TradingOrder("MSFT", 20,
new DateTime(2023, 1, 1, 10, 0, 0)));
[When("I ask to buy 20 shares of MSFT stock")]
public void AskToBuy20SharesOfMsftStock() =>
Context?.Trading.Buy(new TradingOrder("MSFT", 20,
new DateTime(2023, 1, 1, 10, 0, 0)));
[Then(@"Eu deveria ter :w ações de :y")]
[Then("I should have :w shares of :y stock")]
public void ShouldHaveDynamicSharesOfMsftStock() =>
Context?.Trading.Shares[Let["y"].As<string>()].Should().Be(Let["w"].As<int>());
[Then("I should have 80 shares of MSFT stock")]
public void ShouldHave80SharesOfMsftStock() =>
Context?.Trading.Shares["MSFT"].Should().Be(80);
[Then("I should have 120 shares of MSFT stock")]
public void ShouldHave120SharesOfMsftStock() =>
Context?.Trading.Shares["MSFT"].Should().Be(120);
[Then("I should have 150 shares of APPL stock")]
public void ShouldHave150SharesOfApplStock() =>
Context?.Trading.Shares["APPL"].Should().Be(150);
[Then("A sell order for 20 shares of MSFT stock should have been executed")]
public void ASellOrderFor20SharesOfMSFT() =>
Context?.Trading.Orders["MSFT"].Should().Be(20);
[Then("A sell order for 0 shares of MSFT stock should have been executed")]
public void ASellOrderFor0SharesOfMSFT() =>
Context?.Trading.Orders.ContainsKey("MSFT").Should().BeFalse();
}