예제 #1
0
 public void CanDisplaySimpleConstraints_Unresolved()
 {
     Assert.That(Is.EqualTo(5).ToString(), Is.EqualTo("<equal 5>"));
     Assert.That(Has.Property("X").ToString(), Is.EqualTo("<propertyexists X>"));
     Assert.That(Has.Attribute(typeof(TestAttribute)).ToString(),
                 Is.EqualTo("<attributeexists NUnit.Framework.TestAttribute>"));
 }
예제 #2
0
 public void SetUp()
 {
     parseTree       = @"<attribute NUnit.Framework.TestFixtureAttribute <property Description <not <null>>>>";
     staticSyntax    = Has.Attribute(typeof(TestFixtureAttribute)).Property("Description").Not.Null;
     inheritedSyntax = Helper().Attribute(typeof(TestFixtureAttribute)).Property("Description").Not.Null;
     builderSyntax   = Builder().Attribute(typeof(TestFixtureAttribute)).Property("Description").Not.Null;
 }
 public void CheckExtensionAttribute()
 {
     Assert.That(typeof(TeamCityEventListener),
                 Has.Attribute <ExtensionAttribute>()
                 .With.Property("EngineVersion").EqualTo("3.4")
                 .And.Property("Enabled").EqualTo(false));
 }
 public void TestResultWriterCheckExtensionPropertyAttribute()
 {
     Assert.That(typeof(TM4JTestResultWriter),
                 Has.Attribute <ExtensionPropertyAttribute>()
                 .With.Property("Name").EqualTo("Format")
                 .And.Property("Value").EqualTo("tm4j"));
 }
예제 #5
0
 public void CheckExtensionPropertyAttribute()
 {
     Assert.That(typeof(NUnit2XmlResultWriter),
                 Has.Attribute <ExtensionPropertyAttribute>()
                 .With.Property("Name").EqualTo("Format")
                 .And.Property("Value").EqualTo("nunit2"));
 }
예제 #6
0
        public void whenever_a_deprecated_currency_is_obtained_an_event_is_raised()
        {
            bool            called   = false;
            CurrencyIsoCode obsolete = CurrencyIsoCode.XXX;
            EventHandler <ObsoleteCurrencyEventArgs> callback = (sender, e) =>
            {
                called   = true;
                obsolete = e.Code;
            };

            try
            {
                Currency.ObsoleteCurrency += callback;
                Currency.Get("EEK");

                Assert.That(called, Is.True);
                Assert.That(obsolete.ToString(), Is.EqualTo("EEK"));
                Assert.That(obsolete.AsAttributeProvider(), Has.Attribute <ObsoleteAttribute>());
            }
            // DO unsubscribe from global events whenever listening isnot needed anymore
            finally
            {
                Currency.ObsoleteCurrency -= callback;
            }
        }
예제 #7
0
        public void RequiredAttributePresentOnProperty(string prop)
        {
            var pinfo = _task.GetType()?.GetProperty(prop);

            Assert.NotNull(pinfo);
            Assert.That(pinfo, Has.Attribute <RequiredAttribute>());
        }
예제 #8
0
 public void CheckExtensionPropertyAttribute()
 {
     Assert.That(typeof(NUnitProjectLoader),
                 Has.Attribute <ExtensionPropertyAttribute>()
                 .With.Property("Name").EqualTo("FileExtension")
                 .And.Property("Value").EqualTo(".nunit"));
 }
예제 #9
0
 public void SetUp()
 {
     parseTree       = "<attributeexists NUnit.Framework.TestFixtureAttribute>";
     staticSyntax    = Has.Attribute(typeof(TestFixtureAttribute));
     inheritedSyntax = Helper().Attribute(typeof(TestFixtureAttribute));
     builderSyntax   = Builder().Attribute(typeof(TestFixtureAttribute));
 }
예제 #10
0
        public void IsSerializable()
        {
            Assert.That(typeof(ConversationException), Has.Attribute <SerializableAttribute>());
            var e = new ConversationException("a message");

            Assert.That(e, Is.BinarySerializable);
        }
예제 #11
0
 public void DisplayPrefixConstraints_Unresolved()
 {
     Assert.That(Is.Not.EqualTo(5).ToString(), Is.EqualTo("<unresolved <equal 5>>"));
     Assert.That(Is.Not.All.EqualTo(5).ToString(), Is.EqualTo("<unresolved <equal 5>>"));
     Assert.That(Has.Property("X").EqualTo(5).ToString(), Is.EqualTo("<unresolved <equal 5>>"));
     Assert.That(Has.Attribute(typeof(TestAttribute)).With.Property("Description").EqualTo("smoke").ToString(),
                 Is.EqualTo("<unresolved <equal \"smoke\">>"));
 }
