Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        public void Test_AssignByInt()
        {
            Weekday day = (Weekday)2;

            day.Should().Be(Weekday.Tuesday);
        }
Exemplo n.º 3
0
        public void Test_ConvertFromInt()
        {
            Weekday value = (Weekday)1;

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