NOODB: Enum Support

NOODB can now save ENUM values.

NOODB Enum Wiki Page

        [TestMethod]
        public void ShouldSaveEnums()
        {
            TestUtility.DeleteTestData();
            try
            {
                IClient client = new Client(new Server(TestUtility.DefaultUnityContainer));
                client.RegisterType(typeof(Book));

                // book has a Name proeprty and a BookType property
                // BookType is of type BookTypes, which is a regular enum
                client.Save(new Book { BookType = BookTypes.Pretend, Name = "Garfield Volume 1" });

                Book fromDb = client.GetObjects<Book>()[0];
                Assert.AreEqual(BookTypes.Pretend, fromDb.BookType);
            }
            finally
            {
                TestUtility.DeleteTestData();
            }
        }

        [TestMethod]
        public void ShouldSaveFlagEnums()
        {
            TestUtility.DeleteTestData();
            try
            {
                // EnumFlagTest contains a single property of type MultiEnum, which is a FlagsEnum.
                IClient client = new Client(new Server(TestUtility.DefaultUnityContainer));
                client.RegisterType(typeof(EnumFlagTest));
                client.Save(new EnumFlagTest { TestEnum = MultiEnum.One | MultiEnum.Three | MultiEnum.Five, Id = 334455 });

                EnumFlagTest fromDb = client.GetObjects<EnumFlagTest>()[0];
                Assert.AreEqual(MultiEnum.One | MultiEnum.Three | MultiEnum.Five, fromDb.TestEnum);
            }
            finally
            {
                TestUtility.DeleteTestData();
            }
        }

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: