NUnit.Framework.Assert.Fail()

Here are the examples of the csharp api class NUnit.Framework.Assert.Fail() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

1. Example

Project: ContinuousTests
Source File: FailFixture.cs
View license
[Test]
		public void FailInheritsFromSystemException() 
		{
			try 
			{
				Assert.Fail();
			} 
			catch (System.Exception) 
			{
				return;
			}

			throw new AssertionException("fail"); // You can't call fail() here
		}

2. Example

View license
[Test] public void Fail3() { Assert.Fail(); }

3. Example

View license
[Test]
		public void Fail()
		{
			Assert.Fail();
		}

4. Example

View license
[Test]
		public void Fail()
		{
			Assert.Fail();
		}

5. Example

View license
[Test] public void Fail2() { Assert.Fail(); }

6. Example

View license
[Test] public void Fail1() { Assert.Fail(); }

7. Example

Project: ContinuousTests
Source File: FailFixture.cs
View license
[Test]
		public void FailInheritsFromSystemException() 
		{
			try 
			{
				Assert.Fail();
			} 
			catch (System.Exception) 
			{
				return;
			}

			throw new AssertionException("fail"); // You can't call fail() here
		}

8. Example

View license
[Test] public void Fail3() { Assert.Fail(); }

9. Example

View license
[Test]
		public void Fail()
		{
			Assert.Fail();
		}

10. Example

View license
[Test] public void Fail3() { Assert.Fail(); }

11. Example

View license
[Test] public void Fail1() { Assert.Fail(); }

12. Example

View license
[Test] public void Fail2() { Assert.Fail(); }

13. Example

View license
[Test] public void Fail2() { Assert.Fail(); }

14. Example

View license
[Test] public void Fail1() { Assert.Fail(); }

15. Example

Project: ContinuousTests
Source File: FailFixture.cs
View license
[Test]
		public void FailInheritsFromSystemException() 
		{
			try 
			{
				Assert.Fail();
			} 
			catch (System.Exception) 
			{
				return;
			}

			throw new AssertionException("fail"); // You can't call fail() here
		}

16. Example

View license
[Test()]
		[ExpectedException(typeof(SQLiteException))]
		public void PrimaryKeyViolationTest()
		{
			using(var con = new SQLiteConnection("Data Source=:memory:"))
				using(var cmd = con.CreateCommand())
				{
					con.Open();
					cmd.CommandText = "CREATE TABLE test (id INTEGER PRIMARY KEY ON CONFLICT FAIL);";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "insert into test values(1);";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "insert into test values(1);";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "insert into test values(1);";
					Assert.Fail();
				}
		}

17. Example

View license
[Test()]
		[ExpectedException(typeof(SQLiteException))]
		public void CheckViolationTest()
		{
			using(var con = new SQLiteConnection("Data Source=:memory:"))
				using(var cmd = con.CreateCommand())
				{
					con.Open();
					cmd.CommandText = "CREATE TABLE test (id INTEGER CHECK (id <> 2));";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "insert into test values(2);";
					cmd.ExecuteNonQuery();
					Assert.Fail();
				}
		}

18. Example

View license
[Test()]
		[ExpectedException(typeof(SQLiteException))]
		public void NotNullViolationTest()
		{
			using(var con = new SQLiteConnection("Data Source=:memory:"))
				using(var cmd = con.CreateCommand())
				{
					con.Open();
					cmd.CommandText = "CREATE TABLE test (id INTEGER NOT NULL);";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "insert into test values(null);";
					cmd.ExecuteNonQuery();
					Assert.Fail();
				}
		}

19. Example

View license
[Test()]
		[ExpectedException(typeof(SQLiteException))]
		public void ViolateCheckTableConstraintTest()
		{	
			using(var con = new SQLiteConnection("Data Source=:memory:"))
				using(var cmd = con.CreateCommand())
				{
					con.Open();
					cmd.CommandText = "CREATE TABLE People (id INTEGER NOT NULL, name VARCHAR(255) NULL, CHECK (ID <> 0));";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "INSERT INTO People VALUES(0, 'test')";
					cmd.ExecuteNonQuery();
					Assert.Fail();
				}
		}

20. Example

View license
[Test()]
		[ExpectedException(typeof(SQLiteException))]
		public void UniqueViolationTest()
		{
			using(var con = new SQLiteConnection("Data Source=:memory:"))
				using(var cmd = con.CreateCommand())
				{
					con.Open();
					cmd.CommandText = "CREATE TABLE test (id INTEGER UNIQUE);";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "insert into test values(100);";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "insert into test values(100);";
					cmd.ExecuteNonQuery();
					Assert.Fail();
				}
		}