예제 #12
0
        public void CanDisplaySimpleConstraints_Resolved()
        {
            IResolveConstraint constraint = Is.EqualTo(5);

            Assert.That(constraint.Resolve().ToString(), Is.EqualTo("<equal 5>"));
            constraint = Has.Property("X");
            Assert.That(constraint.Resolve().ToString(), Is.EqualTo("<propertyexists X>"));
            constraint = Has.Attribute(typeof(TestAttribute)).With.Property("Description").EqualTo("smoke");
            Assert.That(constraint.Resolve().ToString(),
                        Is.EqualTo("<attribute NUnit.Framework.TestAttribute <property Description <equal \"smoke\">>>"));
        }
        public void DirectoryNames_Configuration()
        {
            PropertyInfo property = typeof(XmlDocCommentReaderSettings).GetProperty("DirectoryNames");

            Assert.That(
                property,
                Has.Attribute <ConfigurationPropertyAttribute>()
                .With.Property("Name").EqualTo("XmlDocCommentDirectories")
                .And.Property("IsRequired").True);

            Assert.That(
                property,
                Has.Attribute <ConfigurationCollectionAttribute>()
                .With.Property("ItemType").EqualTo(typeof(XmlDocCommentDirectoryElementCollection))
                .And.Property("AddItemName").EqualTo("Directory"));
        }
예제 #14
0
        public void NUnit3_AssertThat_SingleCustomAttributeOfSpecifiedTypeIsAppliedToTheInspectedAssembly()
        {
            // Arrange
            AssemblyService service = new();

            // Act
            Assembly assembly = service.GetAssembly();

            // Assert
            CLSCompliantAttribute?attribute = assembly.GetCustomAttribute <CLSCompliantAttribute>();

            Assert.IsNotNull(attribute);
            Debug.Assert(attribute is not null);
            Assert.IsTrue(attribute.IsCompliant);

            // ConstraintBasedAssertModel
            Assert.That(assembly,
                        Has.Attribute <CLSCompliantAttribute>()
                        .With.Property(nameof(CLSCompliantAttribute.IsCompliant)).True);
        }
예제 #15
0
 public void AttributeTestPropertyValueOnMethodInfo()
 {
     Assert.That(
         GetType().GetMethod("AttributeTestPropertyValueOnMethodInfo"),
         Has.Attribute(typeof(DescriptionAttribute)).Property("Properties").Property("Keys").Contains("Description"));
 }
예제 #16
0
        public void AllValidatorsAreSerializable()
        {
            var implementors = GetValidatorImplementors();

            implementors.ForEach(x => Assert.That(x, Has.Attribute <SerializableAttribute>()));
        }
 public void AttributeTestPropertyValueOnMethodInfo()
 {
     Assert.That(
         System.Reflection.MethodInfo.GetCurrentMethod(),
         Has.Attribute(typeof(DescriptionAttribute)).Property("Description").EqualTo("my description"));
 }
 /// <summary>
 /// Returns a new AttributeConstraint checking for the
 /// presence of a particular attribute on an object.
 /// </summary>
 public ResolvableConstraintExpression Attribute(Type expectedType)
 {
     return(Has.Attribute(expectedType));
 }
 public void OrOperatorCanCombineConstraintAndResolvableConstraintExpression()
 {
     Assert.That(GetType(), Is.EqualTo(7) | Has.Attribute(typeof(TestFixtureAttribute)));
 }
 public void OrOperatorCanCombineTwoResolvableConstraintExpressions()
 {
     Assert.That(GetType(), Has.Attribute(typeof(TestFixtureAttribute)) | Has.Attribute(typeof(TestCaseAttribute)));
 }
 public void AndOperatorCanCombineResolvableConstraintExpressionAndConstraint()
 {
     Assert.That(GetType(), Has.Attribute(typeof(DescriptionAttribute)) & Is.EqualTo(typeof(AndOperatorOverride)));
 }
 public void AndOperatorCanCombineTwoResolvableConstraintExpressions()
 {
     Assert.That(GetType(), Has.Attribute(typeof(TestFixtureAttribute)) & Has.Attribute(typeof(DescriptionAttribute)));
 }
 public void NotOperatorCanApplyToResolvableConstraintExpression()
 {
     Assert.That(GetType(), !Has.Attribute(typeof(DescriptionAttribute)));
 }
예제 #24
0
 public void CheckExtensionAttribute()
 {
     Assert.That(typeof(NUnitProjectLoader),
                 Has.Attribute <ExtensionAttribute>());
 }
예제 #25
0
 public void LazyFieldInterceptorMarkedAsSerializable()
 {
     Assert.That(typeof(DefaultDynamicLazyFieldInterceptor), Has.Attribute <SerializableAttribute>());
 }
 public void CheckExtensionAttribute()
 {
     Assert.That(typeof(VisualStudioProjectLoader),
                 Has.Attribute <ExtensionAttribute>());
 }
 public void IsSerializable()
 {
     Assert.That(typeof(ValidatorEngine), Has.Attribute <SerializableAttribute>());
 }
 public void AllGettersAreMarkedAsSerializable(System.Type concreteAccessor)
 {
     Assert.That(concreteAccessor, Has.Attribute <SerializableAttribute>());
 }