public void should_import_all_pages_categories_and_usernames() { // Arrange ApplicationSettings applicationSettings = new ApplicationSettings(); applicationSettings.AttachmentsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScrewturnImport"); if (Directory.Exists(applicationSettings.AttachmentsFolder)) Directory.Delete(applicationSettings.AttachmentsFolder, true); Directory.CreateDirectory(applicationSettings.AttachmentsFolder); applicationSettings.ConnectionString = _connectionString; applicationSettings.DatabaseName = "SqlServer2008"; var context = new LightSpeedContext(); context.ConnectionString = _connectionString; context.DataProvider = DataProvider.SqlServer2008; context.IdentityMethod = IdentityMethod.GuidComb; IUnitOfWork unitOfWork = context.CreateUnitOfWork(); IPageRepository pageRepository = new LightSpeedPageRepository(unitOfWork); IUserRepository userRepository = new LightSpeedUserRepository(unitOfWork); ScrewTurnImporter importer = new ScrewTurnImporter(applicationSettings, pageRepository, userRepository); // Act importer.ImportFromSqlServer(TestConstants.CONNECTION_STRING); // Assert User user = userRepository.GetUserByUsername("user2"); Assert.That(user.Id, Is.Not.EqualTo(Guid.Empty)); List<Page> pages = pageRepository.AllPages().ToList(); Assert.That(pages.Count, Is.EqualTo(3)); Page page1 = pages.FirstOrDefault(x => x.Title == "Screwturn page 1"); PageContent pageContent1 = pageRepository.GetLatestPageContent(page1.Id); Assert.That(page1.Tags, Is.EqualTo("Category1,")); AssertSameDateTimes(page1.CreatedOn, "2013-08-11 18:05"); AssertSameDateTimes(page1.ModifiedOn, "2013-08-11 18:05"); Assert.That(page1.CreatedBy, Is.EqualTo("admin")); Assert.That(page1.ModifiedBy, Is.EqualTo("admin")); Assert.That(pageContent1.Text, Is.EqualTo("This is an amazing Screwturn page.")); Page page2 = pages.FirstOrDefault(x => x.Title == "Screwturn page 2"); PageContent pageContent2 = pageRepository.GetLatestPageContent(page2.Id); Assert.That(page2.Tags, Is.EqualTo("Category1,Category2,")); AssertSameDateTimes(page2.CreatedOn, "2013-08-11 18:06"); AssertSameDateTimes(page2.ModifiedOn, "2013-08-11 18:06"); Assert.That(page2.CreatedBy, Is.EqualTo("user2")); Assert.That(page2.ModifiedBy, Is.EqualTo("user2")); Assert.That(pageContent2.Text, Is.EqualTo("Amazing screwturn page 2")); }
public void Should_Import_All_Pages_Categories_And_Usernames() { // Arrange ApplicationSettings applicationSettings = new ApplicationSettings(); applicationSettings.AttachmentsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScrewturnImport"); if (Directory.Exists(applicationSettings.AttachmentsFolder)) Directory.Delete(applicationSettings.AttachmentsFolder, true); Directory.CreateDirectory(applicationSettings.AttachmentsFolder); applicationSettings.ConnectionString = _connectionString; applicationSettings.DataStoreType = DataStoreType.SqlServer2012; IRepository repository = new LightSpeedRepository(applicationSettings); repository.Startup(applicationSettings.DataStoreType, applicationSettings.ConnectionString, false); // Clear the database repository.Install(applicationSettings.DataStoreType, applicationSettings.ConnectionString, false); ScrewTurnImporter importer = new ScrewTurnImporter(applicationSettings, repository); // Act importer.ImportFromSqlServer(SqlExpressSetup.ConnectionString); // Assert User user = repository.GetUserByUsername("user2"); Assert.That(user.Id, Is.Not.EqualTo(Guid.Empty)); List<Page> pages = repository.AllPages().ToList(); Assert.That(pages.Count, Is.EqualTo(3)); Page page1 = pages.FirstOrDefault(x => x.Title == "Screwturn page 1"); PageContent pageContent1 = repository.GetLatestPageContent(page1.Id); Assert.That(page1.Tags, Is.EqualTo("Category1,")); Assert.That(page1.CreatedOn.ToString("u"), Is.EqualTo("2013-08-11 19:05:49Z")); Assert.That(page1.ModifiedOn.ToString("u"), Is.EqualTo("2013-08-11 19:05:49Z")); Assert.That(page1.CreatedBy, Is.EqualTo("admin")); Assert.That(page1.ModifiedBy, Is.EqualTo("admin")); Assert.That(pageContent1.Text, Is.EqualTo("This is an amazing Screwturn page.")); Page page2 = pages.FirstOrDefault(x => x.Title == "Screwturn page 2"); PageContent pageContent2 = repository.GetLatestPageContent(page2.Id); Assert.That(page2.Tags, Is.EqualTo("Category1,Category2,")); Assert.That(page2.CreatedOn.ToString("u"), Is.EqualTo("2013-08-11 19:06:54Z")); Assert.That(page2.ModifiedOn.ToString("u"), Is.EqualTo("2013-08-11 19:06:54Z")); Assert.That(page2.CreatedBy, Is.EqualTo("user2")); Assert.That(page2.ModifiedBy, Is.EqualTo("user2")); Assert.That(pageContent2.Text, Is.EqualTo("Amazing screwturn page 2")); }
public void Should_Import_Files_In_Attachments_Folder() { // Arrange ApplicationSettings applicationSettings = new ApplicationSettings(); applicationSettings.AttachmentsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScrewturnImport"); if (Directory.Exists(applicationSettings.AttachmentsFolder)) Directory.Delete(applicationSettings.AttachmentsFolder, true); Directory.CreateDirectory(applicationSettings.AttachmentsFolder); applicationSettings.ConnectionString = _connectionString; applicationSettings.DataStoreType = DataStoreType.SqlServer2012; IRepository repository = new LightSpeedRepository(applicationSettings); repository.Startup(applicationSettings.DataStoreType, applicationSettings.ConnectionString, false); // Clear the database repository.Install(applicationSettings.DataStoreType, applicationSettings.ConnectionString, false); ScrewTurnImporter importer = new ScrewTurnImporter(applicationSettings, repository); // Act importer.ImportFromSqlServer(_connectionString); // Assert string file1 = Path.Combine(applicationSettings.AttachmentsFolder, "atextfile.txt"); string file2 = Path.Combine(applicationSettings.AttachmentsFolder, "screwdriver1.jpg"); FileInfo fileInfo1 = new FileInfo(file1); FileInfo fileInfo2 = new FileInfo(file2); Assert.True(fileInfo1.Exists); Assert.True(fileInfo2.Exists); Assert.That(fileInfo1.Length, Is.GreaterThan(0)); Assert.That(fileInfo2.Length, Is.GreaterThan(0)); }
public void should_import_files_in_attachments_folder() { // Arrange ApplicationSettings applicationSettings = new ApplicationSettings(); applicationSettings.AttachmentsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScrewturnImport"); if (Directory.Exists(applicationSettings.AttachmentsFolder)) Directory.Delete(applicationSettings.AttachmentsFolder, true); Directory.CreateDirectory(applicationSettings.AttachmentsFolder); applicationSettings.ConnectionString = _connectionString; applicationSettings.DatabaseName = "SqlServer2008"; var context = new LightSpeedContext(); context.ConnectionString = _connectionString; context.DataProvider = DataProvider.SqlServer2008; context.IdentityMethod = IdentityMethod.GuidComb; IUnitOfWork unitOfWork = context.CreateUnitOfWork(); IPageRepository pageRepository = new LightSpeedPageRepository(unitOfWork); IUserRepository userRepository = new LightSpeedUserRepository(unitOfWork); ScrewTurnImporter importer = new ScrewTurnImporter(applicationSettings, pageRepository, userRepository); // Act importer.ImportFromSqlServer(_connectionString); // Assert string file1 = Path.Combine(applicationSettings.AttachmentsFolder, "atextfile.txt"); string file2 = Path.Combine(applicationSettings.AttachmentsFolder, "screwdriver1.jpg"); FileInfo fileInfo1 = new FileInfo(file1); FileInfo fileInfo2 = new FileInfo(file2); Assert.True(fileInfo1.Exists); Assert.True(fileInfo2.Exists); Assert.That(fileInfo1.Length, Is.GreaterThan(0)); Assert.That(fileInfo2.Length, Is.GreaterThan(0)); }