public async Task ShouldCompareTwoContextWithSimpleContent()
        {
            using (SampleContext expectedContext = GetSimpleTestContext())
            {
                using (SampleContext appContext = new XmlFileContext <SampleContext>(this.GetType()).Empty())
                {
                    appContext.Authors.Add(new Author()
                    {
                        FirstName = "Cedric123"
                    });
                    appContext.SaveChanges();

                    //compare context
                    var comparisonResult = await appContext.CompareTo(expectedContext);

                    string s = await appContext.AsXmlAsync();

                    string s2 = await expectedContext.AsXmlAsync(ContextDataEnum.All);

                    comparisonResult.AreEqual.ShouldBe(false, comparisonResult.ToString());
                    comparisonResult.Differences.Count.ShouldBe(2);
                    comparisonResult.Differences[0].ToString()
                    .ShouldBe("Author.FirstName Should be [Cedric] but was [Cedric123] - object with AUT_ID : 1");
                }
            }
        }
예제 #2
0
        public async Task ShouldReturnFalseForContextWithEntryContainingDifferentValues()
        {
            XmlFileContext <SampleContext> xmlFileCtx         = new XmlFileContext <SampleContext>(this.GetType());
            XmlFileContext <SampleContext> xmlFileExpectedCtx = new XmlFileContext <SampleContext>(this.GetType());

            SampleContext ctx1 = xmlFileCtx.InputContext("test2");
            SampleContext ctx2 = xmlFileExpectedCtx.ExpectedContext("test2");

            var result = await ctx1.CompareTo(ctx2);

            result.AreEqual.ShouldBe(false);
            result.Differences.Count.ShouldBe(2);

            result.Differences[0].ObjectId.ShouldBe("2");
            result.Differences[0].ObjectName.ShouldBe("Post");
            result.Differences[0].PropertyName.ShouldBe("Subject");
            result.Differences[0].ActualPropertyContent.ShouldBe("First Text");
            result.Differences[0].ExpectedPropertyContent.ShouldBe("First Text Modified");
            result.Differences[0].ToString().ShouldBe("Post.Subject Should be [First Text Modified] but was [First Text] - object with Post_Id : 2");

            result.Differences[1].ObjectId.ShouldBe("2");
            result.Differences[1].ObjectName.ShouldBe("Post");
            result.Differences[1].PropertyName.ShouldBe("Body");
            result.Differences[1].ActualPropertyContent.ShouldBe("Some Text here");
            result.Differences[1].ExpectedPropertyContent.ShouldBe("Some Other Text here");
        }
예제 #3
0
        private SampleContext GetExpectedContext(string testname)
        {
            XmlFileContext <SampleContext> factory = new XmlFileContext <SampleContext>(this.GetType());

            SampleContext ctx = factory.ExpectedContext(testname, "persistent_tests_input", false);

            return(ctx);
        }
        public void ShouldReturnAllDbsSets()
        {
            using (SampleContext context = new XmlFileContext <SampleContext>(this.GetType()).Empty())
            {
                var result = context.DbSets();

                result.Count().ShouldBe(3);
            }
        }
        public void ShouldReturnAllDbsSets()
        {
            using (SampleContext context = new XmlFileContext<SampleContext>(this.GetType()).Empty())
            {
                var result = context.DbSets();

                result.Count().ShouldBe(3);
            }
        }
        public void ShouldReturnAllDbsSetForEntity()
        {
            using (SampleContext context = new XmlFileContext<SampleContext>(this.GetType()).Empty())
            {
                var result = context.Set("Author");

                result.ElementType.Name.ShouldBe("Author");
            }
        }
        public void ShouldReturnAllDbsSetForEntity()
        {
            using (SampleContext context = new XmlFileContext <SampleContext>(this.GetType()).Empty())
            {
                var result = context.Set("Author");

                result.ElementType.Name.ShouldBe("Author");
            }
        }
