Beispiel #1
0
        public void ControllerTestBaseSetUp()
        {
            var connectionString  = ConfigurationManager.ConnectionStrings["DocsManager_Test"].ConnectionString;
            var connectionBuilder = new SqlConnectionStringBuilder(connectionString);

            connectionBuilder.InitialCatalog = TestDataBase;
            TestDataBaseConnectionString     = connectionBuilder.ToString();

            DropDatabase();
            CreateDatabase();
            var kernel = new StandardKernel();

            kernel.Bind <IDocumentService>().To <DocumentService>().InRequestScope();
            kernel.Bind(typeof(IRepository <>)).To(typeof(Repository <>));
            _kernel = kernel;
            Context = new DocsManagerDbContext(
                new SqlConnection(TestDataBaseConnectionString));
        }
Beispiel #2
0
 private static void CreateDatabase()
 {
     using (var context = new DocsManagerDbContext(
                new SqlConnection(TestDataBaseConnectionString)))
     {
         context.Database.Initialize(true);
         context.Database.Create();
         var docBytes  = Encoding.Default.GetBytes(DocHex);
         var docXBytes = Encoding.Default.GetBytes(DocxHex);
         var rtfBytes  = Encoding.Default.GetBytes(RtfHex);
         context.Documents.Add(new Document()
         {
             FileSize     = 100,
             CreatedBy    = "test",
             CreatedDate  = DateTime.Now,
             DocumentFile = docBytes,
             FileType     = DocumentTypesEnum.Doc,
             FileName     = "hello.doc"
         });
         context.SaveChanges();
     }
 }
Beispiel #3
0
 public Repository(DocsManagerDbContext context)
 {
     _context = context;
 }