コード例 #1
0
ファイル: TestDbContext.cs プロジェクト: simonmau/enum_ext
        public void Test_SaveData_WithOwnedEntity()
        {
            // In-memory database only exists while the connection is open
            using (var connection = new SqliteConnection("DataSource=:memory:"))
            {
                connection.Open();

                var options = new DbContextOptionsBuilder <TestDbContext>()
                              .UseSqlite(connection)
                              .Options;

                using (var db = new TestDbContext(options))
                {
                    db.Database.EnsureCreated();

                    db.EntitiesWithOwnedProperties.Add(new Enum.Ext.EFCore.Tests.DbContext.Entities.EntityWithOwnedProperty()
                    {
                        OwnedStuff = new Enum.Ext.EFCore.Tests.DbContext.Entities.OwnedStuff()
                        {
                            Weekday = Weekday.Thursday
                        }
                    });

                    db.SaveChanges();
                }

                using (var db = new TestDbContext(options))
                {
                    var entities = db.EntitiesWithOwnedProperties.ToList();

                    entities.Count.Should().Be(1);
                    entities.Single().OwnedStuff.Should().NotBeNull();
                    entities.Single().OwnedStuff !.Weekday.Should().Be(Weekday.Thursday);
                }
            }
        }
コード例 #2
0
        public void Test_AssignByInt()
        {
            Weekday day = (Weekday)2;

            day.Should().Be(Weekday.Tuesday);
        }
コード例 #3
0
        public void Test_ConvertFromInt()
        {
            Weekday value = (Weekday)1;

            value.Should().Be(Weekday.Monday);
        }