public async Task Should_support_pipe_configuration_on_the_result()
        {
            IPipe <RequestContext> pipe = CreateHandlerPipe();

            IRequestPipe <CheckInventory, CheckInventoryResult> requestPipe = pipe.CreateRequestPipe <CheckInventory, CheckInventoryResult>(x =>
            {
                x.UseFilter(new UpdateCacheFilter(_inventoryCache));
            });

            var checkInventory = new CheckInventory()
            {
                ItemNumber = "ABC123", Quantity = 2
            };

            var timer  = Stopwatch.StartNew();
            var result = await requestPipe.Send(checkInventory).Result();

            timer.Stop();

            Assert.That(result.ItemNumber, Is.EqualTo(checkInventory.ItemNumber));
            Assert.That(result.QuantityOnHand, Is.EqualTo(checkInventory.ItemNumber.GetHashCode() % 100));
            Assert.That(timer.Elapsed, Is.GreaterThan(TimeSpan.FromMilliseconds(200)));

            timer  = Stopwatch.StartNew();
            result = await requestPipe.Send(checkInventory).Result();

            timer.Stop();

            Assert.That(result.ItemNumber, Is.EqualTo(checkInventory.ItemNumber));
            Assert.That(result.QuantityOnHand, Is.EqualTo(checkInventory.ItemNumber.GetHashCode() % 100));
            Assert.That(timer.Elapsed, Is.LessThan(TimeSpan.FromMilliseconds(20)));
        }
        public ChaKuCun()
        {
            InitializeComponent();
            this.InitDefualtSettings();
            var model = new CheckInventory();

            this.ApplyBindings(this, model);
            CurrentIInputElement = txtbarcode;
            this.Loaded         += ChaKuCun_Loaded;
        }
Exemple #3
0
        public void UnsetValidCharactersList()
        {
            m_dataSource.m_tokens.Add(new DummyTextToken("abcdefgh",
                                                         TextType.Verse, true, false, "Paragraph"));

            // This should not crash, even if the valid characters list has not been set.
            List <TextTokenSubstring> refs =
                CheckInventory.GetReferences(m_dataSource.TextTokens(), string.Empty);

            Assert.AreEqual(8, refs.Count);
        }
Exemple #4
0
        public void InventoryMode()
        {
            m_dataSource.m_tokens.Add(new DummyTextToken("Eph. 2:10",
                                                         TextType.Verse, true, false, "Paragraph", string.Empty, "en"));
            m_dataSource.m_tokens.Add(new DummyTextToken("For we are God's workmanship...",
                                                         TextType.Verse, true, false, "Paragraph"));

            List <TextTokenSubstring> refs =
                CheckInventory.GetReferences(m_dataSource.TextTokens(), string.Empty);

            // We requested only the default vernacular.
            // Should only get references from the second token.
            Assert.AreEqual(31, refs.Count);
        }
Exemple #5
0
        public async Task HandleAsync(IMessageContext <SaveOrder> context, CancellationToken cancellationToken = default)
        {
            _logger.LogInformation($"processing order '{context.Message.OrderId}'...");

            this.State.OrderId = context.Message.OrderId;

            var startCreditCheck = ProcessCreditCheck.New(context.Message.OrderId);

            this.Publish(startCreditCheck);

            var startInventoryCheck = CheckInventory.New(context.Message.OrderId);

            this.Publish(startInventoryCheck);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        void Test(string[,] result, string text)
        {
            m_dataSource.Text = text;

            List <TextTokenSubstring> tts =
                CheckInventory.GetReferences(m_dataSource.TextTokens(), string.Empty);

            Assert.AreEqual(result.GetUpperBound(0) + 1, tts.Count,
                            "A different number of results was returned than what was expected.");

            for (int i = 0; i <= result.GetUpperBound(0); ++i)
            {
                Assert.AreEqual(result[i, 0], tts[i].InventoryText, "InventoryText number: " + i);
                Assert.AreEqual(result[i, 1], tts[i].Message, "Message number: " + i);
            }
        }
        public async Task Should_support_awesome_caching_speed()
        {
            IPipe <RequestContext> pipe = CreateHandlerPipe();

            IRequestPipe <CheckInventory, CheckInventoryResult> requestPipe = pipe.CreateRequestPipe <CheckInventory, CheckInventoryResult>(x =>
            {
                x.UseFilter(new UpdateCacheFilter(_inventoryCache));
            });

            var checks = new CheckInventory[]
            {
                new CheckInventory()
                {
                    ItemNumber = "ABC123", Quantity = 2
                },
                new CheckInventory()
                {
                    ItemNumber = "DEF456", Quantity = 4
                },
                new CheckInventory()
                {
                    ItemNumber = "GHI789", Quantity = 6
                },
            };

            var timer = Stopwatch.StartNew();

            for (var i = 0; i < 100; i++)
            {
                await requestPipe.Send(checks[i % checks.Length]).Result();
            }

            timer.Stop();

            Console.WriteLine("Total time: {0}ms", timer.ElapsedMilliseconds);
            Console.WriteLine("Total calls: {0}", _totalCalls);

            Assert.That(timer.Elapsed, Is.LessThan(TimeSpan.FromMilliseconds(1000)));
        }