示例#1
0
 public void Can_delete_database_if_exists_using_Database_obtained_from_context()
 {
     using (var context = new EmptyContext())
     {
         var database = context.Database;
         Can_delete_database_if_exists(database.Delete, database.Exists);
     }
 }
示例#2
0
 public void Can_create_database_using_Database_obtained_from_context()
 {
     using (var context = new EmptyContext())
     {
         GetObjectContext(context); // Ensures context is initialized
         Can_create_database(context.Database);
     }
 }
示例#3
0
 public void CreateDatabase_throws_if_database_already_exists_using_Database_obtained_from_context()
 {
     using (var context = new EmptyContext())
     {
         context.Database.CreateIfNotExists();
         Assert.Throws <InvalidOperationException>(() => context.Database.Create()).ValidateMessage(
             "Database_DatabaseAlreadyExists", "SimpleModel.EmptyContext");
     }
 }
示例#4
0
 public void Database_can_be_reused_for_multiple_operations_when_backed_by_a_context()
 {
     using (var context = new EmptyContext())
     {
         var database = context.Database;
         database.Delete();               // First use
         Assert.False(database.Exists()); // Second use
     }
 }
示例#5
0
        // TODO: [Fact(Skip = "SDE Merge - No partial trust yet")]
        public void Non_generic_DbSet_creation_works_under_partial_trust()
        {
            using (var context = new EmptyContext())
            {
                var set = context.Set(typeof(Product));

                Assert.NotNull(set);
            }
        }
示例#6
0
        public void PassingWrongOptionsInstanceToResolverThrowsException()
        {
            JsonSerializerOptions defaultOptions = JsonSerializerOptions.Default;
            JsonSerializerOptions contextOptions = new();
            IJsonTypeInfoResolver context        = new EmptyContext(contextOptions);

            Assert.IsAssignableFrom <JsonTypeInfo <int> >(context.GetTypeInfo(typeof(int), contextOptions));
            Assert.IsAssignableFrom <JsonTypeInfo <int> >(context.GetTypeInfo(typeof(int), null));
            Assert.Throws <InvalidOperationException>(() => context.GetTypeInfo(typeof(int), defaultOptions));
        }
示例#7
0
        private void Can_delete_database(Action deleteDatabase, Func <bool> databaseExists)
        {
            using (var context = new EmptyContext())
            {
                context.Database.CreateIfNotExists();
            }
            deleteDatabase();

            Assert.False(databaseExists());
        }
示例#8
0
        public void CreateDatabaseIfNotExists_does_nothing_if_database_exists_using_Database_obtained_from_context()
        {
            using (var context = new EmptyContext())
            {
                context.Database.CreateIfNotExists();

                Assert.False(context.Database.CreateIfNotExists());

                Assert.True(context.Database.Exists());
            }
        }
示例#9
0
        private void Can_delete_database_if_exists(Func <bool> deleteDatabaseIfExists, Func <bool> databaseExists)
        {
            using (var context = new EmptyContext())
            {
                context.Database.CreateIfNotExists();
            }

            Assert.True(deleteDatabaseIfExists());

            Assert.False(databaseExists());
        }
示例#10
0
        public void Checking_if_database_exists_should_not_create_database_Dev10_883499()
        {
            using (var context = new EmptyContext())
            {
                GetObjectContext(context); // Ensures context is initialized
                Database.Delete(DefaultDbName <EmptyContext>());
                Assert.False(context.Database.Exists());

                context.Database.Create();
                Assert.True(context.Database.Exists());
            }
        }
示例#11
0
        public void Can_create_database_if_it_does_not_exist_using_Database_obtained_from_context_Dev10_884353()
        {
            using (var context = new EmptyContext())
            {
                GetObjectContext(context); // Ensures context is initialized
                Database.Delete(DefaultDbName <EmptyContext>());

                Assert.True(context.Database.CreateIfNotExists());

                Assert.True(context.Database.Exists());
            }
        }
示例#12
0
    public void Compiled_model_is_thread_safe()
    {
        var tasks = new Task[Environment.ProcessorCount];

        for (var i = 0; i < tasks.Length; i++)
        {
            tasks[i] = Task.Run(
                () =>
            {
                using var ctx = new EmptyContext();
                Assert.NotNull(ctx.Model.GetRelationalDependencies());
            });
        }

        Task.WaitAll(tasks);
    }
示例#13
0
 public void Can_get_metadata_with_minimal_DbConnection_implementation()
 {
     // Required for use with MVC Scaffolding that uses Microsoft.VisualStudio.Web.Mvc.Scaffolding.BuiltIn.ScaffoldingDbConnection
     // which is a very minimal implementation of DbConnection.
     using (var connection = new FakeSqlConnection
     {
         ConnectionString = ""
     })
     {
         using (var context = new EmptyContext(connection))
         {
             var metadata = ((IObjectContextAdapter)context).ObjectContext.MetadataWorkspace;
             Assert.NotNull(metadata);
         }
     }
 }
