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();
            }
        }
        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();
            }
        }
 public static async Task<string> AsXmlAsync(
    this DbContext dbContext,
    ContextDataEnum contextData
   )
 {
     DbContextConverterOptions options = DbContextConverterOptions.DEFAULT.WithContextData(contextData);
     return await  dbContext.AsXmlAsync(options);
 }
        public static async Task <string> AsXmlAsync(
            this DbContext dbContext,
            ContextDataEnum contextData
            )
        {
            DbContextConverterOptions options = DbContextConverterOptions.DEFAULT.WithContextData(contextData);

            return(await dbContext.AsXmlAsync(options));
        }
        public async Task TestWithObjectWithParentAndChild(string testin, Int64 postId, ContextDataEnum contextData)
        {
            XmlFileContext<SampleContext> xmlFileCtx = new XmlFileContext<SampleContext>(this.GetType());

            using (SampleContext ctx = xmlFileCtx.InputContext(testin, "as-xml-tests"))
            {
                ctx.Posts.Find(postId);
                String xml_result_exepcted = GetOutFileContent(testin + contextData.ToString("G") + postId, "as-xml-tests");
                string xml_result_actual = await ctx.AsXmlAsync(contextData);

                var result = await xmlFileCtx.Compare(xml_result_actual, xml_result_exepcted);
                result.AreEqual.ShouldBe(true, result.ToString());
            }
        }
        public async Task TestLoadingChilds(string testin, Int64 autId, ContextDataEnum contextData)
        {
            XmlFileContext <SampleContext> xmlFileCtx = new XmlFileContext <SampleContext>(this.GetType());

            string testOut = testin + contextData.ToString("G") + autId;

            using (SampleContext ctx = xmlFileCtx.InputContext(testin, "as-xml-tests"))
            {
                ctx.Authors.Find(autId);

                String xml_result_exepcted = GetOutFileContent(testOut, "as-xml-tests");
                string xml_result_actual   = await ctx.AsXmlAsync(contextData);

                var result = await xmlFileCtx.Compare(xml_result_actual, xml_result_exepcted);

                result.AreEqual.ShouldBe(true, result.ToString());
            }
        }
        public async Task TestWithObjectWithParentAndChild(string testin, Int64 postId, ContextDataEnum contextData)
        {
            XmlFileContext <SampleContext> xmlFileCtx = new XmlFileContext <SampleContext>(this.GetType());

            using (SampleContext ctx = xmlFileCtx.InputContext(testin, "as-xml-tests"))
            {
                ctx.Posts.Find(postId);
                String xml_result_exepcted = GetOutFileContent(testin + contextData.ToString("G") + postId, "as-xml-tests");
                string xml_result_actual   = await ctx.AsXmlAsync(contextData);

                var result = await xmlFileCtx.Compare(xml_result_actual, xml_result_exepcted);

                result.AreEqual.ShouldBe(true, result.ToString());
            }
        }
 public DbContextConverterOptions WithContextData(ContextDataEnum contextData)
 {
     this.ContextData = contextData;
     return(this);
 }
        public async Task TestLoadingChilds(string testin, Int64 autId, ContextDataEnum contextData)
        {
            XmlFileContext<SampleContext> xmlFileCtx = new XmlFileContext<SampleContext>(this.GetType());

            string testOut = testin + contextData.ToString("G") + autId;

            using (SampleContext ctx = xmlFileCtx.InputContext(testin, "as-xml-tests"))
            {
                ctx.Authors.Find(autId);
               
                String xml_result_exepcted = GetOutFileContent(testOut,"as-xml-tests");
                string xml_result_actual = await ctx.AsXmlAsync(contextData);

                var result = await xmlFileCtx.Compare(xml_result_actual, xml_result_exepcted);
                result.AreEqual.ShouldBe(true, result.ToString());
            }
        }