示例#1
0
 public void Before() 
 {
     var name = "foo";
     fooAsserter = name.Should();
     person = new Person();
     personAsserter = person.Should();
 }
        IsFalse_ConditionIsComplexAndOrBinaryExpressionThatReturnsTrueForAllParts_ShouldThrowAssertFailedException()
        {
            var o = new TestObject {
                BooleanPropertyTest = true
            };
            var p = new TestObject {
                BooleanPropertyTest = true
            };

            Assert.ThrowsException <AssertFailedException>(
                () =>
            {
                // (!(true && false) || true) == true
                Asserter.IsFalse(() => !(o.BooleanPropertyTest && o.BooleanMethodTest(false)) || p.BooleanPropertyTest);
            });
        }
示例#3
0
    /// <summary>
    /// Executes the LoginOperation asynchronously. The LoginOperationCallback will be invoked when the results are ready.
    /// </summary>
    /// <param name="loginOperationCallback">The callback to be invoked when the result of the LoginOperation is ready.</param>
    public void ExecuteAsync(LoginOperationCallback loginOperationCallback)
    {
        Asserter.NotNull(loginOperationCallback, "LoginOperation.ExecuteAsync:loginOperationCallback is null");
        Dictionary <string, string> fields = new Dictionary <string, string>();

        fields.Add(kUSERNAME_FIELD, _criteria.Username);
        fields.Add(kPASSWORD_FIELD, _criteria.Password);

        WebOperationCallback webOperationCallback = (ResultSet resultSet) =>
        {
            LoginOperationResult result = CreateResultFromResultSet(resultSet);
            loginOperationCallback(result);
        };

        WebOperation.ExecuteAsync(new WebOperationCriteria(WebOperationURLs.GetURL(GetType()), fields), webOperationCallback);
    }
        IsFalse_ConditionIsComplexAndOrBinaryExpressionThatReturnsTrueForLeftPartButFalseForRightPart_ShouldNotThrowAssertFailedException()
        {
            var o = new TestObject {
                BooleanPropertyTest = true
            };
            var p = new TestObject {
                BooleanPropertyTest = false
            };

            ExceptionAsserter.DoesNotThrowException <AssertFailedException>(
                () =>
            {
                // (!(true && true) || false ) == false
                Asserter.IsFalse(() => !(o.BooleanPropertyTest && o.BooleanMethodTest(true)) || p.BooleanPropertyTest);
            });
        }
        public void DoesNotContainShouldPassWhenTrue()
        {
            // arrange
            var assert   = new Asserter();
            var sequence = new List <object>()
            {
                new object(),
                new object(),
                new object(),
            };
            var element  = new object();
            var comparer = EqualityComparer <object> .Default;

            // act, assert
            assert.DoesNotContain(sequence, element, comparer);
        }
示例#6
0
        public void WillThrowArgumentNullExceptionIfDataSourceIsNull()
        {
            dynamic parameters = null;

            parameters = new ExpandoObject();

            parameters.tableObjectMappings = new List <TableObjectMapping>
            {
                new TableObjectMapping()
            };

            Asserter
            .AssertException <ArgumentNullException>(
                () => SystemUnderTest.BuildItems <object>(parameters, null))
            .AndVerifyHasParameter("dataSource");
        }
示例#7
0
        public NavigationControl(IKernel kernel)
            : this()
        {
            Asserter.AssertIsNotNull(kernel, "kernel");

            _kernel          = kernel;
            _shellController = _kernel.Get <IShellController>();
            _storageService  = _kernel.Get <IStorageService>();

            Asserter.AssertIsNotNull(_shellController, "_shell");
            Asserter.AssertIsNotNull(_storageService, "_storageService");

            _shellController.CurrentViewChanged += new EventHandler(shellController_CurrentViewChanged);

            serverListsGroupControl.SelectPublicServers();
        }
