public void InvoiceAddLineItemEventAddsLineItem() { _mockInvoiceView.GetCustomer += null; LastCall.IgnoreArguments(); _mockInvoiceView.AddInvoiceLine += null; var addInvoiceLineEventRaiser = LastCall.IgnoreArguments().GetEventRaiser(); _mockInvoiceView.CalculateTotals += null; LastCall.IgnoreArguments(); _mockInvoiceView.SaveInvoice += null; LastCall.IgnoreArguments(); const int quantity = 3; const decimal amount = 35.00M; ITaxesService taxesService = new TaxesService(); Expect.Call(_mockInvoiceView.Quantity).Return(quantity); Expect.Call(_mockInvoiceView.Amount).Return(amount); Expect.Call(_mockTaxesRepository.GetTaxesService()).Return(taxesService); var invoiceItem = new InvoiceItem(quantity, amount); var invoice = new Invoice(taxesService); invoice.AddLineItem(invoiceItem); _mockInvoiceView.InvoiceLineItems = invoice.InvoiceItems; _mockRepository.ReplayAll(); var invoicePresenter = new InvoicePresenter(_mockCustomerRepository, _mockTaxesRepository, _mockInvoiceRepository, _mockInvoiceView); addInvoiceLineEventRaiser.Raise(_mockInvoiceView, EventArgs.Empty); }
public void InvoiceCalculateTotalsEventDisplaysSubTotalTaxesAndTotal() { _mockInvoiceView.GetCustomer += null; LastCall.IgnoreArguments(); _mockInvoiceView.AddInvoiceLine += null; LastCall.IgnoreArguments(); _mockInvoiceView.CalculateTotals += null; var calculateTotalsEventRaiser = LastCall.IgnoreArguments().GetEventRaiser(); _mockInvoiceView.SaveInvoice += null; LastCall.IgnoreArguments(); ITaxesService taxesService = new TaxesService(); Expect.Call(_mockTaxesRepository.GetTaxesService()).Return(taxesService); var invoice = new Invoice(taxesService); _mockInvoiceView.SubTotal = invoice.SubTotal; _mockInvoiceView.TaxCalculations = invoice.TaxCalculations; _mockInvoiceView.Total = invoice.Total; _mockRepository.ReplayAll(); var invoicePresenter = new InvoicePresenter(_mockCustomerRepository, _mockTaxesRepository, _mockInvoiceRepository, _mockInvoiceView); calculateTotalsEventRaiser.Raise(_mockInvoiceView, EventArgs.Empty); }
// Helper method private TaxesService CreateTaxesService() { var userID = Guid.Parse(User.Identity.GetUserId()); var service = new TaxesService(userID); return(service); }
public void TaxesServiceRejectsOverlappingTaxesPerTaxType() { var taxesService = new TaxesService(); var pstTax1 = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.City); var pstTax2 = new Tax("PST", DateTime.Today.AddMonths(6), DateTime.Today.AddYears(1), JurisdictionEnum.City); taxesService.AddTax(pstTax1); taxesService.AddTax(pstTax2); }
public void TaxesServiceRejectsDuplicateTaxes() { var taxesService = new TaxesService(); var pstTax1 = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.City); var pstTax2 = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.City); taxesService.AddTax(pstTax1); taxesService.AddTax(pstTax2); }
public void TaxesServiceCanAccumulateTaxes() { var taxesService = new TaxesService(); var pstTax = new Tax("PST", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.City); taxesService.AddTax(pstTax); Assert.IsTrue(taxesService.Taxes.Contains(pstTax)); }
public PrintfulClient(string apiKey) { _productService = new ProductService(apiKey); _countryService = new CountryService(apiKey); _shippingService = new ShippingService(apiKey); _taxesService = new TaxesService(apiKey); _storeInformationService = new StoreInformationService(apiKey); _warehouseProductsService = new WarehouseProductsService(apiKey); _warehouseShipmentsService = new WarehouseShipmentsService(apiKey); _fileLibraryService = new FileLibraryService(apiKey); _orderService = new OrderService(apiKey); _webhookSetupService = new WebhookSetupService(apiKey); }
public void TaxesServiceDistinguishesCorrectlyEachJurisdiction() { var taxesService = new TaxesService(); var city = new City("CityTax", taxesService); var cityTax = new Tax("CityTax", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.City); city.AddTax(cityTax); var provinceState = new City("ProvStateTax", taxesService); var provStateTax = new Tax("ProvStateTax", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.ProvinceState); provinceState.AddTax(provStateTax); var country = new City("CountryTax", taxesService); var countryTax = new Tax("CountryTax", DateTime.Today, DateTime.Today.AddMonths(6), JurisdictionEnum.Country); country.AddTax(countryTax); Assert.AreEqual(1, city.Taxes.Count); Assert.AreEqual(1, provinceState.Taxes.Count); Assert.AreEqual(1, country.Taxes.Count); }
public void Test1() { var moqDatabase = new Mock <TaxesAPI.Models.TaxesContext>(); var service = new TaxesService(moqDatabase.Object); var taxesServiceMock = new Mock <ITaxesService>(); var taxesList = new List <TaxesItem>(); taxesList.Add(new TaxesItem { Municipality = "istanbul", Date = DateTime.UtcNow, TaxesSchedule = "daily", TaxesRatio = 1.2 }); taxesServiceMock.Setup(i => i.ReadAsync("istanbul")).ReturnsAsync(taxesList); ////var service = new TaxesRatioService(); //taxesList.Add(new TaxesItem { Municipality = "istanbul", Date = DateTime.UtcNow, TaxesSchedule = "daily", TaxesRatio = 1.2 }); //var result = service.DailyControl(taxesList, DateTime.UtcNow.AddHours(-1)); // Assert.Equal(1.2, result); }
public void InvoiceSaveInvoiceToRepository() { _mockInvoiceView.GetCustomer += null; LastCall.IgnoreArguments(); _mockInvoiceView.AddInvoiceLine += null; LastCall.IgnoreArguments(); _mockInvoiceView.CalculateTotals += null; LastCall.IgnoreArguments(); _mockInvoiceView.SaveInvoice += null; var saveInvoiceEventRaiser = LastCall.IgnoreArguments().GetEventRaiser(); ITaxesService taxesService = new TaxesService(); Expect.Call(_mockTaxesRepository.GetTaxesService()).Return(taxesService); var invoice = new Invoice(taxesService); _mockInvoiceRepository.SaveInvoice(invoice); _mockRepository.ReplayAll(); var invoicePresenter = new InvoicePresenter(_mockCustomerRepository, _mockTaxesRepository, _mockInvoiceRepository, _mockInvoiceView); saveInvoiceEventRaiser.Raise(_mockInvoiceView, EventArgs.Empty); }