Example #1
0
        internal void ContractTypeSerialization(
            ContractTypeSerializer serializer,
            UpdateCertificationObjects original,
            JObject json,
            UpdateCertificationObjects deserialized
            )
        {
            GIVEN["a contract type serializer"] = () => serializer = CreateSerializer();

            WHEN["serializing a message"] = () => json = SerializeJson(
                serializer,
                original = new UpdateCertificationObjectsBuilder {
                Objects =
                {
                    new CertificationObjectDOBuilder {
                        ID = ID.NewID(), Name = "Object 1", Type = ObjectType.Crop, TypeRef = ID.NewID().ToRef <IObjectType>()
                    }.Build(),
                    new CertificationObjectDOBuilder {
                        ID = ID.NewID(), Name = "Object 2", Type = ObjectType.Livestock, TypeRef = ID.NewID().ToRef <IObjectType>()
                    }.Build()
                },
                Service = new ServiceCode("SERV1234")
            }.Build());
            THEN["the serialized JSON equals the expected"] = () => json.Should().BeEquivalentTo(original.GetExpectedJson());

            WHEN["deserializing the JSON"] = () => deserialized = DeserializeJson <UpdateCertificationObjects>(serializer, json);
            THEN["the deserialized JSON equals the original"] = () => deserialized.Should().BeEquivalentTo(original);

            GIVEN["an object where a property of polymorphic contract type is null"] = () => original = new UpdateCertificationObjectsBuilder();
            WHEN["serializing and deserializing it"] = () => {
                json         = SerializeJson(serializer, original);
                deserialized = DeserializeJson <UpdateCertificationObjects>(serializer, json);
            };
            THEN["its value is still null"] = () => deserialized.Service.Should().BeNull();
        }
            public UpdateCertificationObjects Mutate(Action <UpdateCertificationObjectsBuilder> mutation)
            {
                UpdateCertificationObjectsBuilder mutator = new UpdateCertificationObjectsBuilder(this);

                mutation(mutator);
                return(mutator);
            }
        internal void ContractTypeSerialization(
            ContractTypeSerializer serializer,
            UpdateCertificationObjects original,
            BsonDocument bson,
            UpdateCertificationObjects deserialized
            )
        {
            GIVEN["a contract type serializer"] = () => serializer = CreateSerializer();

            WHEN["serializing a message"] = () => bson = SerializeBson(
                serializer,
                original = new UpdateCertificationObjectsBuilder {
                Objects =
                {
                    new CertificationObjectDOBuilder {
                        ID = ID.NewID(), Name = "Object 1"
                    }.Build(),
                    new CertificationObjectDOBuilder {
                        ID = ID.NewID(), Name = "Object 2"
                    }.Build()
                },
                Service = new ServiceCode("SERV1324")
            }.Build());
            THEN["the serialized BSON equals the expected"] = () => bson.Should().BeEqivalentTo(original.GetExpectedBson());

            WHEN["deserializing the BSON"] = () => deserialized = DeserializeBson <UpdateCertificationObjects>(serializer, bson);
            THEN["the deserialized BSON equals the original"] = () => deserialized.Should().BeEquivalentTo(original);

            GIVEN["an object where a property of polymorphic contract type is null"] = () => original = new UpdateCertificationObjectsBuilder();
            WHEN["serializing and deserializing it"] = () => {
                bson         = SerializeBson(serializer, original);
                deserialized = DeserializeBson <UpdateCertificationObjects>(serializer, bson);
            };
            THEN["its value is still null"] = () => deserialized.Service.Should().BeNull();
        }
 public UpdateCertificationObjects(UpdateCertificationObjectsBuilder source) : base()
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     Objects = source.Objects.ToImmutable();
     Service = source.Service;
 }