Exemplo n.º 1
0
        /// <summary>
        /// Tests the map.
        /// </summary>
        /// <param name="map">The map to execute.</param>
        /// <param name="xsltExtensionObjectOverrides">The overrides for the XSLT arguments - allowing you to mock external assembly methods.</param>
        /// <param name="validateInput">if set to <c>true</c> then the input flat file contents and converted XML is validated.</param>
        /// <param name="validateOutputXml">if set to <c>true</c> then the output XML is validated.</param>
        public void TestMap(TransformBase map, IEnumerable <XsltExtensionObjectDescriptor> xsltExtensionObjectOverrides, bool validateInput, bool validateOutputXml)
        {
            if (map == null)
            {
                throw new ArgumentNullException(nameof(map));
            }

            XNode inputXml = BizTalkXmlFlatFileAdapter.ConvertInputFlatFileContentsToInputXml(map, this.InputFlatFileContents);

            if (validateInput)
            {
                BizTalkXmlMapTestValidator.ValidateInputXml(map, inputXml, this.Logger);
            }

            Logger.Log("Executing the BizTalk map (flat file to XML) " + map.GetType().Name);
            string outputXml = BizTalkXmlMapExecutor.PerformTransform(map, xsltExtensionObjectOverrides, inputXml);

            LogAssert.IsTrue("XML output from the BizTalk map exists", !string.IsNullOrWhiteSpace(outputXml));
            Logger.Log();
            Logger.Log("BizTalk map (flat file to XML) execution completed");

            base.SetActualOutputXmlFromXmlString(outputXml);

            if (validateOutputXml)
            {
                BizTalkXmlMapTestValidator.ValidateOutputXml(map, this.ActualOutputXml, this.Logger);
            }
        }
Exemplo n.º 2
0
        public void WhenTheRequestIsSentToTheSOAP11Service()
        {
            Logger.Log("About to wait for a request (that will not come)");
            var waitedForRequest = this.nancySoapAdapter.TryWaitForRequest(
                TestCaseRoutes.MySoap11Service,
                TestCaseSoapActions.MySoap11ServiceTestAction,
                5,
                TimeSpan.FromSeconds(1));

            LogAssert.IsTrue("No request has been received", waitedForRequest == null);

            Logger.Log("About to send the SOAP request");
            var content         = new StringContent(this.request);
            var responseMsgTask = myHttpClient.PostAsync($"{NancyBaseUrl}/{TestCaseRoutes.MySoap11Service}", content).ConfigureAwait(true);

            Logger.Log("About to wait for a request");
            waitedForRequest = this.nancySoapAdapter.TryWaitForRequest(
                TestCaseRoutes.MySoap11Service,
                TestCaseSoapActions.MySoap11ServiceTestAction,
                5,
                TimeSpan.FromSeconds(1));
            LogAssert.IsTrue("Request was been received", waitedForRequest != null);

            var responseMsg = responseMsgTask.GetAwaiter().GetResult();

            this.actualResponse = responseMsg.Content.ReadAsStringAsync().ConfigureAwait(true).GetAwaiter().GetResult();
            Logger.Log($"Actual response was: {actualResponse}");
            responseMsg.EnsureSuccessStatusCode();
        }
        public void ThenTheTwoTextSamplesAreTreatedAsDifferent()
        {
            LogAssert.IsTrue("Text samples are different", !this.isEqual);

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

            AssertExpectedException();
        }
        public async Task ShouldDisposeAnIAsyncDisposableObject_WhenSafeDisposeAsyncIsCalled()
        {
            // ARRANGE
            var disposable = new MyAsyncDisposable(base.Logger);

            // ACT
            await MyAsyncDisposable.SafeDisposeAsync(disposable).ConfigureAwait(false);

            // ASSERT
            LogAssert.IsTrue("Is Disposed", disposable.IsDisposed);
        }