示例#14
0
    public Contexts()
    {
        Empty       = new EmptyContext();
        Example     = new ExampleContext();
        Game        = new GameContext();
        VisualDebug = new VisualDebugContext();

        var postConstructors = System.Linq.Enumerable.Where(
            GetType().GetMethods(),
            method => System.Attribute.IsDefined(method, typeof(JCMG.EntitasRedux.PostConstructorAttribute))
            );

        foreach (var postConstructor in postConstructors)
        {
            postConstructor.Invoke(this, null);
        }
    }
示例#15
0
        public void Read_loads_edmx_from_EdmxWriter_into_DbCompiledModel()
        {
            var stream    = new MemoryStream();
            var xmlWriter = XmlWriter.Create(stream);

            using (var context = new EmptyContext())
            {
                EdmxWriter.WriteEdmx(context, xmlWriter);
            }

            stream.Seek(0, SeekOrigin.Begin);

            var defaultSchema = "default";
            var xmlReader     = XmlReader.Create(stream);
            var readModel     = EdmxReader.Read(xmlReader, defaultSchema);

            Assert.IsType <DbCompiledModel>(readModel);

            Assert.Equal(defaultSchema, readModel.DefaultSchema);
            Assert.NotNull(readModel.ProviderInfo);
        }
示例#16
0
文件: RParser.cs 项目: mpmedia/Excess
	public ExprlistContext exprlist() {
		ExprlistContext _localctx = new ExprlistContext(Context, State);
		EnterRule(_localctx, 6, RULE_exprlist);
		int _la;
		try {
			State = 199;
			switch (TokenStream.La(1)) {
			case T__7:
			case T__14:
			case T__15:
			case T__25:
			case T__30:
			case T__34:
			case T__35:
			case T__37:
			case T__39:
			case T__41:
			case T__42:
			case T__43:
			case T__44:
			case T__45:
			case T__46:
			case T__47:
			case T__48:
			case T__49:
			case T__50:
			case T__51:
			case HEX:
			case INT:
			case FLOAT:
			case COMPLEX:
			case STRING:
			case ID:
				_localctx = new ExpressionListContext(_localctx);
				EnterOuterAlt(_localctx, 1);
				{
				State = 188; expr_or_assign();
				State = 195;
				ErrorHandler.Sync(this);
				_la = TokenStream.La(1);
				while (_la==T__0 || _la==NL) {
					{
					{
					State = 189;
					_la = TokenStream.La(1);
					if ( !(_la==T__0 || _la==NL) ) {
					ErrorHandler.RecoverInline(this);
					}
					else {
					    Consume();
					}
					State = 191;
					_la = TokenStream.La(1);
					if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__7) | (1L << T__14) | (1L << T__15) | (1L << T__25) | (1L << T__30) | (1L << T__34) | (1L << T__35) | (1L << T__37) | (1L << T__39) | (1L << T__41) | (1L << T__42) | (1L << T__43) | (1L << T__44) | (1L << T__45) | (1L << T__46) | (1L << T__47) | (1L << T__48) | (1L << T__49) | (1L << T__50) | (1L << T__51) | (1L << HEX) | (1L << INT) | (1L << FLOAT) | (1L << COMPLEX) | (1L << STRING) | (1L << ID))) != 0)) {
						{
						State = 190; expr_or_assign();
						}
					}

					}
					}
					State = 197;
					ErrorHandler.Sync(this);
					_la = TokenStream.La(1);
				}
				}
				break;
			case T__36:
				_localctx = new EmptyContext(_localctx);
				EnterOuterAlt(_localctx, 2);
				{
				}
				break;
			default:
				throw new NoViableAltException(this);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			ErrorHandler.ReportError(this, re);
			ErrorHandler.Recover(this, re);
		}
		finally {
			ExitRule();
		}
		return _localctx;
	}
示例#17
0
 protected override void Seed(EmptyContext context)
 {
     CustomSeedDatabase = context.Database.Connection.Database;
 }
示例#18
0
 private ReturnValue Clear(EmptyContext <CommandType> context)
 {
     return(ReturnValue.Ok(ReturnValueType.Clear));
 }
 public EmptyController(EmptyContext context)
 {
     _context = context;
 }
示例#20
0
 private ReturnValue Exit(EmptyContext <CommandType> context)
 {
     return(ReturnValue.Ok(ReturnValueType.ExitApplication));
 }