public void Constructor1_ShouldSetContractNamePropertyToEmptyString() { var attribute = new ImportAttribute(); Assert.Null(attribute.ContractName); Assert.Null(attribute.ContractType); }
public void Constructor1_ShouldSetContractNamePropertyToEmptyString() { var attribute = new ImportAttribute(); Assert.IsNull(attribute.ContractName); Assert.IsNull(attribute.ContractType); }
public void Constructor4_NullAsContractTypeArgument_ShouldSetContractNamePropertyToEmptyString() { var attribute = new ImportAttribute((string)null, (Type)null); Assert.Null(attribute.ContractName); Assert.Null(attribute.ContractType); }
public void Constructor4_NullAsContractTypeArgument_ShouldSetContractNamePropertyToEmptyString() { var attribute = new ImportAttribute((string)null, (Type)null); Assert.IsNull(attribute.ContractName); Assert.IsNull(attribute.ContractType); }
public void AsContractName_AndContractType_SetsContractNameAndType() { var builder = new ConventionBuilder(); builder.ForType <FooImpl>().ImportProperty((p) => p.IFooProperty, (c) => c.AsContractName("hey")); ImportAttribute importAtt = GetImportAttribute(builder); Assert.Equal("hey", importAtt.ContractName); }
public void AsContractName_AndContractType_ComputeContractNameFromType() { var builder = new ConventionBuilder(); builder.ForType <FooImpl>().ImportProperty((p) => p.IFooProperty, c => c.AsContractName(t => "Contract:" + t.FullName)); ImportAttribute importAtt = GetImportAttribute(builder); Assert.Equal("Contract:" + typeof(IFoo).FullName, importAtt.ContractName); }
public void Constructor2_ValueAsContractNameArgument_ShouldSetContractNameProperty() { var expectations = Expectations.GetContractNamesWithEmpty(); foreach (var e in expectations) { var attribute = new ImportAttribute(e); Assert.AreEqual(e, attribute.ContractName); } }
public void Constructor2_ValueAsContractNameArgument_ShouldSetContractNameProperty() { var expectations = Expectations.GetContractNamesWithEmpty(); foreach (var e in expectations) { var attribute = new ImportAttribute(e); Assert.Equal(e, attribute.ContractName); } }
public void AllowDefault_SetsAllowDefaultProperty() { var builder = new ConventionBuilder(); builder.ForType <FooImpl>().ImportProperty((p) => p.IFooProperty, (c) => c.AllowDefault()); ImportAttribute importAtt = GetImportAttribute(builder); Assert.True(importAtt.AllowDefault); Assert.Null(importAtt.ContractName); }
public void AsContractName_SetsContractName() { var builder = new ConventionBuilder(); builder.ForType <FooImpl>().ImportProperty((p) => p.IFooProperty, (c) => c.AsContractName("hey")); ImportAttribute importAtt = GetImportAttribute(builder); Assert.AreEqual("hey", importAtt.ContractName); Assert.IsFalse(importAtt.AllowDefault); }
public void AsContractName_AndContractType_SetsContractNameAndType() { var builder = new ImportBuilder(); builder.AsContractName("hey"); builder.AsContractType(typeof(IFoo)); ImportAttribute importAtt = GetImportAttribute(builder); Assert.AreEqual("hey", importAtt.ContractName); Assert.AreEqual(typeof(IFoo), importAtt.ContractType); }
public void AllowRecomposition_ValueAsValueArgument_ShouldSetProperty() { var expectations = Expectations.GetBooleans(); var attribute = new ImportAttribute(); foreach (var e in expectations) { attribute.AllowRecomposition = e; Assert.Equal(e, attribute.AllowRecomposition); } }
public void AllowRecomposition_SetsAllowRecompositionProperty() { var builder = new ImportBuilder(); builder.AllowRecomposition(); ImportAttribute importAtt = GetImportAttribute(builder); Assert.IsTrue(importAtt.AllowRecomposition); Assert.IsNull(importAtt.ContractType); Assert.IsNull(importAtt.ContractName); }
public void AsContractName_SetsContractName() { var builder = new ImportBuilder(); builder.AsContractName("hey"); ImportAttribute importAtt = GetImportAttribute(builder); Assert.AreEqual("hey", importAtt.ContractName); Assert.IsFalse(importAtt.AllowDefault); Assert.IsFalse(importAtt.AllowRecomposition); Assert.IsNull(importAtt.ContractType); }
public void RequiredCreationPolicy_SetsRequiredCreationPolicyProperty() { var builder = new ImportBuilder(); builder.RequiredCreationPolicy(CreationPolicy.NonShared); ImportAttribute importAtt = GetImportAttribute(builder); Assert.AreEqual(CreationPolicy.NonShared, importAtt.RequiredCreationPolicy); Assert.IsFalse(importAtt.AllowDefault); Assert.IsFalse(importAtt.AllowRecomposition); Assert.IsNull(importAtt.ContractType); Assert.IsNull(importAtt.ContractName); }
/// <summary> /// 根据 <see cref="ImportAttribute" />,返回导入插件的描述信息 /// </summary> /// <param name="import"> 导入描述 </param> /// <param name="memberType"> 属性或字段的类型 </param> /// <returns> </returns> private static ImportDefinitionImpl GetImportDefinition(ImportAttribute import, Type memberType) { if (import == null) { return null; } var name = import.ContractName ?? AttributedModelServices.GetTypeIdentity(import.ContractType ?? memberType); return new ImportDefinitionImpl( GetExpression(name, import.ContractType ?? memberType), import.ContractName, ImportCardinality.ZeroOrOne, false, true, null) { MemberType = memberType, ExportedType = memberType }; }
public void Constructor1_ShouldSetAllowDefaultPropertyToFalse() { var attribute = new ImportAttribute(); Assert.False(attribute.AllowDefault); }
public void AllowRecomposition_ValueAsValueArgument_ShouldSetProperty() { var expectations = Expectations.GetBooleans(); var attribute = new ImportAttribute(); foreach (var e in expectations) { attribute.AllowRecomposition = e; Assert.AreEqual(e, attribute.AllowRecomposition); } }
public void Constructor2_ShouldSetAllowDefaultPropertyToFalse() { var attribute = new ImportAttribute("ContractName"); Assert.IsFalse(attribute.AllowDefault); }
public void Constructor3_ShouldSetAllowDefaultPropertyToFalse() { var attribute = new ImportAttribute(typeof(String)); Assert.IsFalse(attribute.AllowDefault); }
public void Constructor3_ShouldSetAllowRecompositionPropertyToFalse() { var attribute = new ImportAttribute(typeof(string)); Assert.False(attribute.AllowRecomposition); }
public void Constructor2_ShouldSetAllowRecompositionPropertyToFalse() { var attribute = new ImportAttribute("ContractName"); Assert.False(attribute.AllowRecomposition); }
public void Constructor1_ShouldSetAllowRecompositionPropertyToFalse() { var attribute = new ImportAttribute(); Assert.IsFalse(attribute.AllowRecomposition); }
public void Constructor2_ShouldSetAllowRecompositionPropertyToFalse() { var attribute = new ImportAttribute("ContractName"); Assert.IsFalse(attribute.AllowRecomposition); }