예제 #1
0
        public override Fen Translate(string from)
        {
            if (!BypassValidation)
            {
                var fenValidator = new FENValidator();
                fenValidator.Validate(from);
            }

            return(GetFenObject(from));
        }
예제 #2
0
        private void AssertExceptionValueSet(FENError error)
        {
            _fenRuleMock = new Mock <IFENRule>();
            var mockedMethod = _fenRuleMock
                               .Setup(x => x.Validate(It.IsAny <string>()))
                               .Returns(error);

            _fenValidator = new FENValidator(_fenRuleMock.Object);
            try
            {
                _fenValidator.Validate(BoardConstants.FenStartingPosition);
            }
            catch (System.Exception exc)
            {
                var fenException = (FENException)exc;
                Assert.AreEqual(error, fenException.FENError, $"Expected fenException Error to have been {error}");
                throw;
            }
        }
예제 #3
0
 public void FENValidatorTest_ShouldThrowExceptionWhenInvalidFenStringDetected(FENError testCase)
 {
     _fenValidator = new FENValidator(_fenRuleMock.Object);
     Assert.Throws(typeof(FENException), () => AssertExceptionValueSet(testCase));
 }