예제 #8
0
        public async Task ShouldReturnTrueForSameContextComparison()
        {
            XmlFileContext <SampleContext> xmlFileCtx = new XmlFileContext <SampleContext>(this.GetType());

            SampleContext ctx1 = xmlFileCtx.InputContext("test1");
            SampleContext ctx2 = xmlFileCtx.InputContext("test1");

            var result = await ctx1.CompareTo(ctx2);

            result.AreEqual.ShouldBe(true);
        }
        public void ShouldGetMappedTableAndEntityName()
        {
            using (SampleContext emptyContext1 = new XmlFileContext <SampleContext>(this.GetType()).Empty())
            {
                var TableName = emptyContext1.MappedTable("Author");
                TableName.ShouldBe("AUTHOR");

                var EntityName = emptyContext1.MappedEntity("AUTHOR");
                EntityName.ShouldBe("Author");
            }
        }
        public void ShouldGetMappedTableAndEntityName()
        {
            using (SampleContext emptyContext1 = new XmlFileContext<SampleContext>(this.GetType()).Empty())
            {
                var TableName = emptyContext1.MappedTable("Author");
                TableName.ShouldBe("AUTHOR");

                var EntityName = emptyContext1.MappedEntity("AUTHOR");
                EntityName.ShouldBe("Author");
            }
        }
        public async Task ShouldCompareEmptyContext()
        {
            using (SampleContext emptyContext1 = new XmlFileContext <SampleContext>(this.GetType()).Empty())
            {
                using (SampleContext emptyContext2 = new XmlFileContext <SampleContext>(this.GetType()).Empty())
                {
                    var comparisonResult = await emptyContext1.CompareTo(emptyContext2);

                    comparisonResult.AreEqual.ShouldBe(true, comparisonResult.ToString());
                }
            }
        }
        public async Task ShouldReturnTrueForSameContextComparison()
        {
            XmlFileContext<SampleContext> xmlFileCtx = new XmlFileContext<SampleContext>(this.GetType());

            SampleContext ctx1 = xmlFileCtx.InputContext("test1");
            SampleContext ctx2 = xmlFileCtx.InputContext("test1");

            var result = await ctx1.CompareTo(ctx2);

            result.AreEqual.ShouldBe(true);

        }
        public async Task ShouldCompareEmptyContext()
        {
            using (SampleContext emptyContext1 = new XmlFileContext<SampleContext>(this.GetType()).Empty())
            {
                using (SampleContext emptyContext2 = new XmlFileContext<SampleContext>(this.GetType()).Empty())
                {
                    var comparisonResult = await emptyContext1.CompareTo(emptyContext2);

                    comparisonResult.AreEqual.ShouldBe(true, comparisonResult.ToString());
                }
            }
        }
        public void ShouldGetAllMappings()
        {
            using (SampleContext emptyContext = new XmlFileContext <SampleContext>(this.GetType()).Empty())
            {
                var entityMappings = emptyContext.GetMappings();

                entityMappings.Count.ShouldBe(3);
                entityMappings.Where(t => t.Table == "AUTHOR").FirstOrDefault().ShouldNotBe(null);
                entityMappings.Where(t => t.Table == "COMMENT").FirstOrDefault().ShouldNotBe(null);
                entityMappings.Where(t => t.Table == "POST").FirstOrDefault().ShouldNotBe(null);
            }
        }
