Ejemplo n.º 1
0
        public void WhenIntegrateShould_ChangeItem_InvoiceSummary()
        {
            var dataServices = SetupDataServices();
            // this setup the toolbar.
            int state        = 0;
            var eventManager = new Mock <IEventManager>();

            eventManager.Setup(x =>
                               x.NotifyToolBar(It.IsAny <DataPayLoad>())).Callback((DataPayLoad p) =>
            {
                if (state == 0)
                {
                    Assert.AreEqual(DataPayLoad.Type.RegistrationPayload, p.PayloadType);
                    ++state;
                }
                else
                {
                    Assert.AreEqual(DataPayLoad.Type.Update, p.PayloadType);
                    Assert.IsTrue(p.HasDataObject);
                    Assert.NotNull(p.DataObject);
                }
                Assert.IsNotEmpty(p.PrimaryKeyValue);
                Assert.AreEqual(DataSubSystem.InvoiceSubsystem, p.Subsystem);
            });
            IDictionary <string, object> valueDictionary = new Dictionary <string, object>();

            valueDictionary["AssitTableName"]  = "CLIENT_ASSIST";
            valueDictionary["DataFieldFirst"]  = "CLIENT_FAC";
            valueDictionary["DataFieldSecond"] = string.Empty;
            valueDictionary["DataObject"]      = new InvoiceDto();
            valueDictionary["Field"]           = "CLIENT_FAC";
            valueDictionary["ChangedCode"]     = "2881";
            valueDictionary["ChangedValue"]    = "2881";
            valueDictionary["ChangedValue2"]   = "05";
            var viewModel = new InvoiceInfoViewModel(dataServices, _dialogServices.Object, eventManager.Object,
                                                     _regionManager.Object, _controller.Object);
            var invoiceDto = new InvoiceDto();

            invoiceDto.NUMERO_FAC = "28289";
            var dataPayLoad = new DataPayLoad()
            {
                PayloadType     = DataPayLoad.Type.Update,
                PrimaryKeyValue = "28289",
                DataObject      = new Invoice("28289", invoiceDto),
                HasDataObject   = true
            };

            viewModel.IncomingPayload(dataPayLoad);
            viewModel.ItemChangedCommand.Execute(valueDictionary);
        }
Ejemplo n.º 2
0
        public async Task WhenIntegrateShould_Load_ClientInvoice()
        {
            var dataServices    = SetupDataServices();
            var dialogServices  = new Mock <IDialogService>();
            var eventManager    = new Mock <IEventManager>();
            var regionManager   = new Mock <IRegionManager>();
            var controller      = new Mock <IInteractionRequestController>();
            var invoiceServices = dataServices.GetInvoiceDataServices();
            var invoiceSummary  = await invoiceServices.GetPagedSummaryDoAsync(1, 10);

            var singleInvoice = invoiceSummary.FirstOrDefault();

            if (singleInvoice != null)
            {
                var invoiceDto = await invoiceServices.GetDoAsync(singleInvoice.InvoiceName);

                var dataPayLoad = new DataPayLoad()
                {
                    PayloadType     = DataPayLoad.Type.Show,
                    PrimaryKeyValue = invoiceDto.Value.NUMERO_FAC,
                    DataObject      = invoiceDto,
                    HasDataObject   = true
                };
                var viewModel = new InvoiceInfoViewModel(dataServices,
                                                         dialogServices.Object,
                                                         eventManager.Object,
                                                         regionManager.Object,
                                                         controller.Object);
                viewModel.IncomingPayload(dataPayLoad);
                Assert.Greater(viewModel.ClientDto.Count(), 0);
            }
            else
            {
                Assert.Fail("No invoice in the system");
            }
        }