Ejemplo n.º 1
0
        public void ProcessOrder_ShouldReturnStatusCode201()
        {
            var incommingOrder = new IncommingOrderDto {
                OrderNumber = 5, UserId = 456, PayableAmount = 99.12, PaymentGateWay = "Seb", Description = "This is order number 5"
            };
            var orderList = new MockOrderRepo();
            var orders    = new Mock <IOrderRepo>();

            orders.Setup(x => x.AddNewOrderDetails(incommingOrder)).Returns(orderList.AddNewOrderDetails(incommingOrder));

            var clientFactory = new Mock <IHttpClientFactory>();

            clientFactory.Setup(x => x.CreateClient(incommingOrder.PaymentGateWay)).Returns(() =>
            {
                var client         = new HttpClient();
                client.BaseAddress = new Uri("https://localhost:6001/api/paymentgateway/process/seb");
                return(client);
            }
                                                                                            );

            var billingController = new BillingController(orders.Object, clientFactory.Object);
            var result            = billingController.ProcessOrder(incommingOrder).Result;
            var okResult          = result as ObjectResult;

            Assert.NotNull(okResult);
            Assert.True(okResult is ObjectResult);
            Assert.IsType <CreatedOrderDto>(okResult.Value);
            Assert.Equal(StatusCodes.Status201Created, okResult.StatusCode);
        }
Ejemplo n.º 2
0
        public void It_Should_Return_False_If_The_Bill_Being_Sent_Is_Null()
        {
            Bill bill = null;

            bool result = BillingController.SendBill(bill);

            Assert.IsTrue(!result);
        }
Ejemplo n.º 3
0
 protected override void onDestroy()
 {
     base.OnDestroy();
     BillingController.unregisterObserver(mBillingObserver); // Avoid
     // receiving
     // notifications after
     // destroy
     BillingController.setConfiguration(null);
 }
Ejemplo n.º 4
0
 public void Setup()
 {
     supplier = DataMother.CreateSupplier();
     session.Save(supplier);
     client = DataMother.TestClient();
     session.Save(client);
     controller = new BillingController();
     Prepare(controller);
 }
Ejemplo n.º 5
0
        public BillingControllerTest()
        {
            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new BillingProfile());
            });

            mapper     = mappingConfig.CreateMapper();
            repository = new MockBasicBillingRepoImpl();
            controller = new BillingController(repository, mapper);
        }
Ejemplo n.º 6
0
        public BillingControllerMoqTest()
        {
            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new BillingProfile());
            });

            mapper = mappingConfig.CreateMapper();
            basicBillingRepoMock = new Mock <IBasicBillingRepo>();
            controller           = new BillingController(basicBillingRepoMock.Object, mapper);
        }
Ejemplo n.º 7
0
        public void Billing_Controller_Should_Return_False_If_A_Bill_Is_Being_Sent_On_A_Weekend(int day, int month)
        {
            Bill bill = new Bill
            {
                Amount   = 5000,
                DateSent = new DateTime(2019, month, day)
            };

            bool result = BillingController.SendBill(bill);

            Assert.IsTrue(!result);
        }
Ejemplo n.º 8
0
        public void It_Should_Return_True_If_The_Bill_Being_Sent_Is_Not_Null()
        {
            Bill bill = new Bill
            {
                Amount   = 5000,
                DateSent = new DateTime(2019, 8, 14)
            };

            bool result = BillingController.SendBill(bill);

            Assert.IsTrue(result);
        }
Ejemplo n.º 9
0
        public override void onCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            BillingController.registerObserver(mBillingObserver);
            BillingController.setConfiguration(this); // This activity will provide
            // the public key and salt
            this.checkBillingSupported();
            if (!mBillingObserver.isTransactionsRestored())
            {
                BillingController.restoreTransactions(this);
            }
        }