예제 #15
0
        public async Task ShouldReturnFalseForContextWithMissingEntryinExpected()
        {
            XmlFileContext <SampleContext> xmlFileCtx = new XmlFileContext <SampleContext>(this.GetType());

            XmlFileContext <SampleContext> xmlFileExpectedCtx = new XmlFileContext <SampleContext>(this.GetType());

            SampleContext ctx1 = xmlFileCtx.InputContext("test1");
            SampleContext ctx2 = xmlFileExpectedCtx.ExpectedContext("test1");

            var result = await ctx1.CompareTo(ctx2);

            result.AreEqual.ShouldBe(false);
        }
        public async Task ShouldReturnFalseForContextWithMissingEntryinExpected()
        {
            XmlFileContext<SampleContext> xmlFileCtx = new XmlFileContext<SampleContext>(this.GetType());

            XmlFileContext<SampleContext> xmlFileExpectedCtx = new XmlFileContext<SampleContext>(this.GetType());

            SampleContext ctx1 = xmlFileCtx.InputContext("test1");
            SampleContext ctx2 = xmlFileExpectedCtx.ExpectedContext("test1");

            var result = await ctx1.CompareTo(ctx2);

            result.AreEqual.ShouldBe(false);
        }
        public async Task TestWithXmlFIles()
        {
            //load a context
            XmlFileContext<SampleContext> xmlFileCtx = new XmlFileContext<SampleContext>(this.GetType());

            using (SampleContext ctx = xmlFileCtx.InputContext("test1"))
            {
                string fromFile = await ctx.AsXmlAsync(DbContextConverterOptions.DEFAULT.WithAll());
                dynamic obj = fromFile.XmlToDynamic();

                ((string)obj.AUTHOR[0].AUT_FIRSTNAME).ShouldBe("John");
            }
        }
        public async Task TestWithXmlFIles()
        {
            //load a context
            XmlFileContext <SampleContext> xmlFileCtx = new XmlFileContext <SampleContext>(this.GetType());

            using (SampleContext ctx = xmlFileCtx.InputContext("test1"))
            {
                string fromFile = await ctx.AsXmlAsync(DbContextConverterOptions.DEFAULT.WithAll());

                dynamic obj = fromFile.XmlToDynamic();

                ((string)obj.AUTHOR[0].AUT_FIRSTNAME).ShouldBe("John");
            }
        }
        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 void ShouldGetMappedColumnAndPropertyName()
        {
            using (SampleContext emptyContext1 = new XmlFileContext <SampleContext>(this.GetType()).Empty())
            {
                var columnName = emptyContext1.MappedColumnName("Author", "Id");
                columnName.ShouldBe("AUT_ID");

                columnName = emptyContext1.MappedColumnName("Author", "FirstName");
                columnName.ShouldBe("AUT_FIRSTNAME");

                var propertyName = emptyContext1.MappedPropertyName("AUTHOR", "AUT_FIRSTNAME");
                propertyName.ShouldBe("FirstName");
            }
        }
        private SampleContext GetSimpleTestContext()
        {
            SampleContext simpleContext = new XmlFileContext <SampleContext>(this.GetType()).Empty();

            Author cedric = new Author()
            {
                FirstName = "Cedric", LastName = "Dumont"
            };

            simpleContext.Authors.Add(cedric);

            simpleContext.SaveChanges();

            return(simpleContext);
        }