示例#8
0
        private GherkinFileScopeChange MergePartialResult(IGherkinFileScope previousScope, IGherkinFileScope partialResult, IScenarioBlock firstAffectedScenario, IScenarioBlock firstUnchangedScenario, int lineCountDelta)
        {
            Debug.Assert(partialResult.HeaderBlock == null, "Partial parse cannot re-parse header");
            Debug.Assert(partialResult.BackgroundBlock == null, "Partial parse cannot re-parse background");

            var changedBlocks = new List <IGherkinFileBlock>();
            var shiftedBlocks = new List <IGherkinFileBlock>();

            var fileScope = new GherkinFileScope(previousScope.GherkinDialect, partialResult.TextSnapshot)
            {
                HeaderBlock     = previousScope.HeaderBlock,
                BackgroundBlock = previousScope.BackgroundBlock
            };

            // inserting the non-affected scenarios
            fileScope.ScenarioBlocks.AddRange(previousScope.ScenarioBlocks.TakeUntilItemExclusive(firstAffectedScenario));

            //inserting partial result
            fileScope.ScenarioBlocks.AddRange(partialResult.ScenarioBlocks);
            changedBlocks.AddRange(partialResult.ScenarioBlocks);
            if (partialResult.InvalidFileEndingBlock != null)
            {
                Asserter.Assert(firstUnchangedScenario == null, "first affected scenario is not null");
                // the last scenario was changed, but it became invalid
                fileScope.InvalidFileEndingBlock = partialResult.InvalidFileEndingBlock;
                changedBlocks.Add(fileScope.InvalidFileEndingBlock);
            }

            if (firstUnchangedScenario != null)
            {
                Asserter.Assert(partialResult.InvalidFileEndingBlock == null, "there is an invalid file ending block");

                // inserting the non-effected scenarios at the end
                var shiftedScenarioBlocks = previousScope.ScenarioBlocks.SkipFromItemInclusive(firstUnchangedScenario)
                                            .Select(scenario => scenario.Shift(lineCountDelta)).ToArray();
                fileScope.ScenarioBlocks.AddRange(shiftedScenarioBlocks);
                shiftedBlocks.AddRange(shiftedScenarioBlocks);

                if (previousScope.InvalidFileEndingBlock != null)
                {
                    fileScope.InvalidFileEndingBlock = previousScope.InvalidFileEndingBlock.Shift(lineCountDelta);
                    shiftedBlocks.Add(fileScope.InvalidFileEndingBlock);
                }
            }

            return(new GherkinFileScopeChange(fileScope, false, false, changedBlocks, shiftedBlocks));
        }
示例#9
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;
            }
        }
