public void BackgroundCommand_0_10_64_And_Later_HandleANullDocumentAndMetadata()
        {
            UseRealTables();

            Setup("HybridDb_1_x_x_to_2_x_x_Part1_Tests_2.sql");

            ResetConfiguration();

            UseTypeMapper(new OtherTypeMapper());
            UseMigrations(new InlineMigration(1,
                                              ListOf(new HybridDb_1_x_x_to_2_x_x_Part1.UpfrontCommand()),
                                              ListOf(new HybridDb_1_x_x_to_2_x_x_Part1.BackgroundCommand_0_10_64_And_Later())));

            // Match the serializer with the one used in the sample data set
            var serializer = new DefaultSerializer();

            serializer.EnableAutomaticBackReferences();
            UseSerializer(serializer);

            Document <JObject>("Cases", discriminator: "DV.Application.Cases.Case, DV.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");

            InitializeStore();

            log.Where(x => x.Exception != null).ShouldBeEmpty();

            var after = store.Query(new DocumentTable("Cases"), out _).Single();

            after["Document"].ShouldBe("{}");
            after["Metadata"].ShouldBe(null);
        }
        public void BackgroundCommand_Before_0_10_64()
        {
            UseRealTables();

            Setup("HybridDb_1_x_x_to_2_x_x_Part1_Tests_3.sql");

            UseTypeMapper(new OtherTypeMapper());
            Document <JObject>("BuildingParts", discriminator: "UValueCalculator.Models.RefBuildingPart, UValueCalculator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");

            var before = store.Query(new DocumentTable("BuildingParts"), out _).Single();

            ResetStore();

            UseMigrations(new InlineMigration(1,
                                              ListOf(new HybridDb_1_x_x_to_2_x_x_Part1.UpfrontCommand()),
                                              ListOf(new HybridDb_1_x_x_to_2_x_x_Part1.BackgroundCommand_Before_0_10_64())));

            // Match the serializer with the one used in the sample data set
            var serializer = new DefaultSerializer();

            serializer.EnableAutomaticBackReferences();
            UseSerializer(serializer);

            InitializeStore();

            var after = store.Query(new DocumentTable("BuildingParts"), out _).Single();

            var expectedDocument = File.ReadAllText("Migrations\\BuiltIn\\HybridDb_1_x_x_to_2_x_x_Part1_Tests_3_Result.json");

            after["Document"].ShouldNotBe(null);
            after["Document"].ShouldBe(expectedDocument);
        }
Beispiel #3
0
        public void DisablesPreserveReferenceHandling()
        {
            serializer.EnableAutomaticBackReferences();

            var jObject = JObject.FromObject(new { String = "asger" }, CreateSerializer());

            jObject.ShouldNotContainKey("$id");
            jObject.ShouldContainKeyAndValue("String", "asger");
        }