Ejemplo n.º 1
0
        public void SaveThenReadDummyWithReadOnlyObservableCollectionOfInts(bool trackingDirty)
        {
            var jsonSettings = new JsonSerializerSettings
            {
                NullValueHandling          = NullValueHandling.Ignore,
                Culture                    = CultureInfo.InvariantCulture,
                MissingMemberHandling      = MissingMemberHandling.Ignore,
                PreserveReferencesHandling = PreserveReferencesHandling.Objects,
            };

            jsonSettings.Converters.Add(new ReadOnlyObservableCollectionConverter <int>());
            var settings = new DataRepositorySettings(
                directory: this.TargetDirectory.FullName,
                jsonSerializerSettings: jsonSettings,
                isTrackingDirty: trackingDirty,
                saveNullDeletesFile: true,
                backupSettings: null);

            var repository = new DataRepository(settings);
            var dummy      = new DummyWith <ReadOnlyObservableCollection <int> > {
                Data = new ReadOnlyObservableCollection <int>(new ObservableCollection <int> {
                    1, 2, 3
                })
            };

            repository.Save("dummy", dummy);
            var roundtrip = repository.Read <DummyWith <ReadOnlyObservableCollection <int> > >("dummy");

            CollectionAssert.AreEqual(dummy.Data, roundtrip.Data);
        }
Ejemplo n.º 2
0
        public void SaveThenReadDummyWithArrayOfInts()
        {
            var jsonSettings = new JsonSerializerSettings
            {
                NullValueHandling          = NullValueHandling.Ignore,
                TypeNameHandling           = TypeNameHandling.Objects,
                Culture                    = CultureInfo.InvariantCulture,
                MissingMemberHandling      = MissingMemberHandling.Ignore,
                PreserveReferencesHandling = PreserveReferencesHandling.Objects,
            };

            var settings = new DataRepositorySettings(
                directory: this.TargetDirectory.FullName,
                jsonSerializerSettings: jsonSettings,
                isTrackingDirty: true,
                saveNullDeletesFile: true,
                backupSettings: null);

            var repository = new DataRepository(settings);
            var dummy      = new DummyWith <int[]> {
                Data = new[] { 1, 2, 3 }
            };

            repository.Save("dummy", dummy);
            var roundtrip = repository.Read <DummyWith <int[]> >("dummy");

            CollectionAssert.AreEqual(dummy.Data, roundtrip.Data);
        }
Ejemplo n.º 3
0
        protected override IRepository Create()
        {
            var settings = new DataRepositorySettings(
                directory: this.TargetDirectory.FullName,
                jsonSerializerSettings: RepositorySettings.CreateDefaultJsonSettings(),
                isTrackingDirty: false,
                saveNullDeletesFile: true,
                backupSettings: Default.BackupSettings(this.TargetDirectory));

            return(new DataRepository(settings));
        }
Ejemplo 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));
        }