Exemplo n.º 5
0
        public void ShouldDisposeOfAnObject_WhenSafeDisposeIsCalled_AndTheObjectIsIDisposable()
        {
            // ARRANGE
            var disposable = new MyDisposable(base.Logger);

            // ACT
            MyDisposable.SafeDispose(disposable);

            // ASSERT
            LogAssert.IsTrue("Is Disposed", disposable.IsDisposed);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Tests the map.
        /// </summary>
        /// <param name="map">The map to execute.</param>
        /// <param name="xsltExtensionObjectOverrides">The overrides for the XSLT arguments - allowing you to mock external assembly methods.</param>
        /// <param name="validateInput">if set to <c>true</c> then the input flat file contents and converted XML is validated.</param>
        /// <param name="validateOutput">if set to <c>true</c> then the output is validated.</param>
        public void TestMap(TransformBase map, IEnumerable <XsltExtensionObjectDescriptor> xsltExtensionObjectOverrides, bool validateInput, bool validateOutput)
        {
            if (map == null)
            {
                throw new ArgumentNullException(nameof(map));
            }

            XNode inputXml = BizTalkXmlFlatFileAdapter.ConvertInputFlatFileContentsToInputXml(map, this.InputFlatFileContents);

            if (validateInput)
            {
                BizTalkXmlMapTestValidator.ValidateInputXml(map, inputXml, this.Logger);
            }

            Logger.Log("Executing the BizTalk map (flat file to flat file) " + map.GetType().Name);
            string outputXmlString = BizTalkXmlMapExecutor.PerformTransform(map, xsltExtensionObjectOverrides, inputXml);

            LogAssert.IsTrue("XML output from the BizTalk map exists", !string.IsNullOrWhiteSpace(outputXmlString));

            var actualOutputXml = XElement.Parse(outputXmlString);

            if (validateOutput)
            {
                BizTalkXmlMapTestValidator.ValidateOutputXml(map, actualOutputXml, this.Logger);
            }

            var schemaTree = BizTalkMapSchemaUtility.CreateSchemaTreeAndLoadSchema(map, map.TargetSchemas[0]);

            if (schemaTree.IsStandardXML)
            {
                throw new InvalidOperationException("The map does not have a schema for converting to a flat file.");
            }
            else
            {
                Logger.Log("Converting the XML output of the BizTalk map to a flat file");
                this.ActualOutputFlatFileContents = BizTalkXmlFlatFileAdapter.ConvertOutputXmlToOutputFlatFileContents(map, actualOutputXml, validateOutput);
            }

            Logger.Log();
            Logger.Log("BizTalk map (flat file to flat file) execution completed");
        }
        public async Task ShouldPerformLifecycleOfOverridableAsyncDisposeMethods()
        {
            // ARRANGE
            var disposable = new MyAsyncDisposable(base.Logger);

            AssertInitialState(disposable);

            // ACT
            await disposable.DisposeAsync().ConfigureAwait(false);

            // ASSERT
            // Assert lifecycle of Async Dispose methods were invoked
            LogAssert.IsTrue("IsDisposed", disposable.IsDisposed);
            LogAssert.AreEqual("OnDisposing Call Position", 1, disposable.OnDisposingCallPosition);
            LogAssert.AreEqual("DisposeManagedResourcesAsync Call Position", 2, disposable.DisposeManagedResourcesAsyncCallPosition);
            LogAssert.AreEqual("DisposeUnmanagedResourcesAsync Call Position", 3, disposable.DisposeUnmanagedResourcesAsyncCallPosition);
            LogAssert.AreEqual("SetResourcesToNull Call Position", 4, disposable.SetResourcesToNullCallPosition);
            LogAssert.AreEqual("OnDisposed Call Position", 5, disposable.OnDisposedCallPosition);

            // Assert the normal Dispose methods were NOT invoked
            LogAssert.AreEqual("DisposeManagedResources Call Position", 0, disposable.DisposeManagedResourcesCallPosition);
            LogAssert.AreEqual("DisposeUnmanagedResources Call Position", 0, disposable.DisposeUnmanagedResourcesCallPosition);
        }
        public void ShouldPerformLifecycleOfOverridableDisposeMethods()
        {
            // ARRANGE
            var disposable = new MyAsyncDisposable(base.Logger);

            AssertInitialState(disposable);

            // ACT
            disposable.Dispose();

            // ASSERT
            // Assert lifecycle of Dispose methods were invoked
            LogAssert.IsTrue("IsDisposed", disposable.IsDisposed);
            LogAssert.AreEqual("OnDisposing Call Position", 1, disposable.OnDisposingCallPosition);
            LogAssert.AreEqual("DisposeManagedResources Call Position", 2, disposable.DisposeManagedResourcesCallPosition);
            LogAssert.AreEqual("DisposeUnmanagedResources Call Position", 3, disposable.DisposeUnmanagedResourcesCallPosition);
            LogAssert.AreEqual("SetResourcesToNull Call Position", 4, disposable.SetResourcesToNullCallPosition);
            LogAssert.AreEqual("OnDisposed Call Position", 5, disposable.OnDisposedCallPosition);

            // Assert async methods were NOT invoked
            LogAssert.AreEqual("DisposeManagedResourcesAsync Call Position", 0, disposable.DisposeManagedResourcesAsyncCallPosition);
            LogAssert.AreEqual("DisposeUnmanagedResourcesAsync Call Position", 0, disposable.DisposeUnmanagedResourcesAsyncCallPosition);
        }
Exemplo n.º 9
0
        public void ShouldPerformLifecycleOfOverridableMethods()
        {
            // ARRANGE
            var disposable = new MyDisposable(base.Logger);

            LogAssert.IsFalse("IsDisposed", disposable.IsDisposed);
            LogAssert.AreEqual("OnDisposing Call Position", 0, disposable.OnDisposingCallPosition);
            LogAssert.AreEqual("DisposeManagedResources Call Position", 0, disposable.DisposeManagedResourcesCallPosition);
            LogAssert.AreEqual("DisposeUnmanagedResources Call Position", 0, disposable.DisposeUnmanagedResourcesCallPosition);
            LogAssert.AreEqual("SetResourcesToNull Call Position", 0, disposable.SetResourcesToNullCallPosition);
            LogAssert.AreEqual("OnDisposed Call Position", 0, disposable.OnDisposedCallPosition);

            // ACT
            disposable.Dispose();

            // ASSERT
            LogAssert.IsTrue("IsDisposed", disposable.IsDisposed);
            LogAssert.AreEqual("OnDisposing Call Position", 1, disposable.OnDisposingCallPosition);
            LogAssert.AreEqual("DisposeManagedResources Call Position", 2, disposable.DisposeManagedResourcesCallPosition);
            LogAssert.AreEqual("DisposeUnmanagedResources Call Position", 3, disposable.DisposeUnmanagedResourcesCallPosition);
            LogAssert.AreEqual("SetResourcesToNull Call Position", 4, disposable.SetResourcesToNullCallPosition);
            LogAssert.AreEqual("OnDisposed Call Position", 5, disposable.OnDisposedCallPosition);
        }
Exemplo n.º 10
0
 public void ThenTheTwoXmlSamplesAreTreatedAsDifferent()
 {
     LogAssert.IsTrue("Xml samples are different", !this.isEqual);
 }
Exemplo n.º 11
0
 public void ThenTheTwoXmlSamplesAreTreatedAsEqual()
 {
     LogAssert.IsTrue("Xml samples are equal", this.isEqual);
 }
Exemplo n.º 12
0
 public void ThenTheOutputByteArrayIsCorrect()
 => LogAssert.IsTrue("Output byte array is as expected", _expectedBytes.SequenceEqual(_actualBytes));
Exemplo n.º 13
0
 public void ThenTheContextStringIsAsExpected()
 => LogAssert.IsTrue("Context String is as expected", _expectedContextString.SequenceEqual(_actualContextString));
 public void ThenTheClientContextFinalisationOutputResultIsCorrect()
 => LogAssert.IsTrue("Client Context Finalisation output is correct", _testVectorOutput.SequenceEqual(_actualBytes));
 public void ThenTheServerContextEvaluationResultIsCorrect()
 => LogAssert.IsTrue("ServerContext Evaluation is correct", _testVectorEvaluationElement.SequenceEqual(_actualBytes));
 public void ThenTheClientContextBlindResultIsCorrect()
 => LogAssert.IsTrue("Blind Result is same as Blinded Element", _testVectorBlindedElement.SequenceEqual(_actualBytes));