public void GivenSubcategoriesInQuery_ThenSpecThatFiltersBySubcategoriesIsReturned() { var factory = new TransactionSpecificationFactory(); var returnedSpec = factory.Create(new GetTransactionsQuery { Subcategories = new List <string> { "subcategory1", "subcategory2" } }); Assert.True(returnedSpec.IsSatisfied(new Transaction { Subcategory = "subcategory1" })); Assert.True(returnedSpec.IsSatisfied(new Transaction { Subcategory = "subcategory2" })); Assert.False(returnedSpec.IsSatisfied(new Transaction { Subcategory = "invalid subcategory" })); }
public void GivenTypeAndCategoriesInQuery_ThenSpecThatFiltersByTypeAndCategoriesIsReturned() { var factory = new TransactionSpecificationFactory(); var returnedSpec = factory.Create(new GetTransactionsQuery { Type = TransactionType.Expense, Categories = new List <string> { "category1", "category2" } }); Assert.True(returnedSpec.IsSatisfied(new Transaction { TransactionType = "expense", Category = "category1" })); Assert.True(returnedSpec.IsSatisfied(new Transaction { TransactionType = "expense", Category = "category2" })); Assert.False(returnedSpec.IsSatisfied(new Transaction { TransactionType = "expense", Category = "invalid subcategory" })); Assert.False(returnedSpec.IsSatisfied(new Transaction { TransactionType = "income", Category = "category1" })); }
public TransactionHelperService(CurrentUserContext userContext, ITransactionRepository repository, IMapper mapper) { _repository = repository ?? throw new ArgumentNullException(nameof(repository)); _userContext = userContext ?? throw new ArgumentNullException(nameof(userContext)); _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); _specificationFactory = new TransactionSpecificationFactory(); }
public void GivenNoFilterParametersInQuery_ThenEmptyAndSpecificationReturned() { var factory = new TransactionSpecificationFactory(); var returnedSpec = factory.Create(new GetTransactionsQuery()); Assert.True(returnedSpec.IsSatisfied(new Transaction())); }
public void GivenTransactionTypeInQuery_ThenSpecThatFiltersByTypeIsReturned() { var factory = new TransactionSpecificationFactory(); var returnedSpec = factory.Create(new GetTransactionsQuery { Type = TransactionType.Expense }); Assert.True(returnedSpec.IsSatisfied(new Transaction { TransactionType = "expense" })); Assert.False(returnedSpec.IsSatisfied(new Transaction { TransactionType = "income" })); }
public void GivenPayerPayeeIdsInQuery_ThenSpecThatFiltersByPayerPayeeIdsIsReturned() { var factory = new TransactionSpecificationFactory(); var returnedSpec = factory.Create(new GetTransactionsQuery { PayerPayeeIds = new List <string> { "payer1", "payer2" } }); Assert.True(returnedSpec.IsSatisfied(new Transaction { PayerPayeeId = "payer1" })); Assert.True(returnedSpec.IsSatisfied(new Transaction { PayerPayeeId = "payer2" })); Assert.False(returnedSpec.IsSatisfied(new Transaction { PayerPayeeId = "payer3" })); }