예제 #22
0
        public async Task ShouldReturnFalseForContextWithSameCollectionCountButDifferentIds()
        {
            XmlFileContext <SampleContext> xmlFileCtx = new XmlFileContext <SampleContext>(this.GetType());

            XmlFileContext <SampleContext> xmlFileExpectedCtx = new XmlFileContext <SampleContext>(this.GetType());

            SampleContext ctx1 = xmlFileCtx.InputContext("test3");
            SampleContext ctx2 = xmlFileExpectedCtx.ExpectedContext("test3");

            var result = await ctx1.CompareTo(ctx2);

            result.AreEqual.ShouldBe(false);
            result.Differences.Count.ShouldBe(1);
            result.Differences[0].ToString().ShouldBe("Author was null - object with AUT_ID : 2 (we couldn't find an actual object with expected id  : 2 - this can be caused because the id is auto generated. You could adapt the ids of the expected object)");
        }
        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 ShouldReturnFalseForContextWithSameCollectionCountButDifferentIds()
        {
            XmlFileContext<SampleContext> xmlFileCtx = new XmlFileContext<SampleContext>(this.GetType());

            XmlFileContext<SampleContext> xmlFileExpectedCtx = new XmlFileContext<SampleContext>(this.GetType());

            SampleContext ctx1 = xmlFileCtx.InputContext("test3");
            SampleContext ctx2 = xmlFileExpectedCtx.ExpectedContext("test3");

            var result = await ctx1.CompareTo(ctx2);

            result.AreEqual.ShouldBe(false);
            result.Differences.Count.ShouldBe(1);
            result.Differences[0].ToString().ShouldBe("Author was null - object with AUT_ID : 2 (we couldn't find an actual object with expected id  : 2 - this can be caused because the id is auto generated. You could adapt the ids of the expected object)");

        }
        public void ShouldReturnPrimaryKeyMemberandColumnName()
        {
            using (SampleContext emptyContext1 = new XmlFileContext <SampleContext>(this.GetType()).Empty())
            {
                var pkName = emptyContext1.KeyMemberFor(typeof(Author));
                pkName.ShouldBe("Id");

                pkName = emptyContext1.KeyMemberFor(typeof(Post));
                pkName.ShouldBe("Id");

                var pkColumnFor = emptyContext1.PrimaryKeyColumnFor(typeof(Author));
                pkColumnFor.ShouldBe("AUT_ID");

                pkColumnFor = emptyContext1.PrimaryKeyColumnFor(typeof(Post));
                pkColumnFor.ShouldBe("Post_Id");
            }
        }
        public async Task TestReturnEmptyXml()
        {
            XmlFileContext <SampleContext> xmlFileCtx = new XmlFileContext <SampleContext>(this.GetType());

            using (SampleContext emptyContext = xmlFileCtx.Empty())
            {
                Author aut1 = new Author();
                aut1.FirstName = "testname";

                emptyContext.Authors.Attach(aut1);

                string fromFile = await emptyContext.AsXmlAsync(DbContextConverterOptions.DEFAULT.WithNullValues());

                dynamic obj = fromFile.XmlToDynamic();

                ((string)obj.AUTHOR[0].AUT_FIRSTNAME).ShouldBe("testname");
            }
        }
        public async Task TestReturnEmptyXml()
        {
            XmlFileContext<SampleContext> xmlFileCtx = new XmlFileContext<SampleContext>(this.GetType());

            using (SampleContext emptyContext = xmlFileCtx.Empty())
            {
                Author aut1 = new Author();
                aut1.FirstName = "testname";

                emptyContext.Authors.Attach(aut1);

                string fromFile = await emptyContext.AsXmlAsync(DbContextConverterOptions.DEFAULT.WithNullValues());

                dynamic obj = fromFile.XmlToDynamic();

                ((string)obj.AUTHOR[0].AUT_FIRSTNAME).ShouldBe("testname");
            }
        }
        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 ShouldBeFalseWhenEntityStateAreDifferent()
        {
            XmlFileContext<SampleContext> xmlFileCtx = new XmlFileContext<SampleContext>(this.GetType());
            XmlFileContext<SampleContext> xmlFileExpectedCtx = new XmlFileContext<SampleContext>(this.GetType());

            SampleContext ctx1 = xmlFileCtx.InputContext("test4");
            SampleContext ctx2 = xmlFileExpectedCtx.ExpectedContext("test4");
            SampleContext ctx3 = xmlFileExpectedCtx.ExpectedContext("test4b");

            var auth = ctx1.Authors.Find((Int64)1);
            auth.FirstName = "cedric";
            
            var result = await ctx1.CompareTo(ctx2);
            result.AreEqual.ShouldBe(false, result.ToString());

            ctx1.SaveChanges();
            result = await ctx1.CompareTo(ctx3);
            result.AreEqual.ShouldBe(true, result.ToString());

        }