Ejemplo n.º 10
0
        public void Get_ShouldReturnStatusCode200()
        {
            var orderList = new MockOrderRepo();
            var orders    = new Mock <IOrderRepo>();

            orders.Setup(x => x.GetAllOrders()).Returns(orderList.GetAllOrders());
            var clientFactory = new Mock <IHttpClientFactory>();

            var billingController = new BillingController(orders.Object, clientFactory.Object);
            var result            = billingController.Get().Result;
            var okResult          = result as OkObjectResult;

            Assert.NotNull(okResult);
            Assert.True(okResult is OkObjectResult);
            Assert.IsType <List <ReadOrderDto> >(okResult.Value);
            Assert.Equal(StatusCodes.Status200OK, okResult.StatusCode);
        }
        public void CreateCreditNotes_ShouldBeThrowsAnException_WhenInvoiceIdIsNotValid()
        {
            var creditNote = new CreditNoteRequest {
                Amount = 100, BillingSystemId = 2, ClientId = 1, InvoiceId = 0, Type = 1
            };
            var loggerMock         = new Mock <ILogger <BillingController> >();
            var billingServiceMock = new Mock <IBillingService>();

            billingServiceMock.Setup(x => x.CreateCreditNote(It.IsAny <CreditNoteRequest>())).ThrowsAsync(new ArgumentException("Value can not be null", "InvoiceId"));

            var controller = new BillingController(loggerMock.Object, billingServiceMock.Object);

            // Act
            var ex = Assert.ThrowsAsync <ArgumentException>(() => controller.CreateCreditNote(creditNote));

            // Assert
            Assert.Equal("Value can not be null (Parameter 'InvoiceId')", ex.Result.Message);
        }
        public void UpdateCreditNotePaymentStatus_ShouldBeThrowsAnException_WhenBillingSystemIdIsNotValid()
        {
            var updateCreditNotePaymentStatusRequest = new UpdateCreditNotePaymentStatusRequest {
                BillingSystemId = 0, Type = 2, CreditNoteId = 1
            };
            var loggerMock         = new Mock <ILogger <BillingController> >();
            var billingServiceMock = new Mock <IBillingService>();

            billingServiceMock.Setup(x => x.UpdateCreditNotePaymentStatus(updateCreditNotePaymentStatusRequest)).ThrowsAsync(new ArgumentException("Value can not be null", "BillingSystemId"));

            var controller = new BillingController(loggerMock.Object, billingServiceMock.Object);

            // Act
            var ex = Assert.ThrowsAsync <ArgumentException>(() => controller.UpdateCreditNotePaymentStatus(updateCreditNotePaymentStatusRequest));

            // Assert
            Assert.Equal("Value can not be null (Parameter 'BillingSystemId')", ex.Result.Message);
        }
        public void CancelCreditNote_ShouldBeHttpStatusCodeOk_WhenRequestIsValid_ShouldBeThrowsAnException_WhenBillingSystemIdIsNotValid()
        {
            var cancelCreditNoteRequest = new CancelCreditNoteRequest {
                BillingSystemId = 0, CreditNoteId = 1
            };

            var loggerMock         = new Mock <ILogger <BillingController> >();
            var billingServiceMock = new Mock <IBillingService>();

            billingServiceMock.Setup(x => x.CancelCreditNote(cancelCreditNoteRequest)).ThrowsAsync(new ArgumentException("Value can not be null", "BillingSystemId"));

            var controller = new BillingController(loggerMock.Object, billingServiceMock.Object);

            // Act
            var ex = Assert.ThrowsAsync <ArgumentException>(() => controller.CancelCreditNote(cancelCreditNoteRequest));

            // Assert
            Assert.Equal("Value can not be null (Parameter 'BillingSystemId')", ex.Result.Message);
        }
        public async Task CancelCreditNote_ShouldBeHttpStatusCodeOk_WhenRequestIsValid()
        {
            var cancelCreditNoteRequest = new CancelCreditNoteRequest {
                BillingSystemId = 2, CreditNoteId = 1
            };

            var loggerMock         = new Mock <ILogger <BillingController> >();
            var billingServiceMock = new Mock <IBillingService>();

            billingServiceMock.Setup(x => x.CancelCreditNote(cancelCreditNoteRequest)).Returns(Task.CompletedTask);

            var controller = new BillingController(loggerMock.Object, billingServiceMock.Object);

            // Act
            var response = await controller.CancelCreditNote(cancelCreditNoteRequest);

            // Assert
            Assert.IsType <OkObjectResult>(response);
            Assert.Equal("Successfully", ((ObjectResult)response).Value);
        }
