public void InternalRestClient_Ctor_should_create_with_valid_arguments() { //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(); }
public void PaymentServiceExternal_Ctor_should_not_throw_if_argument_is_valid() { //Act Action ctor = () => SubjectBuilder.New().Build(); //Assert ctor.Should().NotThrow(); }
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 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>(); }
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 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 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 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 static ISubject GetSubject() { var subject = ThreadContext.Subject; if (subject == null) { subject = new SubjectBuilder().BuildSubject(); ThreadContext.Subject = subject; } return(subject); }
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 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); }
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]); } }
/// <summary> /// Initialized an instance of the <see cref="SubjectBuilder"/> using the certificate <seealso cref="X509Certificate2.SubjectName"/> /// </summary> /// <param name="cert"></param> /// <returns></returns> public static SubjectBuilder GetSubjectBuilder(this X509Certificate2 cert) { return(SubjectBuilder.Parse(cert.Subject)); }