Ejemplo n.º 1
0
    public static void Initiate(this IBus bus)
    {
        Parallel.ForEach(EndpointNames.All, endpointName =>
        {
            var remoteName = endpointName;

            bus.Send(remoteName, new IntMessage())
            .Register <int>(i =>
            {
                Asserter.IsTrue(5 == i, "Incorrect int value");
                Verifier.IntReplyReceivedFrom.Add(remoteName);
            });

            bus.Send(remoteName, new EnumMessage())
            .Register <CustomEnum>(status =>
            {
                Asserter.IsTrue(CustomEnum.Value2 == status, "Incorrect enum value");
                Verifier.EnumReplyReceivedFrom.Add(remoteName);
            });

            bus.Send(remoteName, new ObjectMessage())
            .Register(i =>
            {
                var localResult = (CompletionResult)i.AsyncState;
                var response    = (ObjectResponseMessage)localResult.Messages[0];
                Asserter.IsTrue("PropertyValue" == response.Property, "Incorrect object value");
                Verifier.ObjectReplyReceivedFrom.Add(remoteName);
            }, null);
        });
    }
    public Task Handle(SecondMessage message, IMessageHandlerContext context)
    {
        Verifier.SecondMessageReceivedFrom.Add(message.Sender);
        Asserter.IsTrue("Secret" == message.EncryptedProperty, "Incorrect EncryptedProperty value");

        return(Task.FromResult(0));
    }
Ejemplo n.º 3
0
        public void WaitDeselected(Func <WebBaseElement, string, bool> waitSelectedAction, params string[] names)
        {
            var result = Invoker.DoJActionResult($"Are deselected '{names.Print()}'",
                                                 el => names.All(name => !waitSelectedAction(el, name)));

            Asserter.IsTrue(result);
        }
 public static void AssertExpectations()
 {
     foreach (var endpointName in EndpointNames.All)
     {
         Asserter.IsTrue(EventReceivedFrom.Contains(endpointName), $"{EndpointNames.EndpointName} expected a event to be Received From {endpointName}");
     }
 }
