public void TestConvertWithDifferentArraySources()
        {
            var collection = new TestConverterCollection <AValue, BValue>(new PathFormatterCollection(), configurator =>
            {
                configurator.If(a => a.Condition)
                .Target(b => b.BOuterArray.Each().BInnerArray.Each().FirstValue)
                .Set(a => a.AOuterArray.Current().AFirstAFirstInnerArray.Current().Value);
                configurator.If(a => !a.Condition)
                .Target(b => b.BOuterArray.Each().BInnerArray.Each().FirstValue)
                .Set(a => a.AOuterArray.Current().ASecondASecondInnerArray.Current().Value);
            });
            var converter = collection.GetConverter(MutatorsContext.Empty);
            var from      = new AValue
            {
                AOuterArray = new[]
                {
                    new AOuterValue
                    {
                        AFirstAFirstInnerArray = new[]
                        {
                            new AFirstInnerValue {
                                Value = "123"
                            }
                        },
                        ASecondASecondInnerArray = new[]
                        {
                            new ASecondInnerValue {
                                Value = "321"
                            }
                        },
                    }
                },
                Condition = true,
            };

            Following.Code(() => converter(from))
            .Should().Throw <InvalidOperationException>()
            .Which.Message.Should().MatchRegex(@"^Method T Current\[T\].* cannot be invoked$");

            return;

#pragma warning disable 162
            var expected = new BValue
            {
                BOuterArray = new[]
                {
                    new BOuterValue
                    {
                        BInnerArray = new[]
                        {
                            new BInnerValue {
                                FirstValue = "123"
                            },
                        },
                    },
                },
            };
            converter(from).Should().BeEquivalentTo(expected);
#pragma warning restore 162
        }
        public void TestGetOnlyIndexerNotSupported()
        {
            Expression <Func <Root, string> > path = x => x.IndexerGet["abc"];

            Following.Code(() => root.Traverse(path.Body, create: true))
            .Should().Throw <InvalidOperationException>();
        }
Example #3
0
 public void TestInvalidAssertions()
 {
     page.SimpleInput.ClearAndInputText("hello");
     Following.Code(() => page.SimpleInput.ExpectTo().Value.BeOneOf("1", "2", "3")).ShouldThrow <AssertionException>();
     Following.Code(() => page.SimpleInput.ExpectTo().Value.BeEmpty()).ShouldThrow <AssertionException>();
     Following.Code(() => page.SimpleInput.ExpectTo().Value.HaveLength(3)).ShouldThrow <AssertionException>();
     Following.Code(() => page.SimpleInput.ExpectTo().Value.Match("*hi*")).ShouldThrow <AssertionException>();
 }
Example #4
0
 public void Test_CustomExpression_ErrorMessage()
 {
     Following
     .Code(() => page.SimpleInput.ExpectTo().Satisfy(x => x.Value.Get() == "Blah", "ожидалось волшебство"))
     .ShouldThrow <AssertionException>().Which.Message.Should()
     .Be(To.Text(
             @"Input(##SimpleInput): ожидалось волшебство",
             @"Время ожидания: 2 секунды."));
 }
Example #5
0
 public void Test_Presence_ErrorMessage()
 {
     Following
     .Code(() => page.SimpleInput.ExpectTo().BeAbsent())
     .ShouldThrow <AssertionException>().Which.Message.Should()
     .Be(To.Text(
             @"Input(##SimpleInput): ожидалось отсутствие",
             @"Время ожидания: 2 секунды."));
 }
Example #6
0
 public void Test_Present_ErrorMessage()
 {
     Following
     .Code(() => page.ModalWithStatefullComponentWithShowPropsCase.Modal.ExpectTo().BePresent())
     .ShouldThrow <AssertionException>().Which.Message
     .Should().Be(To.Text(
                      @"TestModal(##ModalWithStatefullComponentWithShowPropsCase ##Modal): ожидалось присутствие",
                      @"Время ожидания: 5 секунд."
                      ));
 }
Example #7
0
 public void Test_Absense_ErrorMessage()
 {
     Following
     .Code(() => page.NotExistentInput.ExpectTo().BePresent())
     .ShouldThrow <AssertionException>().Which.Message.Should()
     .Be(To.Text(
             @"Input(##NotExistentInput): ожидалось присутствие",
             @"Время ожидания: 2 секунды."
             ));
 }
