NOODB: Nullable Enums

Nullable enums now work. Of course, it didn’t just automatically work. I will never again anticipate that any particular feature is going to work based on the implementation of a previous feature.

Here’s the new nullable enum test.

USUAL isn’t nullable. NULLABLE and NULLABLE2 are nullable. This shows that non-nullable continues to work, and nullable works with and without a value.

            EnumTestClass test = new EnumTestClass
            {
                Name="name",
                Usual = CrapEnum.B,
                Nullable = null,
                Nullable2 = CrapEnum.C
            };

            NoodbClient client = new NoodbClient(new Server(TestUtility.UnityContainer));
            client.RegisterType<EnumTestClass>();
            client.Save(test);

            EnumTestClass fromDb = client.GetObjects<EnumTestClass>()[0];
            Assert.AreEqual("name", fromDb.Name);
            Assert.AreEqual(CrapEnum.B, fromDb.Usual);
            Assert.IsNull(fromDb.Nullable);
            Assert.AreEqual(CrapEnum.C, fromDb.Nullable2);

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: