public void Lists_Of_Guids_Are_Formatted_Correctly()
	    {
            using (var db = OpenDbConnection())
            {
                db.DropAndCreateTable<WithAListOfGuids>();

                JsConfig<Guid>.RawSerializeFn = x => x.ToString();

                var item = new WithAListOfGuids {
                    GuidOne = new Guid("32cb0acb-db43-4061-a6aa-7f4902a7002a"),
                    GuidTwo = new Guid("13083231-b005-4ff4-ab62-41bdc7f50a4d"),
                    TheGuids = new[] { new Guid("18176030-7a1c-4288-82df-a52f71832381"), new Guid("017f986b-f7be-4b6f-b978-ff05fba3b0aa") },
                };

                db.Insert(item);

                var tbl = "WithAListOfGuids".SqlTable();
                var savedGuidOne = db.Select<Guid>("SELECT {0} FROM {1}".Fmt("GuidOne".SqlColumn(), tbl)).First();
                Assert.That(savedGuidOne, Is.EqualTo(new Guid("32cb0acb-db43-4061-a6aa-7f4902a7002a")));

                var savedGuidTwo = db.Select<Guid>("SELECT {0} FROM {1}".Fmt("GuidTwo".SqlColumn(), tbl)).First();
                Assert.That(savedGuidTwo, Is.EqualTo(new Guid("13083231-b005-4ff4-ab62-41bdc7f50a4d")));

                var savedGuidList = db.Select<string>("SELECT {0} FROM {1}".Fmt("TheGuids".SqlColumn(), tbl)).First();
                Assert.That(savedGuidList, Is.EqualTo("[18176030-7a1c-4288-82df-a52f71832381,017f986b-f7be-4b6f-b978-ff05fba3b0aa]"));

                JsConfig.Reset();
            }
	    }
Ejemplo n.º 2
0
        public void Lists_Of_Guids_Are_Formatted_Correctly()
        {
            LogManager.LogFactory = new ConsoleLogFactory();
            using (var db = OpenDbConnection())
            {
                db.DropAndCreateTable <WithAListOfGuids>();

                JsConfig <Guid> .RawSerializeFn = x => x.ToString();

                var item = new WithAListOfGuids
                {
                    GuidOne  = new Guid("32cb0acb-db43-4061-a6aa-7f4902a7002a"),
                    GuidTwo  = new Guid("13083231-b005-4ff4-ab62-41bdc7f50a4d"),
                    TheGuids = new[] { new Guid("18176030-7a1c-4288-82df-a52f71832381"), new Guid("017f986b-f7be-4b6f-b978-ff05fba3b0aa") },
                };

                db.Insert(item);

                var tbl          = "WithAListOfGuids".SqlTable();
                var savedGuidOne = db.Select <Guid>("SELECT {0} FROM {1}".Fmt("GuidOne".SqlColumn(), tbl)).First();
                Assert.That(savedGuidOne, Is.EqualTo(new Guid("32cb0acb-db43-4061-a6aa-7f4902a7002a")));

                var savedGuidTwo = db.Select <Guid>("SELECT {0} FROM {1}".Fmt("GuidTwo".SqlColumn(), tbl)).First();
                Assert.That(savedGuidTwo, Is.EqualTo(new Guid("13083231-b005-4ff4-ab62-41bdc7f50a4d")));

                var savedGuidList = db.Select <string>("SELECT {0} FROM {1}".Fmt("TheGuids".SqlColumn(), tbl)).First();
                Assert.That(savedGuidList, Is.EqualTo("[18176030-7a1c-4288-82df-a52f71832381,017f986b-f7be-4b6f-b978-ff05fba3b0aa]"));

                JsConfig.Reset();
            }
        }