Example #1
0
        public void HelloWorldTest_CyclesThroughWholeProgram()
        {
            new HeavyTestRunner(_logger).RunServerAndBrowserAndExecute(
                MagicsForTests.ClientSideFlows.HelloWorld, (assertX, server, browser) => {
                assertX.DialogIsVisibleInBrowser("Hello there");

                browser
                .FindElementByXPath(XPathBuilder.Dialog("Hello there").InBody("/input[@type='text']"))
                .SendKeys(someName);

                assertX.NoServiceCallsMadeOnServer();

                browser
                .FindElementByXPath(XPathBuilder.Dialog("Hello there").HasEnabledButtonAction("OK"))
                .Click();

                assertX.DialogIsVisibleInBrowser("Server reply");

                assertX.InvocationsMadeOnServerAre(x => x.ResType == ResourceType.RegularPostService, () => {
                    var onBefore   = FilterInvocation.OfMethod((IHelloWorldService x) => x.SayHello(someName));
                    var actualCall = ServiceCall.OfMethod((IHelloWorldService x) => x.SayHello(someName));
                    var onAfter    = FilterInvocation.ExpectOnConnectionAfterFor(onBefore);

                    return(new CsChoice <ServiceCall, FilterInvocation>[] { onBefore, actualCall, onAfter });
                });

                assertX.MatchesXPathInBrowser(
                    XPathBuilder
                    .Dialog("Server reply")
                    .HasReadOnlyLabel($"Hello {someName}. How are you?"));
            });
        }