Ejemplo n.º 5
0
        public void WaitDeselected(Func <string, bool> waitSelectedAction, params string[] names)
        {
            bool result = Invoker.DoJActionResult($"Are deselected '{names.Print()}'",
                                                  () => names.All(name => !waitSelectedAction.Invoke(name)));

            Asserter.IsTrue(result);
        }
 public void IsTrue_ExpressionIsNull_ShouldThrowArgumentNullException()
 {
     Assert.ThrowsException <ArgumentNullException>(
         () =>
     {
         Asserter.IsTrue(null);
     });
 }
 public void IsTrueNullable_ExpressionIsNull_ShouldThrowArgumentNullException()
 {
     Assert.ThrowsException <ArgumentNullException>(
         () =>
     {
         Asserter.IsTrue(default(Expression <Func <bool?> >));
     });
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Returns the WebOperation URL associated with the given type, or null if no URL is found.
 /// </summary>
 /// <param name="type">The type for which to return a WebOperation URL.</param>
 /// <returns>The URL of the operation.</returns>
 private string GetURLFromType(Type type)
 {
     if (!_urlsByType.ContainsKey(type.FullName))
     {
         Asserter.IsTrue(false, "WebOperationURLs.GetURLFromType:WebOperations.txt contains no URL mapping for given Type (" + type.Name + ")");
     }
     return(_urlsByType[type.FullName]);
 }
Ejemplo n.º 9
0
    public Task MutateIncoming(MutateIncomingTransportMessageContext context)
    {
        var messageString = Encoding.Default.GetString(context.Body);

        Asserter.IsTrue(!messageString.Contains("Secret"), "Message property was not encrypted");

        return(Task.FromResult(0));
    }
Ejemplo n.º 10
0
            /**
             * Check that current page url/title contains expected url/title-matcher
             */

            public void Contains()
            {
                var url = IsNullOrEmpty(_template)
                    ? _equals
                    : _template;

                Logger.Info($"Page {_what} contains to '{url}'");
                Asserter.IsTrue(_timer().Wait(() => _actual().Contains(url)));
            }
Ejemplo n.º 11
0
            /**
             * Check that current page url/title equals to expected url/title
             */

            public void Equal()
            {
                if (IsNullOrEmpty(_equals))
                {
                    return;
                }
                Logger.Info($"Page {_what} equals to '{_equals}'");
                Asserter.IsTrue(_timer().Wait(() => _actual().Equals(_equals)));
            }
Ejemplo n.º 12
0
            /**
             * Check that current page url/title matches to expected url/title-matcher
             */

            public void Match()
            {
                if (IsNullOrEmpty(_template))
                {
                    return;
                }
                Logger.Info($"Page {_what} matches to '{_template}'");
                Asserter.IsTrue(_timer().Wait(() => _actual().Matches(_template)));
            }
Ejemplo n.º 13
0
 /**
  * Check that current page url/title contains expected url/title-matcher
  */
 public void Contains()
 {
     if (_template == null || _template.Equals(""))
     {
         return;
     }
     Logger.Info($"Page {_what} contains to '{_template}'");
     Asserter.IsTrue(_timer().Wait(() => _actual().Contains(_template)));
 }
Ejemplo n.º 14
0
 /**
  * Check that current page url/title equals to expected url/title
  */
 public void Equal()
 {
     if (_equals == null || _equals.Equals(""))
     {
         return;
     }
     Logger.Info($"Page {_what} equals to '{_equals}'");
     Asserter.IsTrue(_timer().Wait(() => _actual().Equals(_equals)));
 }
        public void IsTrueNullable_ConditionIsNullBooleanMethodResult_ShouldThrowAssertFailedException()
        {
            var o = new TestObject();

            Assert.ThrowsException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => o.NullableBooleanMethodTest(null));
            });
        }
 public Task Handle(SendMessage message, IMessageHandlerContext context)
 {
     Verifier.SendReceivedFromSites.Add(message.SentFrom);
     Asserter.IsTrue(message.PropertyDataBus != null, "Incorrect property value");
     return(context.Reply(new ResponseMessage
     {
         PropertyDataBus = new byte[100],
         Sender = EndpointNames.EndpointName
     }));
 }
 public void Handle(FirstMessage message)
 {
     Verifier.FirstMessageReceivedFrom.Add(message.Sender);
     Asserter.IsTrue("Secret" == message.EncryptedProperty, "Incorrect EncryptedProperty value");
     Bus.Reply(new SecondMessage
     {
         Sender            = EndpointNames.EndpointName,
         EncryptedProperty = "Secret"
     });
 }
 public void Handle(SendMessage message)
 {
     Verifier.SendReceivedFromSites.Add(message.SentFrom);
     Asserter.IsTrue(message.PropertyDataBus != null, "Incorrect property value");
     Bus.Reply(new ResponseMessage
     {
         PropertyDataBus = new byte[100],
         Sender          = EndpointNames.EndpointName
     });
 }
        public void IsTrue_ConditionIsFalseBooleanMethodResult_ShouldThrowAssertFailedException()
        {
            var o = new TestObject();

            Assert.ThrowsException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => o.BooleanMethodTest(false));
            });
        }
        public void IsTrue_ConditionIsTrueBooleanMethodResult_ShouldNotThrowAssertFailedException()
        {
            var o = new TestObject();

            ExceptionAsserter.DoesNotThrowException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => o.BooleanMethodTest(true));
            });
        }
Ejemplo n.º 21
0
        public void AssertOk(Asserter asserter)
        {
            asserter.IsTrue(IsMatched && (Timeout == TimeSpan.Zero || MatchedAt < Timeout), "Expected message was not received in time:\\r\\n " + ToString());

            if (IsMatched && failOnMultipleMatches)
            {
                asserter.IsTrue(NumberOfMatches == 1, NumberOfMatches + " matching messages were found, but only 1 was expected:\r\n " + ToString());
            }

            foreach (var matcher in happensBefore)
            {
                asserter.IsTrue(MatchedAt < matcher.MatchedAt, String.Format("The partial ordering of the message occurences were not as expected. Expected: {0} < {1}", ToString(), matcher.ToString()));
            }

            foreach (var matcher in happensAfter)
            {
                asserter.IsTrue(matcher.MatchedAt < MatchedAt, String.Format("The partial ordering of the message occurences were not as expected. Expected: {0} < {1}", matcher.ToString(), ToString()));
            }
        }
