public void InternalRestClient_Ctor_should_create_with_valid_arguments()
        {
            //Act
            Action ctor = () => SubjectBuilder.New().Build();

            //Assert
            ctor.Should().NotThrow();
        }
Exemplo n.º 2
0
        public void PaymentServiceExternal_Ctor_should_not_throw_if_argument_is_valid()
        {
            //Act
            Action ctor = () => SubjectBuilder.New().Build();

            //Assert
            ctor.Should().NotThrow();
        }
        public void Repository_Ctor_should_not_throw_if_argument_is_valid()
        {
            //Act
            Action ctor = () => SubjectBuilder.New().Build();

            //Assert
            ctor.Should().NotThrow();
        }
Exemplo n.º 4
0
        public void PaymentServiceExternal_UpdatePaymentStatusAsync_should_throw_if_argument_is_null()
        {
            //Arrange
            var subject = SubjectBuilder.New().Build();

            //Act
            Func <Task> func = async() => await subject.UpdatePaymentStatusAsync(null);

            //Assert
            func.Should().Throw <ArgumentNullException>();
        }
Exemplo n.º 5
0
        public void PaymentServiceExternal_GetPaymentByIdAsync_should_throw_if_argument_is_invalid()
        {
            //Arrange
            var subject = SubjectBuilder.New().Build();

            //Act
            Func <Task> func = async() => await subject.GetPaymentByIdAsync(0);

            //Assert
            func.Should().Throw <ArgumentOutOfRangeException>();
        }
        public void InternalRestClient_PutAsync_should_throw_if_argument_is_null(string relativeUrl, object value)
        {
            //Arrange
            var subject = SubjectBuilder.New().Build();

            //Act
            Func <Task> putAsync = async() => await subject.PutAsync(relativeUrl, value);

            //Assert
            putAsync.Should().Throw <ArgumentNullException>();
        }
        public void InternalRestClient_GetAsync_should_throw_if_any_argument_is_null()
        {
            //Arrange
            var subject = SubjectBuilder.New().Build();

            //Act
            Func <Task> getAsync = async() => await subject.GetAsync(null);

            //Assert
            getAsync.Should().Throw <ArgumentNullException>();
        }
        public void Repository_Updatec_should_throw_if_argument_is_null()
        {
            //Arrange
            var subject = SubjectBuilder.New().Build();

            //Act
            Action update = () => subject.Update(null);

            //Assert
            update.Should().Throw <ArgumentNullException>();
        }
        public void Repository_DeleteAsync_should_throw_if_argument_is_invalid()
        {
            //Arrange
            var subject = SubjectBuilder.New().Build();

            //Act
            Func <Task> deleteAsync = async() => await subject.DeleteAsync(0);

            //Assert
            deleteAsync.Should().Throw <ArgumentOutOfRangeException>();
        }
        public void Repository_InsertAsync_should_throw_if_argument_is_null()
        {
            //Arrange
            var subject = SubjectBuilder.New().Build();

            //Act
            Func <Task> insertAsync = async() => await subject.InsertAsync(null);

            //Assert
            insertAsync.Should().Throw <ArgumentNullException>();
        }
        public void PaymentServiceInternal_GetPaymentsFiltered_should_throw_if_argument_is_null()
        {
            //Arrange
            var subject = SubjectBuilder.New().Build();

            //Act
            Func <Task> func = async() => await subject.GetPaymentsFiltered(null);

            //Assert
            func.Should().Throw <ArgumentNullException>();
        }
        public void Repository_Ctor_should_call_dbFactory_GetDbContext()
        {
            //Arrange
            var builder = SubjectBuilder.New();

            //Act
            var subject = builder.Build();

            //Assert
            A.CallTo(() => builder.DbFactory.GetDbContext())
            .MustHaveHappened(Repeated.Exactly.Once);
        }
Exemplo n.º 13
0
        public void PaymentServiceExternal_GetPaymentsFiltered_should_call_paymentRepository_GetAll()
        {
            //Arrange
            var builder = SubjectBuilder.New();
            var subject = builder.Build();

            //Act
            subject.GetPaymentsFiltered(Enumerable.Empty <PaymentStatus>());

            //Assert
            A.CallTo(() => builder.PaymentRepository.GetAll())
            .MustHaveHappened(Repeated.Exactly.Once);
        }
        public void PaymentServiceInternal_GetPaymentsFiltered_should_throw_InvalidOperationException_if_restClient_GetAsync_returns_error()
        {
            //Arrange
            var subject = SubjectBuilder.New().WithInvalidOperationException().Build();

            //Act
            Func <Task> func = async() => await subject.GetPaymentsFiltered(
                new List <PaymentStatus> {
                PaymentStatus.Pending
            });

            //Assert
            func.Should().Throw <InvalidOperationException>();
        }
        public async Task PaymentServiceInternal_GetPaymentsFiltered_should_create_url(
            IEnumerable <PaymentStatus> filter,
            string url)
        {
            //Arrange
            var builder = SubjectBuilder.New();
            var subject = builder.WithPayments(filter).Build();

            //Act
            await subject.GetPaymentsFiltered(filter);

            //Assert
            A.CallTo(() => builder.RestClient.GetAsync(A <string> .That.IsEqualTo(url)))
            .MustHaveHappened(Repeated.Exactly.Once);
        }
        public async Task PaymentServiceInternal_GetPaymentsFiltered_should_return_payments(
            IList <PaymentStatus> filter,
            string url)
        {
            //Arrange
            var builder          = SubjectBuilder.New();
            var subject          = builder.WithPayments(filter).Build();
            var expectedPayments = builder.Payments
                                   .Where(p => filter.Contains(p.Status))
                                   .OrderBy(p => p.Id)
                                   .ToList();

            //Act
            var result = (await subject.GetPaymentsFiltered(filter)).OrderBy(p => p.Id).ToList();

            //Assert
            for (var i = 0; i < result.Count; i++)
            {
                result[i].Should().BeEquivalentTo(expectedPayments[i]);
            }
        }