示例#10
0
        public void WillConvertModelsToDataTable()
        {
            DatatableObjectMapping expected = null;
            IEnumerable <TestData> models   = null;

            models = CreateEnumerableOfItems(() => ObjectCreator.CreateNew <TestData>(new Dictionary <string, object>
            {
                { "Baz", null }
            }));

            expected = new DatatableObjectMapping(BuildDataTable(models), new Dictionary <string, string>
            {
                { "Id", "Id" },
                { "DateCreated", "DateCreated" },
                { "DateLastUpdated", "DateLastUpdated" },
                { "Foo", "Foo" },
                { "Bar", "Bar" },
                { "Baz", "Baz" }
            });

            var actual = SystemUnderTest.ConvertToDataTable(models);
            Expression <Action <KeyValuePair <string, string>, KeyValuePair <string, string> > > expression =
                (e, a) => CompareKeyValuePairs(e, a);

            Assert.AreEqual(expected.DataTable.Columns.Count, actual.DataTable.Columns.Count);

            for (var index = 0; index < expected.DataTable.Columns.Count; index++)
            {
                Asserter.AssertEquality(expected.DataTable.Columns[index].ColumnName, actual.DataTable.Columns[index].ColumnName);
                Assert.AreEqual(expected.DataTable.Columns[index].DataType, actual.DataTable.Columns[index].DataType);
            }

            for (var index = 0; index < expected.DataTable.Rows.Count; index++)
            {
                Assert.AreEqual(expected.DataTable.Rows[index].ItemArray.Length, actual.DataTable.Rows[index].ItemArray.Length);
                for (var field = 0; field < expected.DataTable.Rows[index].ItemArray.Length; field++)
                {
                    Assert.AreEqual(expected.DataTable.Rows[index].ItemArray[field], actual.DataTable.Rows[index].ItemArray[field]);
                }
            }

            Asserter.AssertEquality(expected.ColumnMappings, actual.ColumnMappings, additionalParameters:
                                    new Dictionary <string, object>
            {
                { Norml.Tests.Common.Constants.ParameterNames.ComparisonDelegate, expression }
            });
        }
        public void TestAllShapesArePutIntoGridSquares()
        {
            // Arrange
            var topLeftSingleSquare = SquareFillPoint(x: 0, y: 1);
            var topLeftRightHydrant = SquareFillPoint(x: 1, y: 0);
            var topLeftCross        = SquareFillPoint(x: 5, y: 5);
            var singleSquare        = Shape(
                topLeftCorner: topLeftSingleSquare,
                squareDefinitions: _singleSquareShapeSquareList1);
            var rightHydrant = Shape(
                topLeftCorner: topLeftRightHydrant,
                squareDefinitions: _rightHydrantSquareList);
            var cross = Shape(
                topLeftCorner: topLeftCross,
                squareDefinitions: _crossShapeSquareList);
            var squaresInShapes = new List <List <Square> >
            {
                _singleSquareShapeSquareList1,
                _rightHydrantSquareList,
                _crossShapeSquareList
            };
            var shapeList           = ShapeList(shape1: singleSquare, shape2: rightHydrant, shape3: cross);
            var shapeSet            = ShapeSet(shapes: shapeList);
            var shapeSetBuilder     = new TestShapeSetBuilder(squareViewFactory: new MockSquareFactory());
            var occupiedGridSquares = shapeSetBuilder.MakeGridSquares();

            // Act
            shapeSet.OccupyGridSquares(occupiedGridSquares: occupiedGridSquares);

            // Assert
            var start1 = 0;
            var end1   = shapeList.Count - 1;

            for (int count1 = start1; count1 <= end1; count1++)
            {
                var start2 = 0;
                var end2   = squaresInShapes[count1].Count - 1;
                for (int count2 = start2; count2 <= end2; count2++)
                {
                    var square = squaresInShapes[count1][count2];
                    var xCoord = square.TopLeftCornerX / TestConstants.SquareWidth;
                    var yCoord = square.TopLeftCornerY / TestConstants.SquareWidth;
                    Asserter.AreEqual(actual: occupiedGridSquares.IsSquareOccupied(x: xCoord, y: yCoord), expected: true);
                }
            }
            Asserter.AreEqual(actual: occupiedGridSquares.IsSquareOccupied(x: 0, y: 0), expected: false);
        }
示例#12
0
    /// <summary>
    /// Constructs a WebOperationURLs object.
    /// </summary>
    private WebOperationURLs()
    {
        TextAsset text = (TextAsset)Resources.Load(kURL_PATH, typeof(TextAsset));

        Asserter.NotNull(text, "WebOperationURLs.ctor:failed to load WebOperations.txt");

        StreamReader reader = new StreamReader(new MemoryStream(Encoding.ASCII.GetBytes(text.text)));

        while (!reader.EndOfStream)
        {
            string   line      = reader.ReadLine();
            string[] splitLine = line.Split(' ');

            Asserter.IsTrue(splitLine.Length == 2, "WebOperationURLs.ctor:unexpected input from WebOperations.txt");
            _urlsByType.Add(splitLine[0], splitLine[1]);
        }
    }
示例#13
0
        GetResults_ShowStoredStringChildStoredStringAndStoredStringsForEachChildren_ThreeItems
            ()
        {
            Query query = new Query(typeof(PalasoTestItem)).Show("StoredString");

            query.In("Child").Show("StoredString", "ChildStoredString");
            query.ForEach("ChildItemList").Show("StoredString", "ChildrenStoredString");

            IEnumerable <IDictionary <string, object> > results = query.GetResults(item);

            Dictionary <string, object>[] expectedResult = new Dictionary <string, object>[]
            {
                new Result(
                    new KV(
                        "StoredString",
                        "top"),
                    new KV(
                        "ChildStoredString",
                        null),
                    new KV(
                        "ChildrenStoredString",
                        "1")),
                new Result(
                    new KV(
                        "StoredString",
                        "top"),
                    new KV(
                        "ChildStoredString",
                        null),
                    new KV(
                        "ChildrenStoredString",
                        "2")),
                new Result(
                    new KV(
                        "StoredString",
                        "top"),
                    new KV(
                        "ChildStoredString",
                        null),
                    new KV(
                        "ChildrenStoredString",
                        "3"))
            };

            Asserter.Assert(new DictionaryContentAsserter <string, object>(expectedResult, results));
        }
