public async Task OriginalShouldBeSameAsInput(string fileName, ContextDataEnum contextData, decimal autId)
        {
            string filepath = this.GetType().AssemblyDirectory() + "\\input\\" + fileName;

            string xml_result_ori        = null;
            string xml_result_actual     = null;
            XmlComparisonResult result   = null;
            XmlComparisonUtils  xmlUtils = new XmlComparisonUtils();

            using (SampleContext sampleContext = DbContextFactory <SampleContext> .Create(filepath, ConnectionBehaviour.Persistent, connectionName))
            {
                sampleContext.StartRecordingOriginalValues();

                //just load the author
                var autor = sampleContext.Authors.FirstOrDefault(aut => aut.Id == autId);
                autor.ShouldNotBe(null, $"author with id {autId} test {fileName}");

                xml_result_actual = await sampleContext.AsXmlAsync(contextData);

                xml_result_ori = await sampleContext.GetRecordedContext().AsXmlAsync(contextData);

                result = xmlUtils.CompareXml(xml_result_actual, xml_result_ori);
                result.AreEqual.ShouldBe(true, result.ToString());

                sampleContext.StopRecordingOriginalValues();
            }
        }
Esempio n. 2
0
        public override bool Matches(object actual)
        {
            if (actual == null)
            {
                throw new ArgumentNullException("actual");
            }

            var actualNode = GetXNode(actual);

            this.result = this.comparer.Compare(this.expectedNode, actualNode);
            return(ResolveState(this.expectedState, this.result.State));
        }
Esempio n. 3
0
        private static void AssertComparison(XmlComparisonResult comparison, XmlComparisonState expectedState, XmlComparisonType[] expectedTypes = null)
        {
            Assert.IsNotNull(comparison);
            Assert.AreEqual(expectedState, comparison.State);

            if (expectedTypes != null)
            {
                var actualItems = comparison.Differences.ToArray();

                Assert.AreEqual(expectedTypes.Length, actualItems.Length);

                for (var i = 0; i < expectedTypes.Length; i++)
                {
                    Assert.AreEqual(expectedTypes[i], actualItems[i].Difference.ComparisonType);
                }
            }
        }