Ejemplo n.º 15
0
        public async Task CreateBillingRequest_ShouldBeHttpStatusCodeOk_WhenCurrencyRateValid()
        {
            var loggerMock         = new Mock <ILogger <BillingController> >();
            var billingServiceMock = new Mock <IBillingService>();

            billingServiceMock.Setup(x => x.SendCurrencyToSap(It.IsAny <List <CurrencyRateDto> >()))
            .Returns(Task.CompletedTask);

            var controller = new BillingController(loggerMock.Object, billingServiceMock.Object);

            // Act
            var response = await controller.CreateBillingRequest(new List <BillingRequest>
            {
                new BillingRequest()
            });

            // Assert
            Assert.IsType <OkObjectResult>(response);
            Assert.Equal("Successfully", ((ObjectResult)response).Value);
        }
        public void UpdatePaymentStatusRequest_ShouldBeThrowsAnException_WhenRequestNotValid()
        {
            var loggerMock         = new Mock <ILogger <BillingController> >();
            var billingServiceMock = new Mock <IBillingService>();

            billingServiceMock.Setup(x => x.UpdatePaymentStatus(It.IsAny <UpdatePaymentStatusRequest>())).ThrowsAsync(new ArgumentException("Value can not be null", "InvoiceId"));

            var controller = new BillingController(loggerMock.Object, billingServiceMock.Object);

            // Act
            var ex = Assert.ThrowsAsync <ArgumentException>(() => controller.UpdatePaymentStatus(new UpdatePaymentStatusRequest
            {
                TransactionApproved = true,
                BillingSystemId     = 2,
                InvoiceId           = 0
            }));

            // Assert
            Assert.Equal("Value can not be null (Parameter 'InvoiceId')", ex.Result.Message);
        }
        public async Task CreateCreditNotes_ShouldBeHttpStatusCodeOk_WhenRequestIsValid()
        {
            var creditNote = new CreditNoteRequest {
                Amount = 100, BillingSystemId = 2, ClientId = 1, InvoiceId = 1, Type = 1
            };

            var loggerMock         = new Mock <ILogger <BillingController> >();
            var billingServiceMock = new Mock <IBillingService>();

            billingServiceMock.Setup(x => x.CreateCreditNote(It.IsAny <CreditNoteRequest>()))
            .Returns(Task.CompletedTask);

            var controller = new BillingController(loggerMock.Object, billingServiceMock.Object);

            // Act
            var response = await controller.CreateCreditNote(creditNote);

            // Assert
            Assert.IsType <OkObjectResult>(response);
            Assert.Equal("Successfully", ((ObjectResult)response).Value);
        }
        public async Task UpdatePaymentStatusRequest_ShouldBeHttpStatusCodeOk_WhenRequestIsValid()
        {
            var loggerMock         = new Mock <ILogger <BillingController> >();
            var billingServiceMock = new Mock <IBillingService>();

            billingServiceMock.Setup(x => x.UpdatePaymentStatus(It.IsAny <UpdatePaymentStatusRequest>()))
            .Returns(Task.CompletedTask);

            var controller = new BillingController(loggerMock.Object, billingServiceMock.Object);

            // Act
            var response = await controller.UpdatePaymentStatus(new UpdatePaymentStatusRequest
            {
                TransactionApproved = true,
                BillingSystemId     = 2,
                InvoiceId           = 1
            });

            // Assert
            Assert.IsType <OkObjectResult>(response);
            Assert.Equal("Successfully", ((ObjectResult)response).Value);
        }
Ejemplo n.º 19
0
        public JsonResult DelFoodItemFromMenusBillingSection(int menusBillingDetailsID)
        {
            var data = context.tbl_MenusBillingDetailsWithBillNo.SingleOrDefault(s => s.ID == menusBillingDetailsID);
            List <MenusBillingDetailsWithBillNo> menusDetailList = new List <MenusBillingDetailsWithBillNo>();

            if (data != null)
            {
                int?billNo = data.BillNo;
                context.Entry(data).State = EntityState.Deleted;
                context.SaveChanges();

                var invData = context.tbl_InventoryUsage.Where(a => a.MenusBillingDetailsID == menusBillingDetailsID && a.GST_NonGST_Bill == "GST").ToList();
                if (invData.Count() > 0)
                {
                    foreach (var i in invData)
                    {
                        context.Entry(i).State = EntityState.Deleted;
                        context.SaveChanges();
                    }
                }
                BillingController billContr = new BillingController();
                billContr.calculateAmount(billNo);

                var lst = context.tbl_MenusBillingDetailsWithBillNo.Where(s => s.BillNo == billNo).ToList();
                foreach (var i in lst)
                {
                    menusDetailList.Add(new MenusBillingDetailsWithBillNo()
                    {
                        ID       = i.ID,
                        FoodName = i.FoodName,
                        Price    = i.Price,
                        Quantity = i.Quantity
                    });
                }
            }
            return(Json(menusDetailList));
        }
Ejemplo n.º 20
0
 /**
  * Returns the billing status. If it's currently unknown, requests to check
  * if billing is supported and
  * {@link AbstractBillingActivity#onBillingChecked(bool)} should be
  * called later with the result.
  *
  * @return the current billing status (unknown, supported or unsupported).
  * @see AbstractBillingActivity#onBillingChecked(bool)
  */
 public BillingController.BillingStatus checkBillingSupported()
 {
     return(BillingController.checkBillingSupported(this));
 }
Ejemplo n.º 21
0
 /**
  * Requests to restore all transactions.
  */
 public void restoreTransactions()
 {
     BillingController.restoreTransactions(this);
 }
Ejemplo n.º 22
0
        static void Main(string[] args)
        {
            BillingController billingController = new BillingController();

            billingController.BillCurrentMonth();
        }
Ejemplo n.º 23
0
 /**
  * Requests the purchase of the specified item. The transaction will not be
  * confirmed automatically; such confirmation could be handled in
  * {@link AbstractBillingActivity#onPurchaseExecuted(String)}. If automatic
  * confirmation is preferred use
  * {@link BillingController#requestPurchase(android.content.Context, String, bool)}
  * instead.
  *
  * @param itemId
  *            id of the item to be purchased.
  */
 public void requestPurchase(String itemId)
 {
     BillingController.requestPurchase(this, itemId);
 }
Ejemplo n.º 24
0
 private void createInvoice()
 {
     billProduct.Add(BillingController.createInvoice());
     dgvItemTable.DataSource = billProduct;
     dgvItemTable.Refresh();
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MainForm"/> class.
 /// </summary>
 public MainForm()
 {
     InitializeComponent();
     // init controller
     this._controller = new BillingController(this);
 }
 public DefaultSignatureValidator(BillingController.IConfiguration configuration)
 {
     this.configuration = configuration;
 }