示例#14
0
        public void GetResults_ShowStoredIntForEachChildren_ThreeItems()
        {
            Query allStoredIntsInChildren =
                new Query(typeof(PalasoTestItem)).ForEach("ChildItemList").Show("StoredInt");

            IEnumerable <IDictionary <string, object> > results =
                allStoredIntsInChildren.GetResults(item);

            Dictionary <string, object>[] expectedResult = new Dictionary <string, object>[]
            {
                new Result(new KV("StoredInt", 1)),
                new Result(new KV("StoredInt", 2)),
                new Result(new KV("StoredInt", 3))
            };

            Asserter.Assert(new DictionaryContentAsserter <string, object>(expectedResult, results));
        }
示例#15
0
        public void ProductPurchaseSucceeds()
        {
            executor
            .Try(() => messagePublisher.Publish(new PurchaseProduct {
                ProductId = productId, CustomerId = customerId
            }))
            .Return()
            .When(purchaseProductConfirmation.WaitFor(TimeSpan.FromSeconds(5)));

            Assert.IsTrue(purchaseProductConfirmation.IsMatched);

            var asserter = new Asserter();

            purchaseProductConfirmation.AssertOk(asserter);
            Assert.IsFalse(asserter.IsOk);
            Console.WriteLine(asserter);
        }
示例#16
0
        public void TestTopLeftCornerIsCalculatedAsParentCornerAdjustedByRelativePosition()
        {
            // Arrange
            var parentTopLeftCorner = SquareFillPoint(
                x: 4 * TestConstants.SquareWidth,
                y: 4 * TestConstants.SquareWidth);
            var square = Square(positionRelativeToParentCorner: SquareFillPoint(x: -2, y: -3), sprite: MockSquareView());

            // Act
            square.MoveTopLeftCorner(newTopLeftCorner: parentTopLeftCorner);

            // Assert
            Asserter.AreEqual(actual: square.TopLeftCornerX,
                              expected: parentTopLeftCorner.X + (square.XRelativeToParentCorner * TestConstants.SquareWidth));
            Asserter.AreEqual(actual: square.TopLeftCornerY,
                              expected: parentTopLeftCorner.Y + (square.YRelativeToParentCorner * TestConstants.SquareWidth));
        }
示例#17
0
        public void Unlock()
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("ProcessLock");
            }
            if (!_created)
            {
                throw new InvalidOperationException();
            }

            Asserter.Assert(_mutex != null, "_mutex != null", "_mutex cannot be null");

            _mutex.ReleaseMutex();
            _mutex   = null;
            _created = false;
        }
示例#18
0
        public void TestCentreOfSquareIsDefinedAsInsideSquare()
        {
            // Arrange
            var centreOfSquare = SquareFillPoint(
                x: TestConstants.SquareWidth / 2,
                y: TestConstants.SquareWidth / 2);
            var topLeftCorner = SquareFillPoint(x: 0, y: 0);
            var square        = Square();

            square.MoveTopLeftCorner(newTopLeftCorner: topLeftCorner);

            // Act
            var isInSquare = square.IsInSquare(point: centreOfSquare);

            // Assert
            Asserter.AreEqual(actual: isInSquare, expected: true);
        }
示例#19
0
        public void Feature_NuSpec_IsCompilant()
        {
            var asserter = new Asserter(Asserter.ResolvePackagesConfig("Jobbr.ArtefactStorage.RavenFS"), Asserter.ResolveRootFile("Jobbr.ArtefactStorage.RavenFS.nuspec"));

            asserter.Add(new PackageExistsInBothRule("Jobbr.ComponentModel.Registration"));
            asserter.Add(new PackageExistsInBothRule("Jobbr.ComponentModel.ArtefactStorage"));
            asserter.Add(new PackageExistsInBothRule("RavenDB.Client"));
            asserter.Add(new AllowNonBreakingChangesRule("RavenDB.Client*"));
            asserter.Add(new VersionIsIncludedInRange("Jobbr.ComponentModel.*"));
            asserter.Add(new OnlyAllowBugfixesRule("Jobbr.ComponentModel.*"));
            asserter.Add(new NoMajorChangesInNuSpec("Jobbr.*"));
            asserter.Add(new NoMajorChangesInNuSpec("RavenDB.Client*"));

            var result = asserter.Validate();

            Assert.IsTrue(result.IsSuccessful, result.Message);
        }
