public void AreValidForReturnsFalseWhenExtensionListDoesNotMatchModelList()
        {
            // Setup
            const string Tenant     = "tenant";
            var          mockTenant = new Tenant {
                Name = Tenant, SubscriptionKind = Shared.Models.SubscriptionKind.Premium
            };

            var list = new List <UDFItem> {
                new UDFItem {
                    DefaultValue = "defaultvalue", Name = "name", Value = "value", Display = "display"
                }
            };
            var testModel = new TestExtension();

            var mockTenantStore = new Mock <ITenantStore>();

            mockTenantStore.Setup(m => m.GetTenant(Tenant)).Returns(mockTenant);

            var udfDictionary = new UDFDictionary(mockTenantStore.Object);

            // Act
            var result = udfDictionary.AreValidFor <TestExtension>(Tenant, list);

            // Assert
            Assert.IsFalse(result);
        }
        public void AreValidForReturnsTrueWhenExtensionListMatchesModelList()
        {
            // Setup
            const string Tenant     = "tenant";
            var          mockTenant = new Tenant {
                Name = Tenant, SubscriptionKind = Shared.Models.SubscriptionKind.Premium
            };

            var list = new List <UDFItem> {
                new UDFItem {
                    DefaultValue = "defaultvalue", Name = "name", Value = "value", Display = "display"
                }
            };
            var testModel = new TestExtension();

            var mockTenantStore = new Mock <ITenantStore>();

            mockTenantStore.Setup(m => m.GetTenant(Tenant)).Returns(mockTenant);

            var metadata = new UDFMetadata {
                Name = "custom", Display = "display"
            };

            var udfDictionary = new UDFDictionary(mockTenantStore.Object);
            IEnumerable <UDFMetadataError> errors = new List <UDFMetadataError>();

            udfDictionary.AddFieldFor <TestExtension>(Tenant, metadata, out errors);

            // Act
            var result = udfDictionary.AreValidFor <TestExtension>(Tenant, list);

            // Assert
            Assert.IsTrue(result);
        }
        public void AreValidForReturnsTrueWhenExtensionListMatchesModelList()
        {
            // Setup
            const string Tenant = "tenant";
            var mockTenant = new Tenant { Name = Tenant, SubscriptionKind = Shared.Models.SubscriptionKind.Premium };

            var list = new List<UDFItem> { new UDFItem { DefaultValue = "defaultvalue", Name = "name", Value = "value", Display = "display" } };
            var testModel = new TestExtension();

            var mockTenantStore = new Mock<ITenantStore>();
            mockTenantStore.Setup(m => m.GetTenant(Tenant)).Returns(mockTenant);

            var metadata = new UDFMetadata { Name = "custom", Display = "display" };

            var udfDictionary = new UDFDictionary(mockTenantStore.Object);
            IEnumerable<UDFMetadataError> errors = new List<UDFMetadataError>();
            udfDictionary.AddFieldFor<TestExtension>(Tenant, metadata, out errors);

            // Act
            var result = udfDictionary.AreValidFor<TestExtension>(Tenant, list);

            // Assert
            Assert.IsTrue(result);
        }
        public void AreValidForReturnsFalseWhenExtensionListDoesNotMatchModelList()
        {
            // Setup
            const string Tenant = "tenant";
            var mockTenant = new Tenant { Name = Tenant, SubscriptionKind = Shared.Models.SubscriptionKind.Premium };

            var list = new List<UDFItem> { new UDFItem { DefaultValue = "defaultvalue", Name = "name", Value = "value", Display = "display" } };
            var testModel = new TestExtension();

            var mockTenantStore = new Mock<ITenantStore>();
            mockTenantStore.Setup(m => m.GetTenant(Tenant)).Returns(mockTenant);

            var udfDictionary = new UDFDictionary(mockTenantStore.Object);

            // Act
            var result = udfDictionary.AreValidFor<TestExtension>(Tenant, list);

            // Assert
            Assert.IsFalse(result);
        }