Example #8
0
 public void Test_Disabled_ErrorMessage()
 {
     Following
     .Code(() => page.SimpleInput.ExpectTo().HaveProperty(x => x.IsDisabled, "disabled").BeTrue())
     .ShouldThrow <AssertionException>().Which.Message.Should()
     .Be(To.Text(
             @"Input(##SimpleInput): поле disabled ожидалось истиным, но было:",
             "  'False'",
             @"Время ожидания: 2 секунды."));
 }
        public void TestSetOnlyIndexerNotSupported()
        {
            Expression <Func <Root, IndexerSet> > path = r => r.IndexerSet;
            var method = typeof(IndexerSet).GetProperty("Item").GetSetMethod();

            var path3 = Expression.Call(path.Body, method, Expression.Constant("zzz"), Expression.Constant("zzz"));

            Following.Code(() => root.Traverse(path3, create: true))
            .Should().Throw <NotSupportedException>()
            .Which.Message.Should().MatchRegex("^Method .* is not supported$");
        }
Example #10
0
 public void Test_PropertyAssertButAbsense_ErrorMessage()
 {
     Following
     .Code(() => page.NotExistentInput.ExpectTo().HaveProperty(x => x.Value, "value").EqualTo("bye"))
     .ShouldThrow <AssertionException>().Which.Message.Should()
     .Be(To.Text(
             @"Input(##NotExistentInput): поле value ожидалось равным:",
             @"  'bye', но не был найден контрол Input(##NotExistentInput)",
             @"Время ожидания: 2 секунды."
             ));
 }
Example #11
0
 public void Test_PropertyMatch_ErrorMessage()
 {
     page.SimpleInput.ClearAndInputText("hello");
     Following
     .Code(() => page.SimpleInput.ExpectTo().HaveProperty(x => x.Value, "value").MatchToRegex(new Regex(@"\d+")))
     .ShouldThrow <AssertionException>().Which.Message.Should()
     .Be(To.Text(
             @"Input(##SimpleInput): поле value ожидалось соотвествующим regex-у:",
             @"  '\d+', но было:",
             @"  'hello'",
             @"Время ожидания: 2 секунды."));
 }
Example #12
0
 public void Test_PropertyNotEqualViaNegationSpecifier_ErrorMessage()
 {
     page.SimpleInput.ClearAndInputText("hello");
     Following
     .Code(() => page.SimpleInput.ExpectTo().HaveProperty(x => x.Value, "value").Not().EqualTo("hello"))
     .ShouldThrow <AssertionException>().Which.Message.Should()
     .Be(To.Text(
             @"Input(##SimpleInput): поле value ожидалось не равным:",
             @"  'hello', но было:",
             @"  'hello'",
             @"Время ожидания: 2 секунды."));
 }
Example #13
0
 public void Test_PropertyEqual_ErrorMessage()
 {
     page.SimpleInput.ClearAndInputText("hello");
     Following
     .Code(() => page.SimpleInput.ExpectTo().HaveProperty(x => x.Value, "value").EqualTo("bye"))
     .Should().Throw <AssertionException>().Which.Message.Should()
     .Be(To.Text(
             @"Input(##SimpleInput): поле value ожидалось равным:",
             @"  'bye', но было:",
             @"  'hello'",
             @"Время ожидания: 2000ms."
             ));
 }
Example #14
0
 public void Test_Absent_ErrorMessage()
 {
     Following
     .Code(() =>
     {
         page.ModalWithStatefullComponentWithShowPropsCase.Open.Click();
         page.ModalWithStatefullComponentWithShowPropsCase.Modal.ExpectTo().BeAbsent();
     })
     .Should().Throw <AssertionException>().Which.Message
     .Should().Be(To.Text(
                      @"TestModal(##ModalWithStatefullComponentWithShowPropsCase ##Modal): ожидалось отсутствие",
                      @"Время ожидания: 5000ms."
                      ));
 }
Example #15
0
 public void Test_InputTextIntoControlThatAppearsAfterTimeout_ErrorMessage()
 {
     Following
     .Code(() =>
     {
         page.ShowInputAppearsAfterTimeout.Click();
         page.InputAppearsAfterTimeout.ClearAndInputText("hello");
         page.InputAppearsAfterTimeout.ExpectTo().Value.EqualTo("hello");
     })
     .ShouldThrow <AssertionException>().Which.Message
     .Should().Be(To.Text(
                      @"Input(##InputAppearsAfterTimeout): требовалось действие InputText(hello), но",
                      @"  не смогли долждаться присутсвия элемента: Input(##InputAppearsAfterTimeout)",
                      @"Время ожидания: одна секунда."
                      ));
 }
Example #16
0
 public void Test_CheckDisabledViaAnd_ErrorMessage()
 {
     Following
     .Code(
         () =>
     {
         page.SimpleInput.ClearAndInputText("hello");
         page.SimpleInput.ExpectTo()
         .BeDisabled().And
         .HaveProperty(x => x.Value, "Value").EqualTo("hello");
     })
     .ShouldThrow <AssertionException>().Which.Message
     .Should().Be(To.Text(
                      @"Input(##SimpleInput): поле disabled ожидалось истиным, но было:",
                      @"  'False'",
                      @"Время ожидания: 2 секунды."
                      ));
 }