Пример #1
0
        [Fact] // async Task<TransactionRequest> FindByIdAsync(string id)
        public async void FindByIdAsync_ForTransactionRequestId_ShouldReturnTheFoundObject()
        {
            // Arrange
            var senderId    = Guid.NewGuid().ToString();
            var recipientId = Guid.NewGuid().ToString();

            var trId  = Guid.NewGuid().ToString();
            var trId2 = Guid.NewGuid().ToString();
            var trId3 = Guid.NewGuid().ToString();

            var transactionRequest  = TransactionRequestCreator.Create(trId, senderId, recipientId);
            var transactionRequest2 = TransactionRequestCreator.Create(trId2, senderId, recipientId);
            var transactionRequest3 = TransactionRequestCreator.Create(trId3, senderId, recipientId);

            await this.Context.TransactionRequests.AddRangeAsync(transactionRequest, transactionRequest2, transactionRequest3);

            await this.Context.SaveChangesAsync();

            var service = new OwnerTransactionRequestService(this.Context);

            // Act
            var result = await service.FindByIdAsync(trId);

            var result2 = await service.FindByIdAsync(trId2);

            var expected  = trId;
            var expected2 = trId2;

            // Assert
            result.Should().BeOfType <TransactionRequest>();
            result.Id.Should().Equals(expected);
            result2.Id.Should().Equals(expected2);
        }
Пример #2
0
        [Fact] // async Task<bool> UpdateAsync(TransactionRequest transactionRequest)
        public async void UpdateAsync_ForGivenTransactionRequestObject_ShouldReturnTrueIfUpdatedSuccessfully()
        {
            // Arrange
            var senderId    = Guid.NewGuid().ToString();
            var recipientId = Guid.NewGuid().ToString();

            var trId = Guid.NewGuid().ToString();

            var transactionRequest = TransactionRequestCreator.Create(trId, senderId, recipientId);

            await this.Context.TransactionRequests.AddAsync(transactionRequest);

            await this.Context.SaveChangesAsync();

            var statusBefore = transactionRequest.Status;
            var statusAfter  = TransactionRequestStatus.Complete;

            transactionRequest.Status = statusAfter;

            var service = new OwnerTransactionRequestService(this.Context);

            // Act
            var result = await service.UpdateAsync(transactionRequest);

            var changed = await this.Context.TransactionRequests.FindAsync(trId);

            // Assert
            result.Should().BeTrue();
            changed.Status.Should().Equals(statusAfter);
            changed.Status.Should().NotBe(statusBefore);
        }