private void AttachMetaData(IMetadataProvider metadataProvider, string metadataToApply) { var metadataService = IoC.CurrentContainer.Resolve <IMetadataService>(); _metadataProxy = string.IsNullOrWhiteSpace(metadataToApply) ? new MetadataProxy(metadataService, metadataProvider) : new MetadataProxy(metadataService, metadataProvider, metadataToApply); _metadataProxy.MetadataChanged += MetadataProxyMetadataChanged; _metadataProxy.ReportInitialMetadata(); }
public void ReportInitialMetadata_AddAndRemoveMetadataItemDtos_MetadataItemDtoChangedListAreNewCustomizedAndMergedWithDefaultAndCustomized() { var metadataChangeList = new List<MetadataChangedEventArgs>(); var metadataProxy = new MetadataProxy(_metadataService, _metadataProvider, "LastName"); var metadata = _metadataProvider.MetadataDto.GetChildMetadata ( "LastName" ); metadata.RemoveMetadataItem<HiddenMetadataItemDto> (); metadata.AddMetadataItem ( new RequiredMetadataItemDto { IsRequired = true } ); metadata.AddMetadataItem ( new HiddenMetadataItemDto { IsHidden = false } ); metadataProxy.MetadataChanged += (sender, args) => metadataChangeList.Add(args); metadataProxy.ReportInitialMetadata(); AssertMetadataItemDtoChangedListAreNewCustomizedAndMergedWithDefaultAndCustomized(metadataChangeList); }
public void ReportInitialMetadata_InvokeTwice_TheSecondTimeWillAlsoFireMetadataChangedEvent() { bool isMetadataChanged = false; var metadataProxy = new MetadataProxy(_metadataService, _metadataProvider, "LastName"); metadataProxy.MetadataChanged += (sender, args) => { isMetadataChanged = true; }; metadataProxy.ReportInitialMetadata(); isMetadataChanged = false; metadataProxy.ReportInitialMetadata (); Assert.IsTrue(isMetadataChanged); }
public void ReportInitialMetadata_ChangeMetadataDtoFromIMetadataProvider_MetadataItemDtoChangedListAreNewCustomizedAndMergedWithDefault() { var metadataChangeList = new List<MetadataChangedEventArgs> (); var metadataProxy = new MetadataProxy(_metadataService, _metadataProvider, "LastName"); _metadataProvider.MetadataDto = CreateNewCustomizedMetadataDto(); metadataProxy.MetadataChanged += (sender, args) => metadataChangeList.Add(args); metadataProxy.ReportInitialMetadata (); AssertMetadataItemDtoChangedListAreNewCustomizedAndMergedWithDefault (metadataChangeList); }
public void Constructor_WithNullMetadataService_ThrowArgumentNullException() { var metadataProxy = new MetadataProxy ( null, new Mock<IMetadataProvider> ().Object ); }
public void Constructor_ForChildMetadata_Succeed() { var metadataProxy = new MetadataProxy(_metadataService, _metadataProvider, "LastName"); }
public void Constructor_ForBaseMetadata_Succeed() { var metadataProxy = new MetadataProxy ( _metadataService, _metadataProvider ); }
public void ReportInitialMetadata_WithMetadataChangedEvent_FireMetadataChangedEvent() { bool isMetadataChanged = false; var metadataProxy = new MetadataProxy(_metadataService, _metadataProvider, "LastName"); metadataProxy.MetadataChanged += (sender, args) => { isMetadataChanged = true; }; metadataProxy.ReportInitialMetadata(); Assert.IsTrue(isMetadataChanged); }
public void ReportInitialMetadata_MetadataChangedEventIsDefault_Succeed() { var metadataProxy = new MetadataProxy(_metadataService, _metadataProvider); metadataProxy.ReportInitialMetadata(); }