コード例 #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);
        });
    }
コード例 #2
0
    public Task Handle(SecondMessage message, IMessageHandlerContext context)
    {
        Verifier.SecondMessageReceivedFrom.Add(message.Sender);
        Asserter.IsTrue("Secret" == message.EncryptedProperty, "Incorrect EncryptedProperty value");

        return(Task.FromResult(0));
    }
コード例 #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);
        }
コード例 #4
0
 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}");
     }
 }
コード例 #5
0
ファイル: ElementsActions.cs プロジェクト: jalona/jdi
        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);
        }
コード例 #6
0
 public void IsTrue_ExpressionIsNull_ShouldThrowArgumentNullException()
 {
     Assert.ThrowsException <ArgumentNullException>(
         () =>
     {
         Asserter.IsTrue(null);
     });
 }
コード例 #7
0
 public void IsTrueNullable_ExpressionIsNull_ShouldThrowArgumentNullException()
 {
     Assert.ThrowsException <ArgumentNullException>(
         () =>
     {
         Asserter.IsTrue(default(Expression <Func <bool?> >));
     });
 }
コード例 #8
0
ファイル: WebOperationURLs.cs プロジェクト: HackPotter/MetaB5
 /// <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]);
 }
コード例 #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));
    }
コード例 #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)));
            }
コード例 #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)));
            }
コード例 #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)));
            }
コード例 #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)));
 }
コード例 #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)));
 }
コード例 #15
0
        public void IsTrueNullable_ConditionIsNullBooleanMethodResult_ShouldThrowAssertFailedException()
        {
            var o = new TestObject();

            Assert.ThrowsException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => o.NullableBooleanMethodTest(null));
            });
        }
コード例 #16
0
 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
     }));
 }
コード例 #17
0
 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"
     });
 }
コード例 #18
0
 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
     });
 }
コード例 #19
0
        public void IsTrue_ConditionIsFalseBooleanMethodResult_ShouldThrowAssertFailedException()
        {
            var o = new TestObject();

            Assert.ThrowsException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => o.BooleanMethodTest(false));
            });
        }
コード例 #20
0
        public void IsTrue_ConditionIsTrueBooleanMethodResult_ShouldNotThrowAssertFailedException()
        {
            var o = new TestObject();

            ExceptionAsserter.DoesNotThrowException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => o.BooleanMethodTest(true));
            });
        }
コード例 #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()));
            }
        }
コード例 #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"
        }));
    }
コード例 #23
0
        public void IsTrue_ConditionIsFalseBooleanProperty_ShouldThrowAssertFailedException()
        {
            var o = new TestObject {
                BooleanPropertyTest = false
            };

            Assert.ThrowsException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => o.BooleanPropertyTest);
            });
        }
コード例 #24
0
        public void IsTrue_ConditionIsTrueBooleanProperty_ShouldNotThrowAssertFailedException()
        {
            var o = new TestObject {
                BooleanPropertyTest = true
            };

            ExceptionAsserter.DoesNotThrowException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => o.BooleanPropertyTest);
            });
        }
コード例 #25
0
        public void IsTrue_ConditionIsSimpleAndBinaryExpressionThatReturnsTrue_ShouldNotThrowAssertFailedException()
        {
            var o = new TestObject {
                BooleanPropertyTest = true
            };

            ExceptionAsserter.DoesNotThrowException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => o.BooleanPropertyTest && o.BooleanMethodTest(true));
            });
        }
コード例 #26
0
        public void IsTrueNullable_ConditionIsNullBooleanProperty_ShouldThrowAssertFailedException()
        {
            var o = new TestObject {
                NullableBooleanPropertyTest = null
            };

            Assert.ThrowsException <AssertFailedException>(
                () =>
            {
                Asserter.IsTrue(() => o.NullableBooleanPropertyTest);
            });
        }
コード例 #27
0
        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()));
                }
            }
        }
コード例 #28
0
        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);
            });
        }
コード例 #29
0
        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);
            });
        }
コード例 #30
0
ファイル: WebPage.cs プロジェクト: zgorcsos/JDI
        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;
            }
        }