示例#1
0
        internal void FreeEquity_MessageCorrect_ReturnsTrue()
        {
            // Arrange
            var account = StubAccountProvider.Create();
            var message = new AccountStateEvent(
                new AccountId("FXCM", "123456789", "SIMULATED"),
                Currency.USD,
                Money.Create(150000m, Currency.AUD),
                Money.Create(150000m, Currency.AUD),
                Money.Zero(Currency.AUD),
                Money.Zero(Currency.AUD),
                Money.Create(2000m, Currency.AUD),
                decimal.Zero,
                string.Empty,
                Guid.NewGuid(),
                this.clock.TimeNow());

            // Act
            account.Apply(message);

            var result = account.FreeEquity;

            // Assert
            Assert.Equal(150000m - 2000m, result.Value);
        }
示例#2
0
        internal void Update_MessageCorrect_EqualsUpdatedStatusValues()
        {
            // Arrange
            var account = StubAccountProvider.Create();
            var message = new AccountStateEvent(
                new AccountId("FXCM", "123456789", "SIMULATED"),
                Currency.AUD,
                Money.Create(150000m, Currency.AUD),
                Money.Create(150000m, Currency.AUD),
                Money.Zero(Currency.AUD),
                Money.Zero(Currency.AUD),
                Money.Zero(Currency.AUD),
                decimal.Zero,
                string.Empty,
                Guid.NewGuid(),
                this.clock.TimeNow());

            // Act
            account.Apply(message);

            // Assert
            Assert.Equal(150000m, account.CashBalance.Value);
            Assert.Equal(150000m, account.CashStartDay.Value);
            Assert.Equal(0m, account.CashActivityDay.Value);
            Assert.Equal(0m, account.MarginRatio);
            Assert.Equal(0m, account.MarginUsedMaintenance.Value);
            Assert.Equal(0m, account.MarginUsedLiquidation.Value);
            Assert.Equal(string.Empty, account.MarginCallStatus);
        }
示例#3
0
        internal void UpdateAccount_WhenAccountExists_CorrectlyUpdatesAccount()
        {
            // Arrange
            var account = StubAccountProvider.Create();

            this.database.UpdateAccount(account);

            var message = new AccountStateEvent(
                new AccountId("FXCM", "123456789", "SIMULATED"),
                Currency.AUD,
                Money.Create(150000m, Currency.AUD),
                Money.Create(150000m, Currency.AUD),
                Money.Zero(Currency.AUD),
                Money.Zero(Currency.AUD),
                Money.Zero(Currency.AUD),
                decimal.Zero,
                string.Empty,
                Guid.NewGuid(),
                StubZonedDateTime.UnixEpoch());

            account.Apply(message);

            // Act
            this.database.UpdateAccount(account);

            // Assert
            Assert.True(true); // Does not throw
        }
        internal void LoadAccountsCache_WhenAccountInDatabase_CorrectlyCachesAccount()
        {
            // Arrange
            var account = StubAccountProvider.Create();

            this.database.UpdateAccount(account);

            var message = new AccountStateEvent(
                new AccountId("FXCM", "123456789", "SIMULATED"),
                Currency.AUD,
                Money.Create(150000m, Currency.AUD),
                Money.Create(150000m, Currency.AUD),
                Money.Zero(Currency.AUD),
                Money.Zero(Currency.AUD),
                Money.Zero(Currency.AUD),
                decimal.Zero,
                string.Empty,
                Guid.NewGuid(),
                StubZonedDateTime.UnixEpoch());

            account.Apply(message);
            this.database.UpdateAccount(account);

            this.database.ClearCaches();

            // Act
            this.database.LoadAccountsCache();

            // Assert
            Assert.Equal(account.Id, this.database.GetAccountIds().FirstOrDefault());
        }
示例#5
0
        internal void AddAccount_WithNoAccountsInDatabase_CorrectlyAddsAccountWithIndexes()
        {
            // Arrange
            var account = StubAccountProvider.Create();

            // Act
            this.database.AddAccount(account);

            // Assert
            Assert.Equal(account, this.database.GetAccount(account.Id));
            Assert.Equal(account.Id, this.database.GetAccountIds().First());
        }
示例#6
0
        internal void UpdateAccount_WhenAccountDoesNotYetExist_CorrectlyUpdatesAccount()
        {
            // Arrange
            var account = StubAccountProvider.Create();

            this.database.UpdateAccount(account);

            // Act
            this.database.UpdateAccount(account);

            // Assert
            Assert.True(true); // Does not throw
        }