public void GetValues_InitializedData_IgnoreTransfers() { //Setup var testCat = new CategoryViewModel {Id = 2, Name = "Ausgehen"}; var paymentList = new List<PaymentViewModel> { new PaymentViewModel { Id = 1, Type = PaymentType.Income, Date = DateTime.Today, Amount = 60, Category = testCat, CategoryId = 1 }, new PaymentViewModel { Id = 2, Type = PaymentType.Expense, Date = DateTime.Today, Amount = 90, Category = testCat, CategoryId = 1 }, new PaymentViewModel { Id = 3, Type = PaymentType.Transfer, Date = DateTime.Today, Amount = 40, Category = testCat, CategoryId = 1 } }; var paymentRepoSetup = new Mock<IPaymentRepository>(); paymentRepoSetup.Setup(x => x.GetList(It.IsAny<Expression<Func<PaymentViewModel, bool>>>())) .Returns((Expression<Func<PaymentViewModel, bool>> filter) => paymentList.Where(filter.Compile()).ToList()); //Excution var result = new CategorySpreadingDataProvider(paymentRepoSetup.Object).GetValues(DateTime.Today.AddDays(-3), DateTime.Today.AddDays(3)).ToList(); //Assertion result.Count.ShouldBe(1); result.First().Value.ShouldBe(30); }
public void GetValues_InitializedData_HandleDateCorrectly() { //Setup var testList = new List<CategoryViewModel> { new CategoryViewModel {Id = 1, Name = "Einkaufen"}, new CategoryViewModel {Id = 2, Name = "Ausgehen"}, new CategoryViewModel {Id = 3, Name = "Bier"} }; var paymentList = new List<PaymentViewModel> { new PaymentViewModel { Id = 1, Type = (int) PaymentType.Expense, Date = DateTime.Today.AddDays(-5), Amount = 60, Category = testList[0], CategoryId = 1 }, new PaymentViewModel { Id = 2, Type = (int) PaymentType.Expense, Date = DateTime.Today, Amount = 90, Category = testList[1], CategoryId = 2 }, new PaymentViewModel { Id = 3, Type = (int) PaymentType.Expense, Date = DateTime.Today.AddDays(5), Amount = 40, Category = testList[2], CategoryId = 3 } }; var paymentRepoSetup = new Mock<IPaymentRepository>(); paymentRepoSetup.Setup(x => x.GetList(It.IsAny<Expression<Func<PaymentViewModel, bool>>>())) .Returns((Expression<Func<PaymentViewModel, bool>> filter) => paymentList.Where(filter.Compile()).ToList()); //Excution var result = new CategorySpreadingDataProvider(paymentRepoSetup.Object).GetValues(DateTime.Today.AddDays(-3), DateTime.Today.AddDays(3)).ToList(); //Assertion result.Count.ShouldBe(1); result.First().Value.ShouldBe(90); }