예제 #1
0
        public void VerifyThatWriteXmlThrowsExceptionWhenTypeIsNull()
        {
            var relationGroup = new RelationGroup();

            // Type is not set

            using (var fs = new FileStream("test.xml", FileMode.Create))
            {
                using (var writer = XmlWriter.Create(fs, new XmlWriterSettings {
                    Indent = true
                }))
                {
                    Assert.That(() => relationGroup.WriteXml(writer),
                                Throws.TypeOf <SerializationException>()
                                .With.Message.EqualTo("The Type property of RelationGroup : may not be null"));
                }
            }

            // Source specification is not set
            var relationGroupType = new RelationGroupType();

            relationGroup.Type = relationGroupType;
            using (var fs = new FileStream("test.xml", FileMode.Create))
            {
                using (var writer = XmlWriter.Create(fs, new XmlWriterSettings {
                    Indent = true
                }))
                {
                    Assert.That(() => relationGroup.WriteXml(writer),
                                Throws.TypeOf <SerializationException>()
                                .With.Message.EqualTo("The SourceSpecification property of RelationGroup : may not be null"));
                }
            }

            // target specification is not set
            var sourceSpecification = new Specification();

            relationGroup.SourceSpecification = sourceSpecification;

            using (var fs = new FileStream("test.xml", FileMode.Create))
            {
                using (var writer = XmlWriter.Create(fs, new XmlWriterSettings {
                    Indent = true
                }))
                {
                    Assert.That(() => relationGroup.WriteXml(writer),
                                Throws.TypeOf <SerializationException>()
                                .With.Message.EqualTo("The TargetSpecification property of RelationGroup : may not be null"));
                }
            }
        }
        public void Verify_That_WriteXml_Throws_Exception_When_Type_Is_Null()
        {
            var relationGroup = new RelationGroup();

            // Type is not set
            using (var memoryStream = new MemoryStream())
            {
                using (var writer = XmlWriter.Create(memoryStream, new XmlWriterSettings {
                    Indent = true
                }))
                {
                    Assert.That(() => relationGroup.WriteXml(writer),
                                Throws.TypeOf <SerializationException>()
                                .With.Message.EqualTo("The Type property of RelationGroup : may not be null"));
                }
            }

            // Source specification is not set
            var relationGroupType = new RelationGroupType();

            relationGroup.Type = relationGroupType;
            using (var memoryStream = new MemoryStream())
            {
                using (var writer = XmlWriter.Create(memoryStream, new XmlWriterSettings {
                    Indent = true
                }))
                {
                    Assert.That(() => relationGroup.WriteXml(writer),
                                Throws.TypeOf <SerializationException>()
                                .With.Message.EqualTo("The SourceSpecification property of RelationGroup : may not be null"));
                }
            }

            // target specification is not set
            var sourceSpecification = new Specification();

            relationGroup.SourceSpecification = sourceSpecification;

            using (var memoryStream = new MemoryStream())
            {
                using (var writer = XmlWriter.Create(memoryStream, new XmlWriterSettings {
                    Indent = true
                }))
                {
                    Assert.That(() => relationGroup.WriteXml(writer),
                                Throws.TypeOf <SerializationException>()
                                .With.Message.EqualTo("The TargetSpecification property of RelationGroup : may not be null"));
                }
            }
        }