public async Task WhenCloseAccount()
    {
        var entity = await GivenAnActiveAccount()
                     .ForUser(AuthorizedUserId)
                     .SavedInDb(_databaseDriver);

        GivenUserIsAuthorized();

        await WhenUserClosesAccount(entity);

        ThenShouldExpectStatusCode(HttpStatusCode.NoContent);

        var result = await _databaseDriver.FindByIdAsync <AccountEntity>(entity.Id, entity.UserId);

        result.Should().NotBeNull();
        result !.Inactive.Should().BeTrue();
    }
    public async Task WhenOpenAccount()
    {
        var entity = GivenAnActiveAccount()
                     .ForUser(AuthorizedUserId)
                     .Build();

        GivenUserIsAuthorized();

        await WhenUserOpensAnAccount(entity);

        ThenShouldExpectStatusCode(HttpStatusCode.Created);

        var id = ThenShouldGetTheRouteOfTheNewResourceInTheHeader();

        var result = await _databaseDriver.FindByIdAsync <AccountEntity>(id, entity.UserId);

        result.Should().NotBeNull();
        result !.Should().BeEquivalentTo(entity,
                                         options => options.Excluding(info => info.Id).Excluding(info => info.Favorite));
    }
Example #3
0
    public async Task WhenFavoriteAccount()
    {
        var entity = await GivenAnActiveAccount()
                     .IsFavorite(false)
                     .ForUser(AuthorizedUserId)
                     .SavedInDb(_databaseDriver);

        entity = GivenAnExistingAccount(entity)
                 .IsFavorite(true)
                 .Build();

        GivenUserIsAuthorized();

        await WhenUserSetsFavoriteAccount(entity);

        ThenShouldExpectStatusCode(HttpStatusCode.NoContent);

        var result = await _databaseDriver.FindByIdAsync <AccountEntity>(entity.Id, entity.UserId);

        result.Should().NotBeNull();
        result !.Should().BeEquivalentTo(entity);
    }
Example #4
0
    public async Task WhenModifyACashflow()
    {
        var account = await GivenAnActiveAccount()
                      .ForUser(AuthorizedUserId)
                      .SavedInDb(_databaseDriver);

        var category = await GivenACategory()
                       .ForUser(AuthorizedUserId)
                       .SavedInDb(_databaseDriver);

        var cashflow = await GivenACashflowEntity()
                       .ForAccount(account)
                       .ForCategory(category)
                       .ForUser(AuthorizedUserId)
                       .SavedInDb(_databaseDriver);

        GivenUserIsAuthorized();

        cashflow = cashflow with
        {
            Amount      = new Faker().Finance.Amount(),
            Description = AutoFaker.Generate <string>()
        };

        await WhenUserModifiedACashflow(MapToRequest(cashflow));

        ThenShouldExpectStatusCode(HttpStatusCode.NoContent);

        var result = await _databaseDriver.FindByIdAsync <CashflowEntity>(cashflow.Id, cashflow.UserId);

        result.Should()
        .NotBeNull()
        .And
        .BeEquivalentTo(cashflow, options =>
                        options.Excluding(info => info.LastPaidDate)
                        .Excluding(info => info.LastCashflowDate)
                        .Excluding(info => info.Account)
                        .Excluding(info => info.Category));
    }
    public async Task WhenModifyAccount()
    {
        var entity = await GivenAnActiveAccount()
                     .ForUser(AuthorizedUserId)
                     .SavedInDb(_databaseDriver);

        entity = GivenAnExistingAccount(entity)
                 .WithName("modified name")
                 .WithDescription("modified description")
                 .WithOpenBalance(123.45m)
                 .Build();

        GivenUserIsAuthorized();

        await WhenUserModifiesAccount(entity);

        ThenShouldExpectStatusCode(HttpStatusCode.NoContent);

        var result = await _databaseDriver.FindByIdAsync <AccountEntity>(entity.Id, entity.UserId);

        result.Should().NotBeNull();
        result !.Should().BeEquivalentTo(entity);
    }