1
複雑なプロジェクトにジャンプしなければならず、WEB APIサービスで特定のリポジトリの単体テストを作成しています。データベースCRUDは、Entity Frameworkによって処理されます。テーブルが存在するときに無効なオブジェクト名を指定するEntity Framework
private class IntegrationScope : AutoRollbackTransactionTestScope<DocumentRepository>
{
public IntegrationScope()
{
DependencyResolverMock = MockDependencyResolverFor<IResourceUrlBuilder, ResourceUrlBuilder>(new ResourceUrlBuilder());
LoggingProviderMock = new Mock<ILoggingProvider>();
// use real document micro service AutoMapper & Unity configuration
AutoMapperConfig.RegisterMaps(Mapper.Configuration, DependencyResolverMock);
UnityConfig.RegisterTypes(TestScopeContainer);
//Set the DomainId
TestId = Guid.NewGuid();
TestDocument = BuildDocument(TestId);
// get the real object
DocumentStoreDbContext = TestScopeContainer.Resolve<IDocumentDbContext>();
InstanceUnderTest = new DocumentRepository(DocumentStoreDbContext);
}
public static Web.Service.DocumentStore.Domain.Document BuildDocument(Guid documentId)
{
// Invoke GetBytes method.
byte[] array = Encoding.ASCII.GetBytes("Byte Repository Test");
return Builder<Web.Service.DocumentStore.Domain.Document>
.CreateNew()
.With(t => t.Id = documentId)
.With(t => t.Data = array)
.Build();
}
それはDocumentStoreDbContextラインになると、コンパイル・エラーがありませんが、私は、オブジェクト名が無効であることを言って、ランタイムエラーを取得する:いくつかの研究これを実行した後
エラーは、データベース/テーブルが存在しないので、しかし、私はそれが存在しないことを確認することができますように表示されます。
私は間違って何をしていますか、どうすれば修正できますか?
テーブルがエンティティモデルで正しくマップされていることを確認しましたか? – derloopkat