예제 #30
0
        public async Task ShouldBeFalseWhenEntityStateAreDifferent()
        {
            XmlFileContext <SampleContext> xmlFileCtx         = new XmlFileContext <SampleContext>(this.GetType());
            XmlFileContext <SampleContext> xmlFileExpectedCtx = new XmlFileContext <SampleContext>(this.GetType());

            SampleContext ctx1 = xmlFileCtx.InputContext("test4");
            SampleContext ctx2 = xmlFileExpectedCtx.ExpectedContext("test4");
            SampleContext ctx3 = xmlFileExpectedCtx.ExpectedContext("test4b");

            var auth = ctx1.Authors.Find((Int64)1);

            auth.FirstName = "cedric";

            var result = await ctx1.CompareTo(ctx2);

            result.AreEqual.ShouldBe(false, result.ToString());

            ctx1.SaveChanges();
            result = await ctx1.CompareTo(ctx3);

            result.AreEqual.ShouldBe(true, result.ToString());
        }
        public async Task ShouldRecordOriginalValues(string test)
        {
            var contextFactory = new XmlFileContext <SampleContext>(this.GetType());

            using (SampleContext sampleContext = contextFactory.InputContext(test, "original-values-tests", false).StartRecordingOriginalValues())
            {
                Post post = sampleContext.Posts.Find((Int64)1);
                post.Body = "Changed : " + post.Body;
                sampleContext.SaveChanges();

                var recordedContext = sampleContext.GetRecordedContext();

                sampleContext.PauseRecordingOriginalValues();

                var result = await sampleContext.CompareTo(recordedContext);

                result.AreEqual.ShouldBe(false);
                result.Differences.Count.ShouldBe(1);
                result.Differences[0].ToString().ShouldBe("Post.Body Should be [Original Body] but was [Changed : Original Body] - object with Post_Id : 1");

                sampleContext.StopRecordingOriginalValues();
            }
        }
        public async Task ShouldCompareTwoContextWithSimpleContent()
        {
            using (SampleContext expectedContext = GetSimpleTestContext())
            {
                using (SampleContext appContext = new XmlFileContext<SampleContext>(this.GetType()).Empty())
                {
                    appContext.Authors.Add(new Author() {  FirstName = "Cedric123" });
                    appContext.SaveChanges();
                   
                    //compare context
                    var comparisonResult = await appContext.CompareTo(expectedContext);

                    string s = await appContext.AsXmlAsync();
                    string s2 = await expectedContext.AsXmlAsync(ContextDataEnum.All);

                    comparisonResult.AreEqual.ShouldBe(false, comparisonResult.ToString());
                    comparisonResult.Differences.Count.ShouldBe(2);
                    comparisonResult.Differences[0].ToString()
                        .ShouldBe("Author.FirstName Should be [Cedric] but was [Cedric123] - object with AUT_ID : 1");

                }
            }
        }
        public async Task ShouldRecordOriginalValues(string test)
        {
            var contextFactory = new XmlFileContext<SampleContext>(this.GetType());

            using (SampleContext sampleContext = contextFactory.InputContext(test, "original-values-tests", false).StartRecordingOriginalValues())
            {
                Post post = sampleContext.Posts.Find((Int64)1);
                post.Body = "Changed : " + post.Body;
                sampleContext.SaveChanges();

                var recordedContext = sampleContext.GetRecordedContext();

                sampleContext.PauseRecordingOriginalValues();

                var result = await sampleContext.CompareTo(recordedContext);

                result.AreEqual.ShouldBe(false);
                result.Differences.Count.ShouldBe(1);
                result.Differences[0].ToString().ShouldBe("Post.Body Should be [Original Body] but was [Changed : Original Body] - object with Post_Id : 1");

                sampleContext.StopRecordingOriginalValues();

            }
        }
        public void ShouldGetMappings()
        {
            using (SampleContext emptyContext = new XmlFileContext <SampleContext>(this.GetType()).Empty())
            {
                var entityMapping = emptyContext.GetMappings <Author>();

                entityMapping.Table.ShouldBe("AUTHOR");
                entityMapping.Entity.ShouldBe("Author");
                entityMapping.PropertiesMapping.Count().ShouldBe(4);

                entityMapping.MappedColumn("FirstName").ShouldBe("AUT_FIRSTNAME");
                entityMapping.MappedProperty("AUT_FIRSTNAME").ShouldBe("FirstName");

                entityMapping.MappedColumn("Id").ShouldBe("AUT_ID");
                entityMapping.MappedProperty("AUT_ID").ShouldBe("Id");


                //from table name
                entityMapping = emptyContext.GetMappings("AUTHOR");

                entityMapping.Entity.ShouldBe("Author");
                entityMapping.ClrType.ShouldBe(typeof(Author));
            }
        }