Ejemplo n.º 22
0
    public Task Handle(FirstMessage message, IMessageHandlerContext context)
    {
        Verifier.FirstMessageReceivedFrom.Add(message.Sender);
        Asserter.IsTrue("Secret" == message.EncryptedProperty, "Incorrect EncryptedProperty value");

        return(context.Reply(new SecondMessage
        {
            Sender = EndpointNames.EndpointName,
            EncryptedProperty = "Secret"
        }));
    }
        public void IsTrue_ConditionIsFalseBooleanProperty_ShouldThrowAssertFailedException()
        {
            var o = new TestObject {
                BooleanPropertyTest = false
            };

            Assert.ThrowsException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => o.BooleanPropertyTest);
            });
        }
        public void IsTrue_ConditionIsTrueBooleanProperty_ShouldNotThrowAssertFailedException()
        {
            var o = new TestObject {
                BooleanPropertyTest = true
            };

            ExceptionAsserter.DoesNotThrowException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => o.BooleanPropertyTest);
            });
        }
        public void IsTrue_ConditionIsSimpleAndBinaryExpressionThatReturnsTrue_ShouldNotThrowAssertFailedException()
        {
            var o = new TestObject {
                BooleanPropertyTest = true
            };

            ExceptionAsserter.DoesNotThrowException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => o.BooleanPropertyTest && o.BooleanMethodTest(true));
            });
        }
        public void IsTrueNullable_ConditionIsNullBooleanProperty_ShouldThrowAssertFailedException()
        {
            var o = new TestObject {
                NullableBooleanPropertyTest = null
            };

            Assert.ThrowsException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => o.NullableBooleanPropertyTest);
            });
        }
        public void AssertOk(Asserter asserter)
        {
            asserter.IsTrue(IsMatched && (Timeout == TimeSpan.Zero || MatchedAt < Timeout),
                            String.Format("Expected consumer confirmation was not received in time (MatchTime: {0}, Timeout: {1}) :\r\n{2}", MatchedAt, Timeout, ToString()));

            if (IsMatched)
            {
                asserter.IsTrue(Match.Succeeded, String.Format("Consumer has failed\r\n{0}\r\n\r\nThe error was:\r\n{1}", ToString(), Match.ErrorMessage));

                foreach (var matcher in happensBefore)
                {
                    asserter.IsTrue(MatchedAt < matcher.MatchedAt,
                                    String.Format("The partial ordering of the message occurences were not as expected. Expected: {0} < {1}", ToString(), matcher.ToString()));
                }

                foreach (var matcher in happensAfter)
                {
                    asserter.IsTrue(matcher.MatchedAt < MatchedAt,
                                    String.Format("The partial ordering of the message occurences were not as expected. Expected: {0} < {1}", matcher.ToString(), ToString()));
                }
            }
        }
        IsTrue_ConditionIsComplexAndOrBinaryExpressionThatReturnsFalseForAllParts_ShouldThrowAssertFailedException()
        {
            var o = new TestObject {
                BooleanPropertyTest = true
            };
            var p = new TestObject {
                BooleanPropertyTest = true
            };

            Assert.ThrowsException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => (o.BooleanPropertyTest && o.BooleanMethodTest(false)) || !p.BooleanPropertyTest);
            });
        }
        IsTrue_ConditionIsComplexAndOrBinaryExpressionThatReturnsTrueForLeftPart_ShouldNotThrowAssertFailedException()
        {
            var o = new TestObject {
                BooleanPropertyTest = true
            };
            var p = new TestObject {
                BooleanPropertyTest = false
            };

            ExceptionAsserter.DoesNotThrowException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => (o.BooleanPropertyTest && o.BooleanMethodTest(true)) || !p.BooleanPropertyTest);
            });
        }
Ejemplo n.º 30
0
        public void CheckOpened()
        {
            if (IsNullOrEmpty(UrlTemplate) && new [] { CheckPageTypes.None, CheckPageTypes.Equal }.Contains(CheckUrlType))
            {
                CheckUrl().Equal();
            }
            else
            {
                switch (CheckUrlType)
                {
                case CheckPageTypes.None:
                    Asserter.IsTrue(GetUrl().Contains(UrlTemplate) ||
                                    GetUrl().Matches(UrlTemplate));
                    break;

                case CheckPageTypes.Equal:
                    CheckUrl().Equal();
                    break;

                case CheckPageTypes.Match:
                    CheckUrl().Match();
                    break;

                case CheckPageTypes.Contains:
                    CheckUrl().Contains();
                    break;
                }
            }
            switch (CheckTitleType)
            {
            case CheckPageTypes.None:
                CheckTitle().Equal();
                break;

            case CheckPageTypes.Equal:
                CheckTitle().Equal();
                break;

            case CheckPageTypes.Match:
                CheckTitle().Match();
                break;

            case CheckPageTypes.Contains:
                CheckTitle().Contains();
                break;
            }
        }