public void ApplyAttributesToTest(ICustomAttributeProvider provider) { object[] allAttributes = provider.GetCustomAttributes(inherit: true); IEnumerable <IApplyToTest> applyToTestAttributes = OSPlatformTranslator.Translate(allAttributes).OfType <IApplyToTest>(); ApplyAttributesToTest(applyToTestAttributes); }
public void TranslateUnknownAttribute() { var unknown = new TestAttribute(); object attribute = OSPlatformTranslator.Translate(new[] { unknown }).Single(); Assert.That(attribute, Is.SameAs(unknown)); }
public void TranslateUnsupportedOSPlatformAttribute() { var unsupported = new UnsupportedOSPlatformAttribute("Linux"); var platform = (PlatformAttribute)OSPlatformTranslator.Translate(new[] { unsupported }).Single(); Assert.That(platform.Include, Is.Null, nameof(platform.Include)); Assert.That(platform.Exclude, Is.EqualTo("Linux"), nameof(platform.Exclude)); }
public void TranslateSupportedOSPlatformAttribute() { var supported = new SupportedOSPlatformAttribute("Windows7.0"); var platform = (PlatformAttribute)OSPlatformTranslator.Translate(new[] { supported }).Single(); Assert.That(platform.Include, Is.EqualTo("Windows7"), nameof(platform.Include)); Assert.That(platform.Exclude, Is.Null, nameof(platform.Exclude)); }
public void TranslatePlatformAttribute() { var original = new PlatformAttribute("Win"); var platform = (PlatformAttribute)OSPlatformTranslator.Translate(new[] { original }).Single(); Assert.That(platform.Include, Is.EqualTo(original.Include), nameof(platform.Include)); Assert.That(platform.Exclude, Is.EqualTo(original.Exclude), nameof(platform.Exclude)); }
public void TranslateMultipleOSPlatformAttributes() { var supported1 = new SupportedOSPlatformAttribute("Windows7.0"); var supported2 = new SupportedOSPlatformAttribute("Linux"); var osPlatforms = new OSPlatformAttribute[] { supported1, supported2 }; object[] attributes = OSPlatformTranslator.Translate(osPlatforms).ToArray(); Assert.That(attributes, Has.Length.EqualTo(1)); Assert.That(attributes[0], Is.InstanceOf <PlatformAttribute>()); var platform = (PlatformAttribute)attributes[0]; Assert.That(platform.Include, Is.EqualTo("Windows7,Linux"), nameof(platform.Include)); Assert.That(platform.Exclude, Is.Null, nameof(platform.Exclude)); }
public void TranslateMixedPlatformAndOSPlatformAttributes() { var supported1 = new SupportedOSPlatformAttribute("Windows"); var supported2 = new SupportedOSPlatformAttribute("Windows10"); var sourcePlatform = new PlatformAttribute("Win"); var sourceAttributes = new object[] { supported1, supported2, sourcePlatform }; object[] attributes = OSPlatformTranslator.Translate(sourceAttributes).ToArray(); Assert.That(attributes, Has.Length.EqualTo(1)); Assert.That(attributes[0], Is.InstanceOf <PlatformAttribute>()); var platform = (PlatformAttribute)attributes[0]; Assert.That(platform.Include, Is.EqualTo("Win,Windows10"), nameof(platform.Include)); Assert.That(platform.Exclude, Is.Null, nameof(platform.Exclude)); }
public string TranslatePlatform(string platformName) { return(OSPlatformTranslator.Translate(platformName)); }