예제 #35
0
        private SampleContext GetExpectedContext(string testname)
        {
            SampleContext ctx = new XmlFileContext <SampleContext>(this.GetType()).ExpectedContext(testname);

            return(ctx);
        }
        public void ShouldReturnPrimaryKeyMemberandColumnName()
        {
            using (SampleContext emptyContext1 = new XmlFileContext<SampleContext>(this.GetType()).Empty())
            {
                var pkName = emptyContext1.KeyMemberFor(typeof(Author));
                pkName.ShouldBe("Id");
                
                pkName = emptyContext1.KeyMemberFor(typeof(Post));
                pkName.ShouldBe("Id");

                var pkColumnFor = emptyContext1.PrimaryKeyColumnFor(typeof(Author));
                pkColumnFor.ShouldBe("AUT_ID");

                pkColumnFor = emptyContext1.PrimaryKeyColumnFor(typeof(Post));
                pkColumnFor.ShouldBe("Post_Id");
            }
        }
        public async Task ShouldReturnFalseForContextWithEntryContainingDifferentValues()
        {
            XmlFileContext<SampleContext> xmlFileCtx = new XmlFileContext<SampleContext>(this.GetType());
            XmlFileContext<SampleContext> xmlFileExpectedCtx = new XmlFileContext<SampleContext>(this.GetType());

            SampleContext ctx1 = xmlFileCtx.InputContext("test2");
            SampleContext ctx2 = xmlFileExpectedCtx.ExpectedContext("test2");

            var result = await ctx1.CompareTo(ctx2);

            result.AreEqual.ShouldBe(false);
            result.Differences.Count.ShouldBe(2);

            result.Differences[0].ObjectId.ShouldBe("2");
            result.Differences[0].ObjectName.ShouldBe("Post");
            result.Differences[0].PropertyName.ShouldBe("Subject");
            result.Differences[0].ActualPropertyContent.ShouldBe("First Text");
            result.Differences[0].ExpectedPropertyContent.ShouldBe("First Text Modified");
            result.Differences[0].ToString().ShouldBe("Post.Subject Should be [First Text Modified] but was [First Text] - object with Post_Id : 2");

            result.Differences[1].ObjectId.ShouldBe("2");
            result.Differences[1].ObjectName.ShouldBe("Post");
            result.Differences[1].PropertyName.ShouldBe("Body");
            result.Differences[1].ActualPropertyContent.ShouldBe("Some Text here");
            result.Differences[1].ExpectedPropertyContent.ShouldBe("Some Other Text here");
        }
        public void ShouldGetMappings()
        {
            using (SampleContext emptyContext = new XmlFileContext<SampleContext>(this.GetType()).Empty())
            {
                var entityMapping = emptyContext.GetMappings<Author>();

                entityMapping.Table.ShouldBe("AUTHOR");
                entityMapping.Entity.ShouldBe("Author");
                entityMapping.PropertiesMapping.Count().ShouldBe(4);

                entityMapping.MappedColumn("FirstName").ShouldBe("AUT_FIRSTNAME");
                entityMapping.MappedProperty("AUT_FIRSTNAME").ShouldBe("FirstName");

                entityMapping.MappedColumn("Id").ShouldBe("AUT_ID");
                entityMapping.MappedProperty("AUT_ID").ShouldBe("Id");


                //from table name
                entityMapping = emptyContext.GetMappings("AUTHOR");

                entityMapping.Entity.ShouldBe("Author");
                entityMapping.ClrType.ShouldBe(typeof(Author));
            }
        }
        public void ShouldGetMappedColumnAndPropertyName()
        {
            using (SampleContext emptyContext1 = new XmlFileContext<SampleContext>(this.GetType()).Empty())
            {
                var columnName = emptyContext1.MappedColumnName("Author", "Id");
                columnName.ShouldBe("AUT_ID");

                columnName = emptyContext1.MappedColumnName("Author", "FirstName");
                columnName.ShouldBe("AUT_FIRSTNAME");

                var propertyName = emptyContext1.MappedPropertyName("AUTHOR", "AUT_FIRSTNAME");
                propertyName.ShouldBe("FirstName");
            }
        }
        private SampleContext GetExpectedContext(string testname)
        {
            XmlFileContext<SampleContext> factory = new XmlFileContext<SampleContext>(this.GetType());

            SampleContext ctx = factory.ExpectedContext(testname, "persistent_tests_input", false);

            return ctx;
        }
        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());
            }
        }
예제 #42
0
        private SampleContext GetExpectedContext(string testname)
        {
            SampleContext ctx = new XmlFileContext<SampleContext>(this.GetType()).ExpectedContext(testname);

            return ctx;
        }
        private SampleContext GetSimpleTestContext()
        {
            SampleContext simpleContext = new XmlFileContext<SampleContext>(this.GetType()).Empty();
            
            Author cedric = new Author() { FirstName = "Cedric", LastName = "Dumont" };

            simpleContext.Authors.Add(cedric);

            simpleContext.SaveChanges();

            return simpleContext;
        }