예제 #1
0
        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();
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
 public void Constructor_WithNullMetadataService_ThrowArgumentNullException()
 {
     var metadataProxy = new MetadataProxy ( null, new Mock<IMetadataProvider> ().Object );
 }
예제 #6
0
 public void Constructor_ForChildMetadata_Succeed()
 {
     var metadataProxy = new MetadataProxy(_metadataService, _metadataProvider, "LastName");
 }
예제 #7
0
 public void Constructor_ForBaseMetadata_Succeed()
 {
     var metadataProxy = new MetadataProxy ( _metadataService, _metadataProvider );
 }
예제 #8
0
        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);
        }
예제 #9
0
        public void ReportInitialMetadata_MetadataChangedEventIsDefault_Succeed()
        {
            var metadataProxy = new MetadataProxy(_metadataService, _metadataProvider);

            metadataProxy.ReportInitialMetadata();
        }