public void ValuesAtEndOfLastMonthFromStatusDate_WhenCalculateAsyncHasNotBeenCalled_ReturnsAccountCollectionValuesWhereLiabilitiesIsEqualToZero()
        {
            IAccountCollection sut = CreateSut();

            sut.Add(_fixture.CreateMany <IAccount>(_random.Next(5, 10)).ToArray());

            IAccountCollectionValues result = sut.ValuesAtEndOfLastMonthFromStatusDate;

            Assert.That(result.Liabilities, Is.EqualTo(0M));
        }
Exemple #2
0
        public async Task GroupByAccountGroupAsync_WhenCalled_ReturnsReadOnlyDictionaryWhichContainsAccountCollectionMatchingEachAccountGroupFromAccountsInAccountCollection()
        {
            IAccountCollection sut = CreateSut();

            sut.Add(CreateAccountCollection());

            IReadOnlyDictionary <IAccountGroup, IAccountCollection> result = await sut.GroupByAccountGroupAsync();

            Assert.That(result.All(item => item.Value.All(account => account.AccountGroup.Number == item.Key.Number)), Is.True);
        }
        public void ValuesAtEndOfLastMonthFromStatusDate_WhenCalculateAsyncHasNotBeenCalled_ReturnsNotNull()
        {
            IAccountCollection sut = CreateSut();

            sut.Add(_fixture.CreateMany <IAccount>(_random.Next(5, 10)).ToArray());

            IAccountCollectionValues result = sut.ValuesAtEndOfLastMonthFromStatusDate;

            Assert.That(result, Is.Not.Null);
        }
Exemple #4
0
        public async Task GroupByAccountGroupAsync_WhenCalled_ReturnsNotNull()
        {
            IAccountCollection sut = CreateSut();

            sut.Add(CreateAccountCollection());

            IReadOnlyDictionary <IAccountGroup, IAccountCollection> result = await sut.GroupByAccountGroupAsync();

            Assert.That(result, Is.Not.Null);
        }
Exemple #5
0
        public async Task GroupByAccountGroupAsync_WhenCalled_ReturnsReadOnlyDictionaryWhereAllAccountCollectionsIsCalculated()
        {
            IAccountCollection sut = CreateSut();

            sut.Add(CreateAccountCollection());

            DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1);
            IReadOnlyDictionary <IAccountGroup, IAccountCollection> result = await(await sut.CalculateAsync(statusDate)).GroupByAccountGroupAsync();

            Assert.That(result.Select(item => item.Value.StatusDate).All(value => value == statusDate.Date), Is.True);
        }
Exemple #6
0
        public async Task GroupByAccountGroupAsync_WhenCalled_ReturnsReadOnlyDictionaryWhichContainsAllAccountsInAccountCollection()
        {
            IAccountCollection sut = CreateSut();

            IAccount[] accountCollection = CreateAccountCollection();
            sut.Add(accountCollection);

            IReadOnlyDictionary <IAccountGroup, IAccountCollection> result = await sut.GroupByAccountGroupAsync();

            Assert.That(accountCollection.All(account => result.SelectMany(item => item.Value).Contains(account)), Is.True);
        }
Exemple #7
0
        public async Task GroupByAccountGroupAsync_WhenCalled_ReturnsReadOnlyDictionaryWhichContainsEachAccountGroupFromAccountsInAccountCollection()
        {
            IAccountCollection sut = CreateSut();

            IAccountGroup[] accountGroupCollection = _fixture.CreateMany <IAccountGroup>(_random.Next(2, 5)).ToArray();
            sut.Add(CreateAccountCollection(accountGroupCollection));

            IReadOnlyDictionary <IAccountGroup, IAccountCollection> result = await sut.GroupByAccountGroupAsync();

            Assert.That(accountGroupCollection.All(accountGroup => result.Keys.Single(key => key.Number == accountGroup.Number) != null), Is.True);
        }
Exemple #8
0
        public async Task GroupByAccountGroupAsync_WhenCalled_AssertAccountNumberWasCalledOnEachAccountInAccountCollection()
        {
            IAccountCollection sut = CreateSut();

            Mock <IAccount>[] accountMockCollection = CreateAccountMockCollection();
            sut.Add(accountMockCollection.Select(accountMock => accountMock.Object).ToArray());

            await sut.GroupByAccountGroupAsync();

            foreach (Mock <IAccount> accountMock in accountMockCollection)
            {
                accountMock.Verify(m => m.AccountNumber, Times.Once);
            }
        }
Exemple #9
0
        public async Task GroupByAccountGroupAsync_WhenCalled_AssertNumberWasCalledOnAccountGroupForEachAccountInAccountCollection()
        {
            IAccountCollection sut = CreateSut();

            Mock <IAccountGroup>[] accountGroupMockCollection =
            {
                _fixture.BuildAccountGroupMock(),
                _fixture.BuildAccountGroupMock(),
                _fixture.BuildAccountGroupMock()
            };
            sut.Add(CreateAccountCollection(accountGroupMockCollection.Select(accountGroupMock => accountGroupMock.Object).ToArray()));

            await sut.GroupByAccountGroupAsync();

            foreach (Mock <IAccountGroup> accountGroupMock in accountGroupMockCollection)
            {
                accountGroupMock.Verify(m => m.Number, Times.AtLeastOnce);
            }
        }
        public async Task <User> CreateUserAccount(CreateUserAccountCredentials credentials)
        {
            var salt     = WebrewHasher.Instance.GetRandomSalt(32);
            var hashword = WebrewHasher.Instance.HashPassword(credentials.Password, SecuritySettings.PasswordHashSecret, salt);

            var account = await AccountCollection.Add(new Account
            {
                Email    = credentials.Email,
                Password = hashword,
                Username = credentials.Username,
                Salt     = Encoding.UTF8.GetString(salt)
            });;

            var user = await UserCollection.Add(new User
            {
                AccountId = account.Id,
                Email     = credentials.Email,
                Username  = credentials.Username
            });

            return(user);
        }