コード例 #1
0
        public void SwapImportsTheDetailsFromTheOtherInstance()
        {
            //Arrange
            var keeper    = new StringKeeper("test");
            var keeper2   = new StringKeeper(keeper);
            var takenData = keeper.TakeAll(); //keeper is now finished

            //Act
            keeper.Swap(keeper2);

            //Assert
            var result = keeper.TakeAll(); //if swap did not change keeper, this will return string.Empty

            result.Should().Be(takenData);
        }
コード例 #2
0
        public void InstancesCanBeCopied()
        {
            //Arrange
            var keeper = new StringKeeper("test");

            //Act
            var keeper2 = new StringKeeper(keeper);

            //Assert
            keeper2.TakeAll().Should().Be(keeper.TakeAll());
        }
コード例 #3
0
        public void FinishedShouldBeTrueAfterTakeAll()
        {
            //Arrange
            var keeper = new StringKeeper("test");

            //Act
            keeper.TakeAll();

            //Assert
            keeper.Finished.Should().BeTrue();
        }
コード例 #4
0
        public void TakeAllReturnsFullString()
        {
            //Arrange
            var keeper = new StringKeeper("test");

            //Act
            var result = keeper.TakeAll();

            //Assert
            result.Should().Be("test");
        }
コード例 #5
0
        public void CopiedInstancesDoNotFollowTheOriginal()
        {
            //Arrange
            var keeper  = new StringKeeper("test");
            var keeper2 = new StringKeeper(keeper);

            //Act
            keeper.TakeAll();

            //Assert
            keeper2.Finished.Should().BeFalse();
        }
コード例 #6
0
        public void CopyingAFinishedInstanceShouldProduceAFinishedInstance()
        {
            //Arrange
            var keeper = new StringKeeper("test");

            keeper.TakeAll();

            //Act
            var keeper2 = new StringKeeper(keeper);

            //Assert
            keeper2.Finished.Should().BeTrue();
        }
コード例 #7
0
        public void CopiedInstancesShouldHaveTheSamePositionAsTheOriginal()
        {
            //Arrange
            var keeper = new StringKeeper("test");

            keeper.Take();

            //Act
            var keeper2 = new StringKeeper(keeper);

            //Assert
            keeper2.TakeAll().Should().Be(keeper.TakeAll());
        }
コード例 #8
0
        public void SkipWhitespaceWorksIfFinished()
        {
            //Arrange
            var keeper = new StringKeeper("test");

            keeper.TakeAll();

            //Act
            keeper.SkipWhiteSpace();

            //Assert
            keeper.Finished.Should().BeTrue(); //well, still true anyway
        }
コード例 #9
0
        public void TakeAllReturnsRemainingText()
        {
            //Arrange
            var keeper = new StringKeeper("test");

            keeper.Take();

            //Act
            var result = keeper.TakeAll();

            //Assert
            result.Should().Be("est");
        }
コード例 #10
0
        public void SwapCopiesTheCorrectPositionIntoAnotherInstance()
        {
            //Arrange
            var keeper  = new StringKeeper("test");
            var keeper2 = new StringKeeper(keeper);

            keeper.TakeAll();

            //Act
            keeper.Swap(keeper2);

            //Assert
            keeper2.Finished.Should().BeTrue();
        }
コード例 #11
0
 public ErrorToken(StringKeeper pos, string errorMessage)
 {
     Text         = pos.TakeAll();
     ErrorMessage = errorMessage;
 }