Пример #1
0
        public void AddChild_WithValidParameterTwice_ChildrenPropertyHasTwoItems()
        {
            var metadataRoot = new MetadataRoot("Default", 1);
            metadataRoot.AddChild("Child.Resource1");
            metadataRoot.AddChild("Child.Resource2");

            Assert.AreEqual(2, metadataRoot.Children.Count);
        }
Пример #2
0
        public void AddChild_WithValidParameter_ChildrenPropertyHasOneItem()
        {
            var metadataRoot = new MetadataRoot("Default", 1);
            metadataRoot.AddChild("Child.Resource");

            Assert.AreEqual ( 1, metadataRoot.Children.Count );
        }
Пример #3
0
        public void MapToDto_ValidMetadata_Succeeds()
        {
            const string propertyWithMetadata = "PatientAddressType";

            Mapper.CreateMap<PatientAddress, PatientAddressDtoTest> ();

            Mapper.CreateMap<IMetadataItem, IMetadataItemDto>()
                .Include<ReadonlyMetadataItem, ReadonlyMetadataItemDto>()
                .Include<RequiredMetadataItem, RequiredMetadataItemDto>()
                .Include<HiddenMetadataItem, HiddenMetadataItemDto>()
                .Include<DisplayNameMetadataItem, DisplayNameMetadataItemDto>();

            var metaDataRepository = new Mock<IMetadataRepository> ();

            var metaDataRoot = new MetadataRoot ( typeof( PatientAddress ).FullName, 1 );

            metaDataRoot.AddChild ( propertyWithMetadata );

            metaDataRoot.Children[0].MetadataItems.Add ( new DisplayNameMetadataItem () );

            metaDataRepository.Setup ( m => m.GetMetadata ( typeof( PatientAddress ).FullName ) ).Returns ( metaDataRoot );

            var metadataMapper = new MetadataMapper ( metaDataRepository.Object );

            var metaDataDto = new MetadataDto ( typeof( PatientAddressDtoTest ).FullName );

            metadataMapper.MapToDto ( typeof(PatientAddress), typeof(PatientAddressDtoTest), metaDataDto );

            Assert.AreEqual ( 1, metaDataDto.Children.Count);
            Assert.AreEqual(1, metaDataDto.Children[0].MetadataItemDtos.Count);
            Assert.AreEqual ( typeof(DisplayNameMetadataItemDto), metaDataDto.Children[0].MetadataItemDtos[0].GetType () );
        }
Пример #4
0
        public void AddChild_WithValidResourceName_CreatedAMetadataNode()
        {
            var metadataRoot = new MetadataRoot("Default", 1);
            var child = metadataRoot.AddChild("Child.Resource");

            Assert.IsNotNull ( child );
            Assert.IsInstanceOfType ( child, typeof(MetadataNode) );
        }
        public void InitializeTestDataToRavenDb_Succeed()
        {
            var metadataLayer = new MetadataLayer ( "Default", 1 );
            using (var session = Store.OpenSession())
            {
                session.Store ( metadataLayer );
                session.SaveChanges ();
            }

            var metadataRoot = new MetadataRoot ( "Rem.Ria.PatientModule.Web.Common.PatientProfileDto", metadataLayer.Id );

            var firstNameNode = metadataRoot.AddChild ( "FirstName" );
            firstNameNode.MetadataItems = new List<IMetadataItem>
                                              {
                                                  new DisplayNameMetadataItem { Name = "The Patient's First Name" },
                                                  new ReadonlyMetadataItem { IsReadonly = true }
                                              };

            var middleNameNode = metadataRoot.AddChild ( "MiddleName" );
            middleNameNode.MetadataItems = new List<IMetadataItem>
                                               {
                                                   new HiddenMetadataItem { IsHidden = true }
                                               };

            var lastNameNode = metadataRoot.AddChild ( "LastName" );
            lastNameNode.MetadataItems = new List<IMetadataItem>
                                             {
                                                 new RequiredMetadataItem { IsRequired = true }
                                             };

            using ( var sesssion = Store.OpenSession() )
            {
                sesssion.Store ( metadataRoot );
                sesssion.SaveChanges ();
            }
        }
Пример #6
0
 public void AddChild_WithWhiteSpacesResourceName_ThrowException()
 {
     var metadataRoot = new MetadataRoot("Default", 1);
     metadataRoot.AddChild("  ");
 }
Пример #7
0
 public void AddChild_WithNullResourceName_ThrowException()
 {
     var metadataRoot = new MetadataRoot ( "Default", 1 );
     metadataRoot.AddChild ( null );
 }
Пример #8
0
 public void AddChild_WithExistingResourceName_ThrowException()
 {
     var metadataRoot = new MetadataRoot("Default", 1);
     var child = metadataRoot.AddChild("Child.Resource");
     metadataRoot.AddChild ("Child.Resource");
 }
Пример #9
0
        public void HasChild_SpecificResourceIsThere_ReturnTrue()
        {
            var metadataRoot = new MetadataRoot("Default", 1);
            metadataRoot.AddChild("Child.Resource1");
            metadataRoot.AddChild("Child.Resource2");

            Assert.IsTrue(metadataRoot.HasChild("Child.Resource2"));
        }
Пример #10
0
        public void HasChild_NoChildForSpecificResource_ReturnFalse()
        {
            var metadataRoot = new MetadataRoot("Default", 1);
            metadataRoot.AddChild ( "Child.Resource1" );

            Assert.IsFalse(metadataRoot.HasChild("Child.Resource2"));
        }
Пример #11
0
        public void FindChildMetadata_SpecificResourceIsThere_ReturnMetadataNode()
        {
            var metadataRoot = new MetadataRoot("Default", 1);
            metadataRoot.AddChild("Child.Resource1");
            metadataRoot.AddChild("Child.Resource2");

            var result = metadataRoot.FindChildMetadata ( "Child.Resource2" );

            Assert.IsNotNull ( result );
            Assert.IsInstanceOfType ( result, typeof(MetadataNode) );
        }
Пример #12
0
        public void FindChildMetadata_NoChildForSpecificResource_ReturnNull()
        {
            var metadataRoot = new MetadataRoot("Default", 1);
            metadataRoot.AddChild("Child.Resource1");

            Assert.IsNull(metadataRoot.FindChildMetadata("Child.Resource2"));
        }