Inheritance: Roadkill.Core.Database.IRepository
Esempio n. 1
0
        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"));
        }
Esempio n. 2
0
		protected IRepository GetRepository()
		{
			ApplicationSettings appSettings = new ApplicationSettings();
			appSettings.DataStoreType = DataStoreType.SqlServer2012;
			appSettings.ConnectionString = SqlExpressSetup.ConnectionString;
			appSettings.LoggingTypes = "none";
			appSettings.UseBrowserCache = false;
			Log.ConfigureLogging(appSettings);

			LightSpeedRepository repository = new LightSpeedRepository(appSettings);
			repository.Startup(appSettings.DataStoreType, appSettings.ConnectionString, false);
			return repository;
		}
Esempio n. 3
0
        /// <summary>
        /// Returns the organisation name
        /// </summary>
        public string GetRelType(int relTypeID)
        {

            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());

            RelationshipType _reltype;
            _reltype = repository.GetRelTypeByID(relTypeID);

            return _reltype.relTypeText;

        }
Esempio n. 4
0
        /// <summary>
        /// Returns the user name
        /// </summary>
        public string GetUser(string username)
        {

            string _usernames = "unknown";
            try
            {

                LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());
                User _user;
                _user = repository.GetUserByUsername(username);
                _usernames = _user.Firstname + " " + _user.Lastname;
            }
            catch { }

            return _usernames;

        }
Esempio n. 5
0
        /// <summary>
        /// Returns the organisation name
        /// </summary>
        public string GetOrg(int orgID)
        {

            string _orgname = "unknown";
            try
            {

                LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());
                Organisation _org;
                _org = repository.GetOrgByID(orgID);
                _orgname = _org.OrgName;
            }
            catch { }

            return _orgname;

        }
Esempio n. 6
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.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));
        }
Esempio n. 7
0
        public List<Activity> Activity()
        {
            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());


            IEnumerable<Activity> ActivityList;
            ActivityList = repository.ActivityViewList();

            List<Activity> items = new List<Activity>();

            foreach (Activity act in ActivityList)
            {

                Activity item = new Activity();
                item.id = act.id;
                item.activityName = act.activityName;
                item.orgName = act.orgName;
                item.projectName = act.projectName;
                item.userNames = act.userNames;                

                items.Add(item);
            }

            return items;

        }
Esempio n. 8
0
        public List<Relationship> GetRelationships()
        {
             LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());
             return repository.FindPageRelationships(Id);

        }
Esempio n. 9
0
        /// <summary>
        /// Returns if this user has already added a relationship to this page
        /// </summary>
        public Relationship RelToUserToPage(int pageID)
        {
            
                LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());

                RoadkillContext = ObjectFactory.GetInstance<IUserContext>();

                return repository.RelToUserToPage(pageID, RoadkillContext.CurrentUsername);
  

        }
        /// <summary>
        /// Gets the number of organisations signed up to Pipeline
        /// </summary>
        public static IEnumerable<Activity> WhatsHotList()
        {

            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());
            return repository.WhatsHotList();

        }
        /// <summary>
        /// Gets the number of organisations signed up to Pipeline
        /// </summary>
        public static int UsersCount()
        {

            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());
            return repository.AllUsersCount();

        }
        /// <summary>
        /// Gets the number of organisations signed up to Pipeline
        /// </summary>
        public static int OrganisationCount()
        {

            LightSpeedRepository repository = new LightSpeedRepository(GetAppSettings());
            return repository.AllOrgsCount();

        }