Ejemplo n.º 1
0
        public void ShouldBeAbleToAddSqlLiteDb()
        {
            var builder =
                new DbContextOptionsBuilder <SampleArchDbContext>()
                .EnableSensitiveDataLogging()
                .UseSqlite("DataSource=:memory:");

            using var context = new SampleArchDbContext(builder.Options);

            // Required for SqlLite
            context.Database.OpenConnection();
            context.Database.EnsureCreated();


            context.People.Add(
                new Person
            {
                Name      = "Parviz",
                Phone     = "0506856915",
                Address   = "Baku",
                State     = "Baku",
                CountryId = 1
            });

            context.SaveChanges();

            Assert.Equal(1, context.People.Count(p =>
                                                 p.Name == "Parviz"));
        }
Ejemplo n.º 2
0
        public void ShouldBeAbleToAddInMemoryDb()
        {
            var builder =
                new DbContextOptionsBuilder <SampleArchDbContext>()
                .EnableSensitiveDataLogging()
                .UseInMemoryDatabase(Guid.NewGuid().ToString());

            using var context = new SampleArchDbContext(builder.Options);
            context.People.Add(
                new Person
            {
                Name      = "Parviz",
                Phone     = "0506856915",
                Address   = "Baku",
                State     = "Baku",
                CountryId = 1
            });
            context.SaveChanges();

            Assert.Equal(1, context.People.Count(p =>
                                                 p.Name == "Parviz"));
        }