Esempio n. 1
0
        public bool NoErrorsWereFound()
        {
            StoryTellerAssert.Fail(_current.Errors.Any(), () => $@"Found:
{_current.Errors.Select(x => $"* {x}{Environment.NewLine}")}
");
            return(true);
        }
Esempio n. 2
0
        public void NavigateToUrl(string url)
        {
            url = correctUrl(url);

            var driver = _browserLifecycle.Driver;

            Logger.Navigating(url, () => driver.Navigate().GoToUrl(url));

            string title = "";

            try
            {
                title = driver.Title;
            }
            catch (Exception)
            {
                // don't throw here.
            }


            if (title == "Exception!")
            {
                var element = driver.FindElement(By.Id("error"));
                StoryTellerAssert.Fail(element == null ? driver.PageSource : element.Text);
            }


            _afterNavigation.AfterNavigation(driver, url);
        }
Esempio n. 3
0
        public bool AckWasSuccessful()
        {
            StoryTellerAssert.Fail(_task.IsFaulted || !_task.IsCompleted,
                                   () => _task.Exception?.ToString() ?? "Task was not completed");

            return(true);
        }
Esempio n. 4
0
        public void EnterData(ISearchContext context, IWebElement element, object data)
        {
            var options = findOptions(element);

            foreach (var option in options)
            {
                if (option.Text == data.ToString())
                {
                    option.Click();
                    return;
                }
            }

            foreach (var option in options)
            {
                if (option.GetAttribute("value") == data.ToString())
                {
                    option.Click();
                    return;
                }
            }

            var message = "Cannot find the desired option\nThe available options are\nDisplay/Key\n";

            foreach (var option in options)
            {
                message += "\n" + "{0}/{1}".ToFormat(option.Text, option.GetAttribute("value"));
            }

            StoryTellerAssert.Fail(message);
        }
Esempio n. 5
0
        public bool CheckList(string[] expected)
        {
            var correct = true;

            var names = _scripts.Select(x => x.Name).ToArray();

            if (names.Length != expected.Length)
            {
                correct = false;
            }
            else
            {
                for (int i = 0; i < names.Length; i++)
                {
                    string actual = names[i];
                    correct = correct && actual == expected[i];
                }
            }

            if (!correct)
            {
                StoryTellerAssert.Fail("Actual:  " + names.Join(", "));
            }

            return(correct);
        }
Esempio n. 6
0
        public bool NoRoutesFor()
        {
            StoryTellerAssert.Fail(_tracks.Any(),
                                   () => { return("Found message routes:\n" + _tracks.Select(x => x.ToString()).Join("\n")); });

            return(true);
        }
Esempio n. 7
0
        public void RunBottles(string commandLine)
        {
            var fileName = Path.Combine(_solutionDirectory, @"bottlesrunner.exe");

            Debug.WriteLine("Execute: {0} {1}".ToFormat(fileName, commandLine));
            var startup = new ProcessStartInfo(fileName, commandLine)
            {
                CreateNoWindow         = true,
                RedirectStandardError  = true,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true,
                UseShellExecute        = false,
                WorkingDirectory       = _solutionDirectory
            };

            try
            {
                var process       = Process.Start(startup);
                var processOutput = process.StandardOutput.ReadToEnd();
                process.WaitForExit();

                if (process.ExitCode != 0)
                {
                    StoryTellerAssert.Fail("Command failed! -- " + commandLine + "\n" + processOutput);
                }
            }
            catch (StorytellerAssertionException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ApplicationException("Trying to run " + fileName, e);
            }
        }
Esempio n. 8
0
        public async Task <bool> CanSendItemDurably()
        {
            cleanDatabase();


            var item = new ItemCreated
            {
                Name = "Shoe",
                Id   = Guid.NewGuid()
            };

            await theSender.TrackActivity().AlsoTrack(theReceiver).SendMessageAndWait(item);

            await Task.Delay(500.Milliseconds());


            await assertReceivedItemMatchesSent(item);

            await assertIncomingEnvelopesIsZero();


            var senderCounts = await assertNoPersistedOutgoingEnvelopes();

            StoryTellerAssert.Fail(senderCounts.Outgoing > 0, "There are still persisted, outgoing messages");

            return(true);
        }
        public void SendMessage([SelectionList("MessageTypes")] string messageType, string name)
        {
            if (!_initialized)
            {
                if (_publisher == null)
                {
                    var registry = new JasperRegistry
                    {
                        ServiceName = "Publisher"
                    };

                    _publisher = _nodes.Add(registry);
                }


                _initialized = true;
            }

            var history = _nodes.History;

            var type    = messageTypeFor(messageType);
            var message = Activator.CreateInstance(type).As <Message>();

            message.Name = name;

            var waiter = history.Watch(() => { _publisher.Messaging.Send(message).Wait(); });

            waiter.Wait(5.Seconds());

            StoryTellerAssert.Fail(!waiter.IsCompleted, "Messages were never completely tracked");
        }
        public override void EnterData(ISearchContext context, IWebElement element, object data)
        {
            if (GetData(context, element).Equals(data))
            {
                EnterDataNested(context, element, data);
                return;
            }

            var beginningCount = int.Parse(element.GetAttribute(ValidationCountKey));

            var stopwatch = Stopwatch.StartNew();

            EnterDataNested(context, element, data);

            // Trigger validation quicker
            element.SendKeys(Keys.Tab);

            var timedOut = !Wait.Until(() => int.Parse(element.GetAttribute(ValidationCountKey)) > beginningCount);

            stopwatch.Stop();
            var longDelay = stopwatch.Elapsed > TimeSpan.FromSeconds(10);

            StoryTellerAssert.Fail(timedOut, "Validation for {0} either took longer than expected or did not occur at all".ToFormat(element));
            StoryTellerAssert.Fail(longDelay, "Input and Validation for {0} took longer than expected".ToFormat(element));
        }
Esempio n. 11
0
 public void fail_directly()
 {
     Exception <StorytellerAssertionException> .ShouldBeThrownBy(() =>
     {
         StoryTellerAssert.Fail("You stink!");
     }).Message.ShouldBe("You stink!");
 }
Esempio n. 12
0
        public async Task <bool> CanSendItemDurably()
        {
            cleanDatabase();


            var item = new ItemCreated
            {
                Name = "Shoe",
                Id   = Guid.NewGuid()
            };

            var waiter = theTracker.WaitFor <ItemCreated>();

            await send(c => c.Send(item));

            await waiter;

            await Task.Delay(500.Milliseconds());


            await assertReceivedItemMatchesSent(item);

            await assertIncomingEnvelopesIsZero();


            var senderCounts = await assertNoPersistedOutgoingEnvelopes();

            StoryTellerAssert.Fail(senderCounts.Outgoing > 0, "There are still persisted, outgoing messages");

            return(true);
        }
Esempio n. 13
0
        public async Task <bool> SendWithReceiverDown()
        {
            cleanDatabase();

            // Shutting it down
            theReceiver.Dispose();
            theReceiver = null;


            var item = new ItemCreated
            {
                Name = "Shoe",
                Id   = Guid.NewGuid()
            };

            await send(c => c.Send(item));

            var outgoing = loadAllOutgoingEnvelopes(theSender).SingleOrDefault();

            StoryTellerAssert.Fail(outgoing == null, "No outgoing envelopes are persisted");
            StoryTellerAssert.Fail(outgoing.MessageType != typeof(ItemCreated).ToMessageTypeName(),
                                   $"Envelope message type expected {typeof(ItemCreated).ToMessageTypeName()}, but was {outgoing.MessageType}");

            return(true);
        }
Esempio n. 14
0
        public void WaitForMessagesToBeProcessed(int count)
        {
            using (var conn = new SqlConnection(ConnectionSource.ConnectionString))
            {
                conn.Open();

                for (var i = 0; i < 200; i++)
                {
                    var actual = (int)conn.CreateCommand("select count(*) from receiver.trace_doc").ExecuteScalar();


                    var envelopeCount = PersistedIncomingCount();


                    Trace.WriteLine($"waitForMessages: {actual} actual & {envelopeCount} incoming envelopes");

                    if (actual == count && envelopeCount == 0)
                    {
                        return;
                    }

                    Thread.Sleep(250);
                }
            }


            StoryTellerAssert.Fail("All messages were not received");
        }
Esempio n. 15
0
        public void BuildTopic(
            [Header("File Path")] string path,
            string Line1 = null,
            string Line2 = null)
        {
            var location = _directory.AppendPath(path.Replace('/', Path.DirectorySeparatorChar));

            var parent = location.ParentDirectory();

            if (!Directory.Exists(parent))
            {
                Directory.CreateDirectory(parent);
            }
            new FileSystem().WriteToFlatFile(location, writer =>
            {
                if (Line1.IsNotEmpty())
                {
                    writer.WriteLine(Line1);
                }
                if (Line2.IsNotEmpty())
                {
                    writer.WriteLine(Line2);
                }
            });

            StoryTellerAssert.Fail(!File.Exists(location), "File was not written");
        }
Esempio n. 16
0
        public bool TheConfirmationEmailWasSent()
        {
            StoryTellerAssert
            .Fail(true, "The email server is not reachable");

            return(true);
        }
Esempio n. 17
0
 public void does_fail_conditionally()
 {
     Exception <StorytellerAssertionException> .ShouldBeThrownBy(() =>
     {
         StoryTellerAssert.Fail(() => true, "Bad!");
     }).Message.ShouldBe("Bad!");
 }
Esempio n. 18
0
        public bool TheLockedOutMessageShouldBeDisplayed()
        {
            string theMessage = TheMessageShouldBe().Trim();

            StoryTellerAssert.Fail(theMessage != LoginKeys.LockedOut.ToString(), () => "Was '{0}'".ToFormat(theMessage));

            return(true);
        }
Esempio n. 19
0
        public bool NoSubscriptionErrors()
        {
            StoryTellerAssert.Fail(_graph.Mismatches.Any(), () => $"Detected publisher/subscriber mismatches{Environment.NewLine}" + _graph.Mismatches.Select(x => x.ToString()).Join(Environment.NewLine));
            StoryTellerAssert.Fail(_graph.NoPublishers.Any(), () => $"Detected subscriptions with no publishers{Environment.NewLine}" + _graph.NoPublishers.Select(x => x.ToString()).Join(Environment.NewLine));
            StoryTellerAssert.Fail(_graph.NoSubscribers.Any(), () => $"Detected published messages with no subscribers{Environment.NewLine}" + _graph.NoSubscribers.Select(x => x.ToString()).Join(Environment.NewLine));

            return(true);
        }
Esempio n. 20
0
        public bool IsOnTheLoginPage()
        {
            var expectedUrl = Application.Urls.UrlFor <LoginRequest>();

            StoryTellerAssert.Fail(!Driver.Url.StartsWith(expectedUrl), "The actual url is " + Driver.Url);

            return(true);
        }
Esempio n. 21
0
        public bool FileDoesNotContain(string File, string Contents)
        {
            string contents = FileSystem.ReadStringFromFile(_root.AppendPath(File));

            StoryTellerAssert.Fail(contents.Contains(Contents), contents);

            return(true);
        }
Esempio n. 22
0
        public bool FailedCheckEnvironmentLogForContains(string description, string trace)
        {
            var log = _environmentLogs.FirstOrDefault(x => x.Description == description);

            StoryTellerAssert.Fail(log == null, () => "Could not find the log entry with that description.  Possibles are:\n" + _environmentLogs.Select(x => x.Description).Join(";\n"));

            return(log.TraceText.Contains(trace));
        }
Esempio n. 23
0
        protected void PushElementContext(By selector)
        {
            var element = SearchContext.FindElement(selector);

            StoryTellerAssert.Fail(element == null, () => "Unable to find element with " + selector);

            PushElementContext(element);
        }
Esempio n. 24
0
        public bool TheAckFailedWithMessage(string message)
        {
            StoryTellerAssert.Fail(_task.Exception == null, "The task exception is null");

            StoryTellerAssert.Fail(!_task.Exception.InnerExceptions.First().ToString().Contains(message), "The actual exception text was:\n" + _task.Exception.ToString());

            return(true);
        }
Esempio n. 25
0
        public IGrammar this[string key] {
            get
            {
                StoryTellerAssert.Fail(!_grammars.Has(key), "Fixture {0} does not have a grammar named {1}".ToFormat(Name, key));

                return(_grammars[key]);
            } set { _grammars[key] = value; }
        }
Esempio n. 26
0
        public void DefaultConnegRules(
            [Default("NULL")] string QueryString,
            [Header("Send As"), SelectionValues("Json", "Xml", "Form Post")] string format,
            [Default("*/*")] string Accepts,
            out string ContentType,
            [Default("200")] out int ResponseCode
            )
        {
            DisableAllSecurity();

            var input = new XmlJsonHtmlMessage
            {
                Id = Guid.NewGuid()
            };

            var response = Runtime.Scenario(_ =>
            {
                var url = "send/mixed";
                if (QueryString.IsNotEmpty())
                {
                    url = url.AppendUrl(QueryString);
                }

                _.Security.Disable();
                _.IgnoreStatusCode();
                _.Post.Url(url);

                _.Request.Accepts(Accepts);

                switch (format)
                {
                case "Json":
                    _.Request.Body.JsonInputIs(input);
                    _.Request.ContentType("application/json");
                    break;

                case "Xml":
                    _.Request.Body.XmlInputIs(input);
                    _.Request.ContentType("application/xml");
                    break;

                case "Form Post":
                    _.Request.Body.WriteFormData(input);
                    _.Request.ContentType(MimeType.HttpFormMimetype);
                    break;

                default:
                    throw new ArgumentException("format");
                }
            });


            StoryTellerAssert.Fail(response.StatusCode == 500, () => response.Body.ReadAsText());

            ContentType  = response.ContentType();
            ResponseCode = response.StatusCode;
        }
Esempio n. 27
0
        public void fail_with_string_builder()
        {
            StoryTellerAssert.Fail(false, () => "bad");

            Exception <StorytellerAssertionException> .ShouldBeThrownBy(() =>
            {
                StoryTellerAssert.Fail(true, () => "*{0}*".ToFormat("Bad"));
            }).Message.ShouldBe("*Bad*");
        }
Esempio n. 28
0
        public void fail_with_boolean()
        {
            StoryTellerAssert.Fail(false, "anything");

            Exception <StorytellerAssertionException> .ShouldBeThrownBy(() =>
            {
                StoryTellerAssert.Fail(true, "Not good");
            }).Message.ShouldBe("Not good");
        }
Esempio n. 29
0
        public void Send(string Key, [SelectionList("Channels")] string Node, [SelectionList("Messages")] string Message)
        {
            var success = MessageHistory.WaitForWorkToFinish(() =>
            {
                Context.State.Retrieve <ServiceBusNodes>().Send(Key, Node, Message);
            });

            StoryTellerAssert.Fail(!success, "MessageHistory tracking failed");
        }
Esempio n. 30
0
        public string DownloadImage(string name)
        {
            var url    = _remoteGraph.GetImageUrl(name);
            var client = new WebClient();
            var bytes  = client.DownloadData("http://localhost" + url);

            StoryTellerAssert.Fail(bytes.Length < 100, "Not enough data detected for the image.  Did it really load?");

            return(client.ResponseHeaders[HttpResponseHeader.ContentType]);
        }