Exemplo n.º 1
0
        protected override IRepository Create()
        {
            var settings = new NewtonsoftJson.DataRepositorySettings(
                directory: this.TargetDirectory.FullName,
                jsonSerializerSettings: RepositorySettings.CreateDefaultJsonSettings(),
                isTrackingDirty: true,
                saveNullDeletesFile: true,
                backupSettings: Default.BackupSettings(this.TargetDirectory));

            return(new DataRepository(settings));
        }
Exemplo n.º 2
0
        private static SingletonRepository CreateJsonRepositoryWithGitBackuper()
        {
            var jsonSerializerSettings = RepositorySettings.CreateDefaultJsonSettings();
            var settings = new RepositorySettings(
                directory: Directories.Default.FullName,
                jsonSerializerSettings: jsonSerializerSettings,
                isTrackingDirty: false,
                backupSettings: null);

            var gitBackuper = new GitBackuper(settings.Directory);

            return(new SingletonRepository(settings, gitBackuper));
        }
Exemplo n.º 3
0
        public void RoundtripJsonRepositorySettings()
        {
            var backupSettings = new BackupSettings(BackupDir.FullName, ".abc", BackupSettings.DefaultTimeStampFormat, 2, 3);
            var settings       = new RepositorySettings(
                directory: Directory.FullName,
                jsonSerializerSettings: RepositorySettings.CreateDefaultJsonSettings(),
                isTrackingDirty: false,
                backupSettings: backupSettings,
                extension: ".cde",
                tempExtension: ".fgh");
            var json         = JsonConvert.SerializeObject(settings);
            var roundtripped = JsonConvert.DeserializeObject <RepositorySettings>(json);

            AssertProperties(settings, roundtripped);
            Assert.IsTrue(JsonEqualsComparer <RepositorySettings> .Default.Equals(settings, roundtripped));
        }
Exemplo n.º 4
0
        public void RoundtripJsonDataRepositorySettingsWithRepository()
        {
            var backupSettings = new BackupSettings(BackupDir.FullName, ".abc", BackupSettings.DefaultTimeStampFormat, 2, 3);
            var settings       = new DataRepositorySettings(
                directory: Directory.FullName,
                jsonSerializerSettings: RepositorySettings.CreateDefaultJsonSettings(),
                isTrackingDirty: false,
                saveNullDeletesFile: false,
                backupSettings: backupSettings,
                extension: ".cde",
                tempExtension: ".fgh");
            var repository = new DataRepository(DataRepositorySettings);

            repository.Save(settings);
            var roundtripped = repository.Read <DataRepositorySettings>();

            AssertProperties(settings, roundtripped);
            Assert.IsTrue(JsonEqualsComparer <DataRepositorySettings> .Default.Equals(settings, roundtripped));
        }
Exemplo n.º 5
0
        public void CreateFromRepositorySettingsAndJsonSettings()
        {
            var backupSettings     = new BackupSettings(BackupDir.FullName, ".abc", BackupSettings.DefaultTimeStampFormat, 2, 3);
            var repositorySettings = new Core.RepositorySettings(
                directory: Directory.FullName,
                isTrackingDirty: false,
                backupSettings: backupSettings,
                extension: ".cde",
                tempExtension: ".fgh");
            var created = new SingletonRepository(repositorySettings, RepositorySettings.CreateDefaultJsonSettings());

            var jsonRepositorySettings = new RepositorySettings(
                directory: Directory.FullName,
                jsonSerializerSettings: RepositorySettings.CreateDefaultJsonSettings(),
                isTrackingDirty: false,
                backupSettings: backupSettings,
                extension: ".cde",
                tempExtension: ".fgh");

            AssertProperties(jsonRepositorySettings, created.Settings);
            Assert.IsTrue(JsonEqualsComparer <RepositorySettings> .Default.Equals(jsonRepositorySettings, created.Settings));
        }