public async Task FindOpenPositionsWorksCorrectly() { var p1 = await _underTest.OpenAsync("EUR", "USD", 200, 1.2f); var p2 = await _underTest.OpenAsync("EUR", "USD", 200, 1.2f); var p3 = await _underTest.OpenAsync("EUR", "USD", 200, 1.3f); var p4 = await _underTest.OpenAsync("EUR", "USD", 200, 1.3f); await _underTest.CloseAsync(p2, 250, 2, null); await _underTest.CloseAsync(p4, 250, 2, null); var positions = await _underTest.FindOpenPositionsAsync("EUR", "USD", 1.25f); positions.Count.Should().Be(1, "there are just two open and only one from them fits"); positions[0].Id.Should().Be(p3, "only p3 is open and opened higher"); }
public async Task PositionIsOpenedAtDefinedHourOnly() { _position.FindOpenPositionsAsync(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <float>()).Returns(Task.FromResult(new List <Position>())); await _underTest.EvaluateRateAsync(Currency.EUR, Currency.USD); await _position.Received().OpenAsync("EUR", "USD", 10f, 2f); _options.OpenHour = DateTime.UtcNow.AddHours(2).Hour; _position.ClearReceivedCalls(); await _underTest.EvaluateRateAsync(Currency.EUR, Currency.USD); await _position.DidNotReceive().OpenAsync("EUR", "USD", 10f, 2f); }