public void AddChild_WithValidParameter_ChildrenPropertyHasOneItem() { var metadataRoot = new MetadataRoot("Default", 1); metadataRoot.AddChild("Child.Resource"); Assert.AreEqual ( 1, metadataRoot.Children.Count ); }
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 () ); }
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 AddChild_WithValidParameterTwice_ChildrenPropertyHasTwoItems() { var metadataRoot = new MetadataRoot("Default", 1); metadataRoot.AddChild("Child.Resource1"); metadataRoot.AddChild("Child.Resource2"); Assert.AreEqual(2, metadataRoot.Children.Count); }
/// <summary> /// Creates the metadata root. /// </summary> /// <param name="resourceName">Name of the resource.</param> /// <param name="metadataLayer">The metadata layer.</param> /// <returns>A <see cref="Pillar.Common.Metadata.IMetadata"/></returns> public IMetadata CreateMetadataRoot( string resourceName, MetadataLayer metadataLayer ) { if ( metadataLayer == null ) { throw new ArgumentNullException ( "metadataLayer" ); } var metadataRoot = new MetadataRoot ( resourceName, metadataLayer.Id ); _metadataRepository.MakePersistent ( metadataRoot ); return metadataRoot; }
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 (); } }
public void Constructor_WithCorrectParameters_CreatedMetadataNode() { var metadataRoot = new MetadataRoot ( "Default", 1 ); }
public void AddChild_WithWhiteSpacesResourceName_ThrowException() { var metadataRoot = new MetadataRoot("Default", 1); metadataRoot.AddChild(" "); }
private MetadataRoot CreateMetadataRoot(string resourceName, MetadataLayer metadataLayer) { using (IDocumentSession session = Store.OpenSession()) { var metadata = new MetadataRoot ( resourceName, metadataLayer.Id ); session.Store ( metadata ); session.SaveChanges(); return metadata; } }
public void FindChildMetadata_NoChildAdded_ReturnNull() { var metadataRoot = new MetadataRoot("Default", 1); Assert.IsNull(metadataRoot.FindChildMetadata("Child.Resource1")); }
public void FindChildMetadata_NoChildForSpecificResource_ReturnNull() { var metadataRoot = new MetadataRoot("Default", 1); metadataRoot.AddChild("Child.Resource1"); Assert.IsNull(metadataRoot.FindChildMetadata("Child.Resource2")); }
public void HasChild_NoChildAdded_ReturnFalse() { var metadataRoot = new MetadataRoot("Default", 1); Assert.IsFalse ( metadataRoot.HasChild ( "Child.Resource1" ) ); }
public void DestroyMetadataRoot_WithValidMetadataRoot_MetadataRootIsTransient() { bool isTransient = false; var metadataRepository = new Mock<IMetadataRepository>(); metadataRepository .Setup(a => a.MakeTransient(It.IsAny<MetadataRoot>())) .Callback(() => isTransient = true); var factory = new MetadataFactory(metadataRepository.Object); var metadataRoot = new MetadataRoot("MyResource", 1); factory.DestroyMetadataRoot(metadataRoot); Assert.IsTrue(isTransient); }
public void MetadataItems_Set_Succeed() { var metadataRoot = new MetadataRoot("Default", 1); metadataRoot.MetadataItems = new List<IMetadataItem> { new Mock<IMetadataItem> ().Object }; Assert.AreEqual ( 1, metadataRoot.MetadataItems.Count ); }
public void MetadataLayerId_Get_Succeed() { var metadataRoot = new MetadataRoot("Default", 1); Assert.AreEqual(1, metadataRoot.MetadataLayerId); }
public void MetadataItems_Add_Succeed() { var metadataRoot = new MetadataRoot("Default", 1); metadataRoot.MetadataItems.Add ( new Mock<IMetadataItem>().Object ); Assert.AreEqual ( 1, metadataRoot.MetadataItems.Count ); }
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")); }
public void HasChild_NoChildForSpecificResource_ReturnFalse() { var metadataRoot = new MetadataRoot("Default", 1); metadataRoot.AddChild ( "Child.Resource1" ); Assert.IsFalse(metadataRoot.HasChild("Child.Resource2")); }
public void Constructor_WithEmptyResourceName_ThrowException() { var metadataRoot = new MetadataRoot("", 1); }
public void AddChild_WithExistingResourceName_ThrowException() { var metadataRoot = new MetadataRoot("Default", 1); var child = metadataRoot.AddChild("Child.Resource"); metadataRoot.AddChild ("Child.Resource"); }
public void Constructor_WithNullResourceName_ThrowException() { var metadataRoot = new MetadataRoot ( null, 1 ); }
public void AddChild_WithNullResourceName_ThrowException() { var metadataRoot = new MetadataRoot ( "Default", 1 ); metadataRoot.AddChild ( null ); }
public void ResourceName_Get_Succeed() { var metadataRoot = new MetadataRoot("Default", 1); Assert.AreEqual("Default", metadataRoot.ResourceName); }
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) ); }