21. Example

View license
[Test()]
		[ExpectedException(typeof(SQLiteException))]
		public void ViolateUniqueTableConstraintTest()
		{	
			using(var con = new SQLiteConnection("Data Source=:memory:"))
				using(var cmd = con.CreateCommand())
				{
					con.Open();
					cmd.CommandText = "CREATE TABLE People (id INTEGER NOT NULL, name VARCHAR(255) NULL, UNIQUE (ID));";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "INSERT INTO People VALUES(1, 'test')";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "INSERT INTO People VALUES(1, 'test')";
					cmd.ExecuteNonQuery();
					Assert.Fail();
				}
		}

22. Example

View license
[Test()]
		[ExpectedException(typeof(SQLiteException))]
		public void ViolatePrimaryKeyTableConstraintTest()
		{	
			using(var con = new SQLiteConnection("Data Source=:memory:"))
				using(var cmd = con.CreateCommand())
				{
					con.Open();
					cmd.CommandText = "CREATE TABLE People (id INTEGER NOT NULL, name VARCHAR(255) NULL, PRIMARY KEY (ID));";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "INSERT INTO People VALUES(1, 'test')";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "INSERT INTO People VALUES(1, 'test')";
					cmd.ExecuteNonQuery();
					Assert.Fail();
				}
		}

23. Example

View license
[Test]
		[ExpectedException(typeof(SQLiteException))]
		public void BreakForeignKeyConstraintTest()
		{
			using(var con = new SQLiteConnection("Data Source=:memory:"))
				using(var cmd = con.CreateCommand())
				{
					con.Open();
					cmd.CommandText = "PRAGMA foreign_keys = ON;";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "CREATE TABLE People (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255) NOT NULL, double DECIMAL NOT NULL, testtext VARCHAR(8000) NOT NULL, testguid GUID NOT NULL);";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "CREATE TABLE Shirts (id INTEGER PRIMARY KEY AUTOINCREMENT, personid INTEGER NOT NULL, color VARCHAR(8000) NOT NULL, size CHAR(1) NOT NULL, FOREIGN KEY (personid) REFERENCES People(id));";
					cmd.ExecuteNonQuery();
					cmd.CommandText = "INSERT INTO Shirts VALUES(NULL, 15,'MLO58XON2EZ','L');";
					cmd.ExecuteNonQuery();
					Assert.Fail();
				}
		}

24. Example

Project: Piglet
Source File: ParserConfigurationTest.cs
View license
[Test]
        public void TestShiftReduceConflictWithAccept()
        {
            // For certain grammars you can produce this stuff. It is not a real world case
            // but the exception should still be helpful

            // Here's how this retarded grammar looks
            // a := a | b | c
            // b := "b" 
            // c := "c"
            //
            try
            {
                var configurator = ParserFactory.Configure<int>();
                var a = configurator.CreateNonTerminal();
                a.DebugName = "a";
                var b = configurator.CreateNonTerminal();
                b.DebugName = "b";
                var c = configurator.CreateNonTerminal();
                c.DebugName = "c";

                a.AddProduction(a);
                a.AddProduction(b);
                a.AddProduction(c);

                b.AddProduction("b");

                c.AddProduction("c");

                configurator.CreateParser();

                Assert.Fail();
            }
            catch (ShiftReduceConflictException<int>)
            {
                // There is no real need to check this exception. It says something
                // about wanting to reduce on the $. We are cool that this
                // sillyness doesn't run on forever.
            }
        }

25. Example

Project: Piglet
Source File: ParserConfigurationTest.cs
View license
[Test]
        public void TestRetardedCyclicGrammar()
        {
            try
            {
                var configurator = ParserFactory.Configure<byte>();
                var t = configurator.CreateNonTerminal();
                t.AddProduction(t);
                configurator.CreateParser();
                Assert.Fail();
            }
            catch (ShiftReduceConflictException<byte>)
            {
                // There is no real need to check this exception. It says something
                // about wanting to shift the augmented start symbol. We are cool that this
                // sillyness doesn't run on forever.
            }
        }

26. Example

Project: DevExpress.Mvvm.Free
Source File: ParserTests.cs
View license
public static IEnumerable<Operand> GetOperands(string input, string backInput) {
            var info = new BindingTreeInfoTest(input, backInput);
            var visitor = new VisitorOperand();
            var errorHandler = new TestErrorHandler();
            var res = visitor.Resolve(new[] { info.Expr }, info.BackExpr, x => typeof(object), errorHandler);
            if(errorHandler.HasError) Assert.Fail();
            return res;
        }

