public void GivenATextTesterWithAMockLogAsserterThatUponAnAssertionWillThrowAnExceptionWhenTheTextIsNotEqual()
        {
            var mockLogAsserter = MyMockRepository.Create <ILogAsserter>();

            mockLogAsserter
            .Setup(m => m.IsTrue(It.IsAny <string>(), It.Is <bool>(x => !x)))
            .Throws(new System.Exception(NotEqualExceptionMessage));

            this.textTester = new TextTester(this.Logger, mockLogAsserter.Object);
        }
        public void ThenTheTwoTextSamplesAreTreatedAsDifferent()
        {
            LogAssert.IsTrue("Text samples are different", !this.isEqual);

            this.ExpectedException.MessageShouldContainText = NotEqualExceptionMessage;
            Try(() => this.textTester.AssertActualTextEqualsExpectedText());
            MyMockRepository.VerifyAll();

            AssertExpectedException();
        }
        public void GivenTheClientContextUsesTheBlindRandomScalarFromTheTestVector()
        {
            HashFunctionFactory hfFactory = new();

            _mockPogFactory = MyMockRepository.Create <IPrimeOrderGroupFactory>();
            _cipherSuite    = new CipherSuite(_cipherSuiteName, _mockPogFactory.Object, hfFactory);

            SetupFullyFunctionalMockPrimeOrderGroupFactoryToUseTestVectorBlindRandomScalar();

            _clientContext = new(_cipherSuite);
        }
示例#4
0
        public void BeforeScenario()
        {
            Logger.Log("---------------------------------------------------------------------------");
            Logger.Log(_scenarioContext.ScenarioInfo.Title);
            Logger.Log("---------------------------------------------------------------------------");

            // We have to mock out the LogAssert.IsTrue() because
            // NUnit tells the test provider to fail the test on an assertion failure - regardless of whether we catch its AssertionException.
            var mockLogAssert = MyMockRepository.Create <ILogAsserter>();

            mockLogAssert
            .Setup(m => m.IsTrue(It.IsAny <string>(), It.Is <bool>(p => !p)))
            .Throws(new Exception(NotEqualExceptionMessage));

            this.xmlTester = new XmlTester(mockLogAssert.Object);
        }
        private void SetupFullyFunctionalMockPrimeOrderGroupFactoryToUseTestVectorBlindRandomScalar()
        {
            _mockPog = MyMockRepository.Create <IPrimeOrderGroup>();
            _mockPog.Setup(m => m.GenerateRandomScalar()).Returns(_testVectorBlindRandomScalar);
            _mockPog.Setup(m => m.InvertScalar(It.IsAny <byte[]>())).Returns <byte[]>((bytes) => _pog.InvertScalar(bytes));
            _mockPog.Setup(m => m.GenerateRandomGroupElement()).Returns(() => _pog.GenerateRandomGroupElement());
            _mockPog.Setup(m => m.PerformScalarMultiplication(It.IsAny <byte[]>(), It.IsAny <byte[]>())).Returns <byte[], byte[]>((b1, b2) => _pog.PerformScalarMultiplication(b1, b2));
            _mockPog.Setup(m => m.HashToGroup(It.IsAny <byte[]>())).Returns <byte[]>((bytes) => _pog.HashToGroup(bytes));
            _mockPog.Setup(m => m.IsValidPoint(It.IsAny <byte[]>())).Returns <byte[]>((bytes) => _pog.IsValidPoint(bytes));
            _mockPog.SetupGet(p => p.GroupElementBytesLength).Returns(() => _pog.GroupElementBytesLength);
            _mockPog.SetupGet(p => p.HashBytesLength).Returns(() => _pog.HashBytesLength);
            _mockPog.SetupGet(p => p.ScalarBytesLength).Returns(() => _pog.ScalarBytesLength);

            _mockPogFactory
            .Setup(m => m.Create(It.IsAny <CipherSuiteName>(), It.IsAny <ICipherSuite>()))
            .Returns(_mockPog.Object);
        }
示例#6
0
 public void AfterScenario()
 {
     Logger.Log();
     Logger.Log("Verifying all mock expectations were met");
     MyMockRepository.VerifyAll();
 }