示例#20
0
        public void AssertElementValueEquals(string expectedValue)
        {
            string actionDescription = string.Format("Assert Element Value Equals '{0}'", expectedValue);
            string stepDecription    = TestLogger.CreateTestStep(actionDescription, name, pageName);
            string actualText        = string.Empty;

            try
            {
                actualText = FindWebElement().GetAttribute("value");
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            Asserter.AssertThat(actualText, Is.EqualTo(expectedValue), stepDecription, false);
        }
示例#21
0
        public void AssertElementTextIsPopulted()
        {
            string stepDecription = TestLogger.CreateTestStep("Assert Element Text Is Populated", name, pageName);
            string actualtext     = string.Empty;

            try
            {
                actualtext = FindWebElement().Text;
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            actualtext = actualtext.Replace(" ", string.Empty);
            Asserter.AssertThat(actualtext.Length > 0, Is.True, stepDecription, false);
        }
示例#22
0
        public void AssertElementTextDoesNotContain(string containsText)
        {
            string actionDescription = string.Format("Assert Element Text Does Not Contain '{0}'", containsText);
            string stepDecription    = TestLogger.CreateTestStep(actionDescription, name, pageName);
            string actualtext        = string.Empty;

            try
            {
                actualtext = FindWebElement().Text;
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            Asserter.AssertThat(actualtext, Does.Not.Contain(containsText), stepDecription, false);
        }
示例#23
0
        public Asserter <AggregateExecutionComparison.TimeComparison> AssertComparison(
            AggregateExecutionComparison.TimeComparison results,
            int expectedComparison
            )
        {
            Constraint ratioConstraint = expectedComparison switch {
                -1 => Is.Positive.And.LessThan(1),
                0 => Is.EqualTo(1),
                1 => Is.Positive.And.GreaterThan(1),
                _ => throw new ArgumentOutOfRangeException(nameof(expectedComparison))
            };

            return(Asserter.Against(results)
                   .And(it => it.First.CompareTo(it.Second), Is.EqualTo(expectedComparison))
                   .And(it => it.Difference.Sign(), Is.EqualTo(expectedComparison))
                   .And(it => it.Ratio, ratioConstraint));
        }
示例#24
0
        public void AssertElementAttributeContains(string attribute, string containsText)
        {
            string actionDescription = string.Format("Assert Element Attribute {0} Contains '{1}'", attribute, containsText);
            string stepDecription    = TestLogger.CreateTestStep(actionDescription, name, pageName);
            string elementAttribute  = string.Empty;

            try
            {
                elementAttribute = FindWebElement().GetAttribute(attribute);
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            Asserter.AssertThat(elementAttribute, Does.Contain(containsText), stepDecription, false);
        }
示例#25
0
        public void Feature_NuSpec_IsCompliant()
        {
            var asserter = new Asserter(Asserter.ResolvePackagesConfig("Jobbr.Server"), Asserter.ResolveRootFile("Jobbr.Server.nuspec"));

            asserter.Add(new PackageExistsInBothRule("Jobbr.ComponentModel.ArtefactStorage"));
            asserter.Add(new PackageExistsInBothRule("Jobbr.ComponentModel.Execution"));
            asserter.Add(new PackageExistsInBothRule("Jobbr.ComponentModel.JobStorage"));
            asserter.Add(new PackageExistsInBothRule("Jobbr.ComponentModel.Management"));
            asserter.Add(new PackageExistsInBothRule("Jobbr.ComponentModel.Registration"));

            asserter.Add(new VersionIsIncludedInRange("Jobbr.ComponentModel.*"));
            asserter.Add(new NoMajorChangesInNuSpec("Jobbr.*"));

            var result = asserter.Validate();

            Assert.IsTrue(result.IsSuccessful, result.Message);
        }
示例#26
0
        public void WillPopulateProperties()
        {
            var  expectedJoinType          = JoinType.None;
            Type expectedType              = null;
            var  expectedLeftKey           = String.Empty;
            var  expectedRightKey          = String.Empty;
            var  expectedJoinTable         = String.Empty;
            var  expectedJoinTableLeftKey  = String.Empty;
            var  expectedJoinTableRightKey = String.Empty;
            var  expectedJoinTableJoinType = JoinType.None;
            var  expectedParentProperty    = String.Empty;
            var  expectedChildProperty     = String.Empty;

            TestRunner
            .DoCustomSetup(() =>
            {
                expectedJoinType          = JoinType.Left;
                expectedType              = typeof(Object);
                expectedLeftKey           = DataGenerator.GenerateString();
                expectedRightKey          = DataGenerator.GenerateString();
                expectedJoinTable         = DataGenerator.GenerateString();
                expectedJoinTableLeftKey  = DataGenerator.GenerateString();
                expectedJoinTableRightKey = DataGenerator.GenerateString();
                expectedJoinTableJoinType = JoinType.Right;
                expectedParentProperty    = DataGenerator.GenerateString();
                expectedChildProperty     = DataGenerator.GenerateString();
            })
            .ExecuteTest(() =>
            {
                var join = new JoinAttribute(expectedJoinType, expectedType, expectedLeftKey,
                                             expectedRightKey, expectedJoinTable, expectedJoinTableLeftKey,
                                             expectedJoinTableRightKey, expectedJoinTableJoinType,
                                             expectedParentProperty, expectedChildProperty);

                Asserter.AssertEquality(expectedJoinType, join.JoinType);
                Asserter.AssertEquality(expectedType.ToString(), join.JoinedType.ToString());
                Asserter.AssertEquality(expectedLeftKey, expectedLeftKey);
                Asserter.AssertEquality(expectedRightKey, join.RightKey);
                Asserter.AssertEquality(expectedJoinTable, join.JoinTable);
                Asserter.AssertEquality(expectedJoinTableLeftKey, join.JoinTableLeftKey);
                Asserter.AssertEquality(expectedJoinTableRightKey, join.JoinTableRightKey);
                Asserter.AssertEquality(expectedJoinTableJoinType, join.JoinTableJoinType);
                Asserter.AssertEquality(expectedParentProperty, join.ParentProperty);
                Asserter.AssertEquality(expectedChildProperty, join.ChildProperty);
            });
        }
示例#27
0
        public void SaveToSlot()
        {
            var saveSlot = GetUniqueSlot();
            var nickname = nameof(SaveToSlot) + Guid.NewGuid();
            var data     = new TestSaveData(nickname);

            var startTime = DateTime.Today;

            for (int i = 0; i < 5; i++)
            {
                var now = startTime.AddDays(i);
                data.Counter = i;

                var saved  = saveSlot.Save(data, now);
                var latest = saveSlot.LatestFile();
                latest?.Load();

                // expectations
                Asserter.Against(saveSlot)
                .WithHeading($"Save Slot iteration #{i}")
                .And(Has.Property(nameof(saveSlot.SaveFileCount)).EqualTo(i + 1))
                .And(
                    Asserter.Against(latest)
                    .WithHeading($"Latest File #{i}")
                    .And(Is.Not.Null)
                    .Exists()
                    .Nicknamed(saveSlot.Nickname)
                    .TimeStamped(now)
                    .And(Has.Property(nameof(latest.Data)).Not.Null)
                    .And(it => it.Data?.Counter, Is.EqualTo(i))
                    )
                .And(
                    Asserter.Against(saved)
                    .WithHeading($"Returned file from {nameof(saveSlot)}.{nameof(saveSlot.Save)}")
                    .And(Is.Not.Null)
                    .Exists()
                    .Nicknamed(saveSlot.Nickname)
                    .TimeStamped(now)
                    .And(Has.Property(nameof(saved.Data)).Not.Null)
                    .And(it => it.Data?.Counter, Is.EqualTo(i))
                    .And(it => it.Data, Is.EqualTo(latest.Data))
                    )
                .Invoke();
            }
        }
示例#28
0
        public void GetResults_ShowEachStringsMergedWithEachKeyValueOfKeyValuePairsMergedWithString()
        {
            Query allStrings =
                new Query(typeof(TestMultiple)).ShowEach("Strings").Show("String").ForEach(
                    "KeyValuePairs").Show("Key").Show("Value");
            IEnumerable <IDictionary <string, object> > results = allStrings.GetResults(item);

            Dictionary <string, object>[] expectedResult = new Dictionary <string, object>[]
            {
                new Result(
                    new KV("Strings",
                           "string1"),
                    new KV("String",
                           "string"),
                    new KV("Key", "key1"),
                    new KV("Value",
                           "value1")),
                new Result(
                    new KV("Strings",
                           "string1"),
                    new KV("String",
                           "string"),
                    new KV("Key", "key2"),
                    new KV("Value",
                           "value2")),
                new Result(
                    new KV("Strings",
                           "string2"),
                    new KV("String",
                           "string"),
                    new KV("Key", "key1"),
                    new KV("Value",
                           "value1")),
                new Result(
                    new KV("Strings",
                           "string2"),
                    new KV("String",
                           "string"),
                    new KV("Key", "key2"),
                    new KV("Value",
                           "value2"))
            };

            Asserter.Assert(new DictionaryContentAsserter <string, object>(expectedResult, results));
        }
示例#29
0
        private GherkinFileScopeChange PartialParse(GherkinTextBufferChange change, IGherkinFileScope previousScope)
        {
            _visualStudioTracer.Trace("Start incremental parsing", ParserTraceCategory);
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            _partialParseCount++;

            var textSnapshot = change.ResultTextSnapshot;

            var firstAffectedScenario = GetFirstAffectedScenario(change, previousScope);

            Asserter.Assert(firstAffectedScenario != null, "first affected scenario is null");
            int parseStartPosition = textSnapshot.GetLineFromLineNumber(firstAffectedScenario.GetStartLine()).Start;

            string fileContent = textSnapshot.GetText(parseStartPosition, textSnapshot.Length - parseStartPosition);

            var gherkinListener = new GherkinTextBufferPartialParserListener(
                previousScope.GherkinDialect,
                textSnapshot, _projectScope,
                previousScope,
                change.EndLine, change.LineCountDelta);

            var scanner = new GherkinScanner(previousScope.GherkinDialect, fileContent, firstAffectedScenario.GetStartLine());

            IScenarioBlock firstUnchangedScenario = null;

            try
            {
                scanner.Scan(gherkinListener);
            }
            catch (PartialListeningDoneException partialListeningDoneException)
            {
                firstUnchangedScenario = partialListeningDoneException.FirstUnchangedScenario;
            }

            var partialResult = gherkinListener.GetResult();

            var result = MergePartialResult(previousScope, partialResult, firstAffectedScenario, firstUnchangedScenario, change.LineCountDelta);

            stopwatch.Stop();
            TraceFinishParse(stopwatch, "incremental", result);
            return(result);
        }
示例#30
0
        public void AssertElementTextMatches(string pattern)
        {
            string actionDescription = string.Format("Assert Element Text Matches Regex Pattern '{0}'", pattern);
            string stepDecription    = TestLogger.CreateTestStep(actionDescription, name, pageName);
            bool   matches           = false;

            try
            {
                Regex regex = new Regex(pattern);
                matches = regex.IsMatch(FindWebElement().Text);
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            Asserter.AssertThat(matches, Is.True, stepDecription, false);
        }
示例#31
0
        public void AssertElementTextContainsNumericCharacters()
        {
            string stepDecription = TestLogger.CreateTestStep("Assert Element Text Contains Numeric Characters", name, pageName);
            string actualtext     = string.Empty;

            try
            {
                actualtext = FindWebElement().Text;
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            bool containsNumericCharacters = actualtext.Any(char.IsDigit);

            Asserter.AssertThat(containsNumericCharacters, Is.True, stepDecription, false);
        }
示例#32
0
 protected UnitTest()
 {
     Assert = new Asserter();
 }