Пример #1
0
        public void ShouldUpdateTransaction()
        {
            var transactionModel = new TransactionModel
            {
                Description = "Tea",
                PostedDate  = new DateTime(2020, 4, 2),
            };

            var builder       = TestBuilder.Begin().AsUser();
            var transactionId = builder
                                .UpsertTransaction(transactionModel)
                                .Result;

            var updatedTransactionModel = new TransactionModel
            {
                Id          = transactionId,
                Description = "Coffee",
                PostedDate  = new DateTime(2020, 4, 11),
            };

            var actualTransaction = builder
                                    .UpsertTransaction(updatedTransactionModel)
                                    .GetTransaction(transactionId)
                                    .Result;

            AssertTransaction(updatedTransactionModel, actualTransaction);
        }
Пример #2
0
 private static TestBuilder <Guid> GetBuilderWithSetupTransaction()
 {
     return(TestBuilder.Begin()
            .AsUser()
            .UpsertAccount(CreditCardAccount)
            .UpsertAccount(FoodAccount)
            .UpsertTransaction(TransactionModel));
 }
Пример #3
0
        public void ShouldHandleInvalidId()
        {
            var builder = TestBuilder.Begin()
                          .AsUser()
                          .GetTransaction(Guid.NewGuid());

            Assert.IsNull(builder.Result);
        }
        public void ShouldThrowWhenAddingUserWithDuplicateUserName()
        {
            var request = new AddUserRequest
            {
                UserName = Guid.NewGuid().ToString(),
                Password = "******",
            };

            var builder = TestBuilder.Begin().ExecuteRequest(request);

            Assert.Throws <AggregateException>(() => builder.ExecuteRequest(request));
        }
        public void ShouldUpsertAccount()
        {
            var accountModel = new AccountModel {
                Name = "expenses:food:groceries"
            };

            var builder = TestBuilder.Begin()
                          .AsUser()
                          .UpsertAccount(accountModel)
                          .ExecuteRequest(new ListAccountsRequest());

            new[] { accountModel }.AssertEquals(builder.Result.Items);
        }
        private static TestBuilder GetBuilderWithSetupTransactions()
        {
            var builder = TestBuilder.Begin().AsUser();

            builder
            .UpsertAccount(CreditCardAccount)
            .UpsertAccount(FoodAccount);

            foreach (var transaction in TransactionModels)
            {
                builder.UpsertTransaction(transaction);
            }

            return(builder);
        }
        public async Task ShouldAddUserAsync()
        {
            var userName = Guid.NewGuid().ToString();

            var builder = TestBuilder.Begin()
                          .ExecuteRequest(new AddUserRequest {
                UserName = userName, Password = "******"
            });

            var repository = builder.GetInstance <IRepository>();

            var user = await repository.QuerySingleOrDefaultAsync <User>(new CommandDefinition(
                                                                             "select * from [dbo].[User] where [UserName] = @UserName",
                                                                             new { UserName = userName }));

            if (user == null)
            {
                Assert.Fail($"Expecting a user with UserName '{userName}' to exist.");
            }
        }
Пример #8
0
        public void ShouldListAccounts()
        {
            var builder = TestBuilder.Begin()
                          .AsUser();

            var accountModels = new List <AccountModel>
            {
                new AccountModel {
                    Name = "assets:checking:boa"
                },
                new AccountModel {
                    Name = "expenses:food"
                },
            };

            foreach (var account in accountModels)
            {
                builder.UpsertAccount(account);
            }

            var response = builder.ExecuteRequest(new ListAccountsRequest()).Result;

            accountModels.AssertEquals(response.Items);
        }
 public void ShouldExecute()
 {
     TestBuilder.Begin()
     .AsUser()
     .ExecuteRequest(new GetPostingAggregatesRequest(Guid.NewGuid()));
 }