Пример #1
0
        public void When_Customer_Order_Amount_Is_Negative_Then_Return_PlaceOrder_Is_False()
        {
            Order order = new Order
            {
                Amount  = -20,
                OrderId = 1,
            };

            var orderAmountFactory   = new OrderAmountFactory();
            var orderAmountValidator = new OrderAmountValidator();
            var configurations       = new ConfigurationsHandler();
            var orderRepository      = new OrderRepository();
            var vatService           = new VatService();

            var orderAmount = orderAmountFactory.GetOrderAmount(order.Amount);

            var orderService = new OrderService(orderAmountFactory,
                                                orderAmountValidator,
                                                vatService,
                                                configurations,
                                                orderRepository);

            int customerId = 1;

            var success = orderService.PlaceOrder(order, customerId);

            Assert.That(success, Is.False);
        }
Пример #2
0
        protected async override Task OnInitializedAsync()
        {
            if (Id != null)
            {
                Guid invoiceNumber = new Guid(Id);
                ViewTitle = "Edit Invoice";
                Invoice   = await InvoiceService.GetInvoice(invoiceNumber);
            }
            else
            {
                ViewTitle = "New Invoice";
                Invoice   = new Invoice
                {
                    DeliveryDate = DateTime.Now,
                    SettleDate   = DateTime.Now,
                    InvoiceDate  = DateTime.Now,
                    InvoiceVat   = "",
                    Client       = "",
                    Currency     = "",
                    ExchangeRate = ""
                };
            }

            Vats          = (await VatService.GetVats()).ToList();
            Currencies    = (await CurrencyService.GetCurrencies()).ToList();
            ExchangeRates = (await ExchangeRateService.GetExchangeRates()).ToList();
            Clients       = (await ClientService.GetClients()).ToList();
            Mapper.Map(Invoice, InvoiceViewModel);
        }
Пример #3
0
        public void When_Customer_Order_Amount_Is_Positive_Then_Return_PlaceOrder_Is_True()
        {
            // this test fails as it is unable to connect the database
            Order order = new Order
            {
                Amount  = 150,
                OrderId = 1,
            };

            var orderAmountFactory   = new OrderAmountFactory();
            var orderAmountValidator = new OrderAmountValidator();
            var configurations       = new ConfigurationsHandler();
            var orderRepository      = new OrderRepository();
            var vatService           = new VatService();

            var orderAmount = orderAmountFactory.GetOrderAmount(order.Amount);

            var orderService = new OrderService(orderAmountFactory,
                                                orderAmountValidator,
                                                vatService,
                                                configurations,
                                                orderRepository);

            int customerId = 1;

            var success = orderService.PlaceOrder(order, customerId);

            Assert.That(success, Is.True);
        }
Пример #4
0
        public void When_Country_Is_Not_UK_Then_Return_VatForOtherCountry()
        {
            var vatService = new VatService();
            var vatRate    = vatService.GetVatRate("Other");

            Assert.AreEqual(vatRate, 0);
        }
Пример #5
0
        public void When_Country_Is_UK_Then_Return_VatForUK()
        {
            var vatService = new VatService();

            var vatRate = vatService.GetVatRate("UK");

            Assert.AreEqual(vatRate, 0.2);
        }
Пример #6
0
        static void Main(string[] args)
        {
            var myContext = new VatContext();

            var plm = myContext.VatEntities.First().Id;

            var myService = new VatService(new UnityOfWork(myContext), new VatRepository(myContext));


            var all = myService.GetAll();

            foreach (var item in all)
            {
                System.Console.WriteLine(item.ProductName + "  " + item.Price);
            }
        }
Пример #7
0
        public void When_Customer_Id_Is_Zero_Then_Return_GetOrder_Is_Null()
        {
            var orderAmountFactory   = new OrderAmountFactory();
            var orderAmountValidator = new OrderAmountValidator();
            var configurations       = new ConfigurationsHandler();
            var orderRepository      = new OrderRepository();
            var vatService           = new VatService();

            var orderService = new OrderService(orderAmountFactory,
                                                orderAmountValidator,
                                                vatService,
                                                configurations,
                                                orderRepository);

            int customerId = 0;

            var success = orderService.GetOrder(customerId);

            Assert.Null(success);
        }
Пример #8
0
        public void When_Customer_Id_Is_Positive_Then_Return_GetOrder_Is_Not_Null()
        {
            // fails as unable to access the database

            var orderAmountFactory   = new OrderAmountFactory();
            var orderAmountValidator = new OrderAmountValidator();
            var configurations       = new ConfigurationsHandler();
            var orderRepository      = new OrderRepository();
            var vatService           = new VatService();

            var orderService = new OrderService(orderAmountFactory,
                                                orderAmountValidator,
                                                vatService,
                                                configurations,
                                                orderRepository);

            int customerId = 12;

            var success = orderService.GetOrder(customerId);

            Assert.NotNull(success);
        }
Пример #9
0
 public void SetUp()
 {
     vatProvider = new Mock <IVatProvider>();
     vatService  = new VatService(vatProvider.Object);
 }
Пример #10
0
 public static void SetDebugService(this VatService vs, DebugService ds)
 {
     Reflector.SetInstanceFieldByName(vs, "m_DebugService", ds, ReflectionWays.SystemReflection);
 }
Пример #11
0
 public VatServiceProxy(VatService vs)
 {
     m_VatService = vs;
 }
 public IVatDevice GetVatDevice(string str)
 {
     return(VatService.GetVatDevice(str) as VatDevice);
 }
 public IVatDevice GetVatDevice(ICoreObject controllerTarget)
 {
     return(VatService.GetVatDevice(controllerTarget) as VatDevice);
 }