27. Example

View license
protected async Task<JObject> GetContent(string uri)
        {
            var response = await _client.GetAsync(uri);
            if (response.IsSuccessStatusCode == false)
                Assert.Fail("Failed request to {0}: Status code: {1} {2}", uri, response.StatusCode.ToString(), response.ReasonPhrase);
            var content = await response.Content.ReadAsAsync<JObject>();
            return content;

        }

28. Example

Project: NPOI
Source File: TestHSSFCell.cs
View license
[Test]
        public void TestCellStyleWorkbookMatch()
        {
            HSSFWorkbook wbA = new HSSFWorkbook();
            HSSFWorkbook wbB = new HSSFWorkbook();

            HSSFCellStyle styA = (HSSFCellStyle)wbA.CreateCellStyle();
            HSSFCellStyle styB = (HSSFCellStyle)wbB.CreateCellStyle();

            styA.VerifyBelongsToWorkbook(wbA);
            styB.VerifyBelongsToWorkbook(wbB);
            try
            {
                styA.VerifyBelongsToWorkbook(wbB);
                Assert.Fail();
            }
            catch (ArgumentException) { }
            try
            {
                styB.VerifyBelongsToWorkbook(wbA);
                Assert.Fail();
            }
            catch (ArgumentException) { }

            ICell cellA = wbA.CreateSheet().CreateRow(0).CreateCell(0);
            ICell cellB = wbB.CreateSheet().CreateRow(0).CreateCell(0);

            cellA.CellStyle = (styA);
            cellB.CellStyle = (styB);
            try
            {
                cellA.CellStyle = (styB);
                Assert.Fail();
            }
            catch (ArgumentException) { }
            try
            {
                cellB.CellStyle = (styA);
                Assert.Fail();
            }
            catch (ArgumentException) { }
        }

29. Example

Project: NPOI
Source File: TestHSSFPalette.cs
View license
[Test]
        public void TestAddColor()
        {
            try
            {
                HSSFColor hssfColor = hssfPalette.AddColor((byte)10, (byte)10, (byte)10);
                Assert.Fail();
            }
            catch (Exception)
            {
                // Failing because by default there are no colours left in the palette.
            }
        }

30. Example

Project: NPOI
Source File: TestXSSFPivotTable.cs
View license
[Test]
        public void TestAddDataColumnOutOfRangeThrowsException()
        {
            int columnIndex = 5;
            bool isDataField = true;

            try
            {
                pivotTable.AddDataColumn(columnIndex, isDataField);
            }
            catch (ArgumentOutOfRangeException e)
            {
                return;
            }
            Assert.Fail();
        }

31. Example

Project: NPOI
Source File: TestXSSFPivotTable.cs
View license
[Test]
        public void TestAddColumnLabelOutOfRangeThrowsException()
        {
            int columnIndex = 5;

            try
            {
                pivotTable.AddColumnLabel(DataConsolidateFunction.SUM, columnIndex);
            }
            catch (ArgumentOutOfRangeException e)
            {
                return;
            }
            Assert.Fail();
        }

32. Example

Project: NPOI
Source File: TestXSSFPivotTable.cs
View license
[Test]
        public void TestAddReportFilterOutOfRangeThrowsException()
        {
            int columnIndex = 5;
            try
            {
                pivotTable.AddReportFilter(columnIndex);
            }
            catch (ArgumentOutOfRangeException e)
            {
                return;
            }
            Assert.Fail();
        }

33. Example

Project: NPOI
Source File: TestCrtLayout12ARecord.cs
View license
[Test]
        public void TestStore()
        {
            //TODO: complete this test
            Assert.Fail();
        }

34. Example

Project: NPOI
Source File: TestPieRecord.cs
View license
[Test]
        public void TestLoad()
        {
            //TODO: complete this test
            Assert.Fail();
        }

35. Example

Project: NPOI
Source File: TestProblems.cs
View license
[Test]
        public void TestEncryptedFile()
        {
            try
            {
                HWPFTestDataSamples.OpenSampleFile("PasswordProtected.doc");
                Assert.Fail();
            }
            catch (EncryptedDocumentException )
            {
                // Good
            }
        }

36. Example

Project: NPOI
Source File: TestPieFormatRecord.cs
View license
[Test]
        public void TestLoad()
        {
            //TODO: complete this test
            Assert.Fail();
        }

37. Example

Project: NPOI
Source File: TestXSSFPivotTable.cs
View license
[Test]
        public void TestAddRowLabelOutOfRangeThrowsException()
        {
            int columnIndex = 5;

            try
            {
                pivotTable.AddRowLabel(columnIndex);
            }
            catch (IndexOutOfRangeException e)
            {
                return;
            }
            Assert.Fail();
        }

