public async Task WhenAccountsExists()
    {
        const string firstCode  = nameof(firstCode);
        const string secondCode = nameof(secondCode);

        await GivenAStoreItem()
        .ForUser(AuthorizedUserId)
        .WithCode(firstCode)
        .SavedInDb(_objectStoreDatabaseDriver);

        await GivenAStoreItem()
        .ForUser(AuthorizedUserId)
        .WithCode(secondCode)
        .SavedInDb(_objectStoreDatabaseDriver);

        await GivenAStoreItem()
        .SavedInDb(_objectStoreDatabaseDriver);

        GivenUserIsAuthorized();

        await WhenUserTriesToQuery(ApiResources.GetStoreItems, sorts : "-code");

        ThenShouldExpectStatusCode(HttpStatusCode.OK);
        var result = HttpClientDriver.DeserializeContent <StoreItemViewModel[]>();

        ThenAssertAll(() =>
        {
            result.Should().NotBeNull().And.HaveCount(2);
            result ![0].Code.Should().Be(secondCode);
            result[1].Code.Should().Be(firstCode);
        });
Beispiel #2
0
    public async Task WhenCategoriesExists()
    {
        const string firstName  = nameof(firstName);
        const string secondName = nameof(secondName);

        var firstCategory = await GivenACategory()
                            .WithName(firstName)
                            .ForUser(AuthorizedUserId)
                            .SavedInDb(_holefeederDatabaseDriver);

        var secondCategory = await GivenACategory()
                             .WithName(secondName)
                             .ForUser(AuthorizedUserId)
                             .SavedInDb(_holefeederDatabaseDriver);

        GivenUserIsAuthorized();

        await WhenUserGetCategories();

        ThenShouldExpectStatusCode(HttpStatusCode.OK);
        var result = HttpClientDriver.DeserializeContent <CategoryViewModel[]>();

        ThenAssertAll(() =>
        {
            result.Should().NotBeNull().And.HaveCount(2);
            result ![0].Should().BeEquivalentTo(firstCategory,
                                                options => options.ExcludingMissingMembers());
            result[1].Should().BeEquivalentTo(secondCategory,
                                              options => options.ExcludingMissingMembers());
        });
    public async Task WhenAccountExistsWithExpenses()
    {
        var account = await GivenAnActiveAccount()
                      .OfType(AccountType.Checking)
                      .ForUser(AuthorizedUserId)
                      .SavedInDb(_holefeederDatabaseDriver);

        var category = await GivenACategory()
                       .OfType(CategoryType.Expense)
                       .ForUser(AuthorizedUserId)
                       .SavedInDb(_holefeederDatabaseDriver);

        var transaction = await GivenATransaction()
                          .ForAccount(account)
                          .ForCategory(category)
                          .SavedInDb(_holefeederDatabaseDriver);

        GivenUserIsAuthorized();

        await WhenUserGetAccount(account.Id);

        ThenShouldExpectStatusCode(HttpStatusCode.OK);
        var result = HttpClientDriver.DeserializeContent <AccountViewModel>();

        ThenAssertAll(() =>
        {
            result.Should()
            .NotBeNull()
            .And
            .BeEquivalentTo(account, options => options.Excluding(x => x.UserId));
            result !.TransactionCount.Should().Be(1);
            result.Balance.Should().Be(account.OpenBalance - transaction.Amount);
        });
    }
Beispiel #4
0
    protected BaseScenario(ApiApplicationDriver apiApplicationDriver, ITestOutputHelper testOutputHelper)
    {
        HttpClientDriver = apiApplicationDriver.CreateHttpClientDriver(testOutputHelper);

        User        = new UserStepDefinition(HttpClientDriver);
        Transaction = new TransactionStepDefinition(HttpClientDriver);
    }
    public async Task WhenAccountsExistsSortedByNameDesc()
    {
        const string firstName  = nameof(firstName);
        const string secondName = nameof(secondName);

        await GivenAnActiveAccount()
        .ForUser(AuthorizedUserId)
        .WithName(firstName)
        .SavedInDb(_holefeederDatabaseDriver);

        await GivenAnActiveAccount()
        .ForUser(AuthorizedUserId)
        .WithName(secondName)
        .SavedInDb(_holefeederDatabaseDriver);

        await GivenAnActiveAccount()
        .SavedInDb(_holefeederDatabaseDriver);

        GivenUserIsAuthorized();

        await WhenUserTriesToQuery(ApiResources.GetAccounts, sorts : "-name");

        ThenShouldExpectStatusCode(HttpStatusCode.OK);
        var result = HttpClientDriver.DeserializeContent <AccountViewModel[]>();

        ThenAssertAll(() =>
        {
            result.Should().NotBeNull().And.HaveCount(2);
            result ![0].Name.Should().Be(secondName);
            result[1].Name.Should().Be(firstName);
        });
 private async Task WhenUserOpensAnAccount(AccountEntity entity)
 {
     var json = JsonSerializer.Serialize(new
     {
         entity.Type,
         entity.Name,
         entity.OpenBalance,
         entity.OpenDate,
         entity.Description
     });
     await HttpClientDriver.SendPostRequest(ApiResources.OpenAccount, json);
 }
    public async Task WhenAnonymousUser()
    {
        GivenUserIsUnauthorized();

        await WhenUserGetEnumeration();

        ThenShouldExpectStatusCode(HttpStatusCode.OK);
        var result = HttpClientDriver.DeserializeContent <DateIntervalType[]>();

        ThenAssertAll(() =>
        {
            result.Should().NotBeNull().And.HaveCount(DateIntervalType.List.Count);
        });
    }
Beispiel #8
0
    public async Task WhenStoreItemExists()
    {
        var storeItem = await GivenAStoreItem()
                        .ForUser(AuthorizedUserId)
                        .SavedInDb(_objectStoreDatabaseDriver);

        GivenUserIsAuthorized();

        await WhenUserGetStoreItem(storeItem.Id);

        ThenShouldExpectStatusCode(HttpStatusCode.OK);
        var result = HttpClientDriver.DeserializeContent <StoreItemViewModel>();

        ThenAssertAll(() =>
        {
            result.Should()
            .NotBeNull()
            .And
            .BeEquivalentTo(storeItem, options => options.Excluding(x => x.UserId));
        });
    }
 private async Task WhenUserGetEnumeration()
 {
     await HttpClientDriver.SendGetRequest(ApiResources.GetDateIntervalTypes);
 }
 private async Task WhenUserGetAccount(Guid id)
 {
     await HttpClientDriver.SendGetRequest(ApiResources.GetAccount, new object?[] { id.ToString() });
 }
 public TransactionStepDefinition(HttpClientDriver httpClientDriver)
 {
     HttpClientDriver = httpClientDriver;
 }
 private async Task WhenUserCreateStoreItem(StoreItemEntity entity)
 {
     var json = JsonSerializer.Serialize(new {entity.Code, entity.Data});
     await HttpClientDriver.SendPostRequest(ApiResources.CreateStoreItem, json);
 }
 public UserStepDefinition(HttpClientDriver httpClientDriver)
 {
     HttpClientDriver = httpClientDriver;
 }
Beispiel #14
0
 private async Task WhenUserSetsFavoriteAccount(AccountEntity entity)
 {
     var json = JsonSerializer.Serialize(new { entity.Id, IsFavorite = entity.Favorite });
     await HttpClientDriver.SendPostRequest(ApiResources.FavoriteAccount, json);
 }
 private async Task WhenUserClosesAccount(AccountEntity entity)
 {
     var json = JsonSerializer.Serialize(new { entity.Id });
     await HttpClientDriver.SendPostRequest(ApiResources.CloseAccount, json);
 }
Beispiel #16
0
 private async Task WhenUserModifiedACashflow(Request request)
 {
     var json = JsonSerializer.Serialize(request);
     await HttpClientDriver.SendPostRequest(ApiResources.ModifyCashflow, json);
 }