コード例 #1
0
        public void stringNotNullOrEmpty_Test()
        {
            var testor = new TestorTheBarbarian();

            //comment line below to fail test
            testor.EquipWeapon("Fists of Fury");

            //Nunit Classic Model
            Assert.IsNotNullOrEmpty(testor.ActiveWeapon);
            // --> Expected: not null or empty string   But was: null

            //NUnit Constraint model
            Assert.That(testor.ActiveWeapon, Is.Not.Null.Or.Empty);
            // --> Expected: not null or empty string   But was: null

            //shouldly syntax
            testor.ActiveWeapon.ShouldNotBeNullOrEmpty();
            // --> testor.ActiveWeapon should not be null or empty
        }
コード例 #2
0
        public void stringNotNullOrEmpty_Test()
        {
            var testor = new TestorTheBarbarian();

            //comment line below to fail test
            testor.EquipWeapon("Fists of Fury");

            //Nunit Classic Model
            Assert.IsNotNullOrEmpty(testor.ActiveWeapon);
            // --> Expected: not null or empty string   But was: null

            //NUnit Constraint model
            Assert.That(testor.ActiveWeapon, Is.Not.Null.Or.Empty);
            // --> Expected: not null or empty string   But was: null

            //FluentAssertions syntax
            testor.ActiveWeapon.Should().NotBeNullOrEmpty();
            // --> Result Message:	Expected string not to be <null> or empty, but found <null>.

            //with optional description
            testor.ActiveWeapon.Should().NotBeNullOrEmpty(because: "weapon has been equipped");
            // --> Result Message:	Expected string not to be <null> or empty because weapon has been equipped, but found <null>.
        }
コード例 #3
0
        public void stringNotNullOrEmpty_Test()
        {
            var testor = new TestorTheBarbarian();
            //comment line below to fail test
            testor.EquipWeapon("Fists of Fury");

            //Nunit Classic Model
            Assert.IsNotNullOrEmpty(testor.ActiveWeapon);
            // --> Expected: not null or empty string   But was: null

            //NUnit Constraint model
            Assert.That(testor.ActiveWeapon, Is.Not.Null.Or.Empty);
            // --> Expected: not null or empty string   But was: null

            //shouldly syntax
            testor.ActiveWeapon.ShouldNotBeNullOrEmpty();
            // --> testor.ActiveWeapon should not be null or empty
        }
コード例 #4
0
        public void stringNotNullOrEmpty_Test()
        {
            var testor = new TestorTheBarbarian();
            //comment line below to fail test
            testor.EquipWeapon("Fists of Fury");

            //Nunit Classic Model
            Assert.IsNotNullOrEmpty(testor.ActiveWeapon);
            // --> Expected: not null or empty string   But was: null

            //NUnit Constraint model
            Assert.That(testor.ActiveWeapon, Is.Not.Null.Or.Empty);
            // --> Expected: not null or empty string   But was: null

            //FluentAssertions syntax
            testor.ActiveWeapon.Should().NotBeNullOrEmpty();
            // --> Result Message:	Expected string not to be <null> or empty, but found <null>.

            //with optional description
            testor.ActiveWeapon.Should().NotBeNullOrEmpty(because:"weapon has been equipped");
            // --> Result Message:	Expected string not to be <null> or empty because weapon has been equipped, but found <null>.
        }