38. Example

Project: NPOI
Source File: TestChart3dRecord.cs
View license
[Test]
        public void TestLoad()
        {
            //TODO: complete this test
            Assert.Fail();
        }

39. Example

Project: NPOI
Source File: TestChart3dRecord.cs
View license
[Test]
        public void TestStore()
        {
            //TODO: complete this test
            Assert.Fail();
        }

40. Example

Project: NPOI
Source File: TestCrtLayout12Record.cs
View license
[Test]
        public void TestStore()
        {
            //TODO: complete this test
            Assert.Fail();
        }

41. Example

Project: NPOI
Source File: TestCrtLayout12ARecord.cs
View license
[Test]
        public void TestLoad()
        {
            //TODO: complete this test
            Assert.Fail();
        }

42. Example

Project: NPOI
Source File: TestPieRecord.cs
View license
[Test]
        public void TestStore()
        {
            //TODO: complete this test
            Assert.Fail();
        }

43. Example

Project: NPOI
Source File: TestHSSFWorkbook.cs
View license
[Test]
        public void DuplicateNames()
        {
            HSSFWorkbook b = new HSSFWorkbook();
            b.CreateSheet("Sheet1");
            b.CreateSheet();
            b.CreateSheet("name1");
            try
            {
                b.CreateSheet("name1");
                Assert.Fail();
            }
            catch (ArgumentException)// pass
            {
            }
            b.CreateSheet();
            try
            {
                b.SetSheetName(3, "name1");
                Assert.Fail();
            }
            catch (ArgumentException)// pass
            {
            }

            try
            {
                b.SetSheetName(3, "name1");
                Assert.Fail();
            }
            catch (ArgumentException)// pass
            {
            }

            b.SetSheetName(3, "name2");
            b.SetSheetName(3, "name2");
            b.SetSheetName(3, "name2");

            HSSFWorkbook c = new HSSFWorkbook();
            c.CreateSheet("Sheet1");
            c.CreateSheet("Sheet2");
            c.CreateSheet("Sheet3");
            c.CreateSheet("Sheet4");

        }

44. Example

Project: NPOI
Source File: TestPieFormatRecord.cs
View license
[Test]
        public void TestStore()
        {
            //TODO: complete this test
            Assert.Fail();
        }

45. Example

Project: NPOI
Source File: TestGelFrameRecord.cs
View license
[Test]
        public void TestStore()
        {
            //TODO: complete this test
            Assert.Fail();
        }

46. Example

Project: NPOI
Source File: TestCrtLayout12Record.cs
View license
[Test]
        public void TestLoad()
        {
            //TODO: complete this test
            Assert.Fail();
        }

47. Example

Project: fluentOptionals
Source File: OptionalTests.cs
View license
[Test]
        public void ImplicitOperator_NullGetsNone()
        {
            Optional<object> optional = (object)null;
            optional.IfSome(_ => Assert.Fail());
        }

48. Example

View license
[Test]
        public void TestIllegalArguments()
        {
            try
            {
                new PhoneNumberMatch(-110, "1 800 234 45 67", new PhoneNumber());
                Assert.Fail();
            }
            catch (ArgumentException) { /* success */ }

            try
            {
                new PhoneNumberMatch(10, "1 800 234 45 67", null);
                Assert.Fail();
            }
            catch (ArgumentNullException) { /* success */ }

            try
            {
                new PhoneNumberMatch(10, null, new PhoneNumber());
                Assert.Fail();
            }
            catch (ArgumentNullException) { /* success */ }

            try
            {
                new PhoneNumberMatch(10, null, null);
                Assert.Fail();
            }
            catch (ArgumentNullException) { /* success */ }
        }

49. Example

View license
[Test]
        public void TestValidateREThrowsException()
        {
            String invalidPattern = "[";
            // Should throw an exception when an invalid pattern is provided independently of the last
            // parameter (remove white spaces).
            try
            {
                BuildMetadataFromXml.ValidateRE(invalidPattern, false);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                // Test passed.
            }
            try
            {
                BuildMetadataFromXml.ValidateRE(invalidPattern, true);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                // Test passed.
            }
        }

50. Example

Project: NosDB
Source File: TestLockingStructs.cs
View license
[Test, ExpectedException(typeof(TimeoutException))]
        public void TestSafeLockTimeout()
        {
            object instance = new object();
            using (new ThreadedWriter(new SimpleReadWriteLocking(instance)))
            using (new SafeLock(instance, 0))
                Assert.Fail();
        }