예제 #1
0
        public async Task UpdatesItemAfterAddingIt()
        {
            var          repository        = GetRepository();
            const string transactionStatus = "Running";
            var          item = PaymentTestDataHelper.GetPayment(1, 123, 1000);

            item.TransactionStatus = transactionStatus;

            await repository.AddAsync(item);

            DbContext.Entry(item).State = EntityState.Detached;

            var newItem = (await repository.ListAsync <Payment>())
                          .FirstOrDefault(x => x.TransactionStatus == transactionStatus);

            newItem.ShouldNotBeNull();
            newItem.ShouldNotBeSameAs(item);

            const string newTransactionStatus = "Completed";

            newItem.TransactionStatus = newTransactionStatus;

            await repository.UpdateAsync(newItem);

            var updatedItem = (await repository.ListAsync <Payment>())
                              .FirstOrDefault(i => i.TransactionStatus == newTransactionStatus);

            updatedItem.ShouldNotBeNull();
            updatedItem.TransactionStatus.ShouldNotBeSameAs(item.TransactionStatus);
            updatedItem.Id.ShouldBe(newItem.Id);
        }
        public async Task AddsItemAndSetsId()
        {
            var repository = GetRepository();
            var item       = PaymentTestDataHelper.GetPayment(1, 123, 1000);

            await repository.AddAsync(item);

            var newItem = (await repository.ListAsync <Payment>()).FirstOrDefault();

            newItem.ShouldNotBeNull();
            newItem.ShouldBeSameAs(item);
            newItem.Id.ToString().ShouldNotBeNull();
        }
예제 #3
0
        public async Task DeletesItemAfterAddingIt()
        {
            var repository = GetRepository();
            var item       = PaymentTestDataHelper.GetPayment(1, 123, 1000);
            await repository.AddAsync(item);

            var paymentId = item.Id;

            await repository.DeleteAsync(item);

            var payments = await repository.ListAsync <Payment>();

            payments.ShouldNotContain(x => x.Id == paymentId);
        }