Here are the examples of the csharp api class NUnit.Framework.Assert.That(NUnit.Framework.Constraints.ActualValueDelegate, NUnit.Framework.Constraints.IResolveConstraint, string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
38 Examples
0
1. Example
Project: nunit
Source File: AssertThatTests.cs
Source File: AssertThatTests.cs
[Test] public void AssertionPasses_ActualLambdaAndConstraintWithMessage() { Assert.That(() => 2 + 2, Is.EqualTo(4), "Should be 4"); }
0
2. Example
Project: nunit
Source File: AssertThatTests.cs
Source File: AssertThatTests.cs
[Test] public void AssertionPasses_DelegateAndConstraintWithMessage() { Assert.That(new ActualValueDelegate<int>(ReturnsFour), Is.EqualTo(4), "Message"); }
0
3. Example
Project: SMAPI
Source File: TranslationTests.cs
Source File: TranslationTests.cs
[Test(Description = "Assert that the translation's Assert method throws the expected exception.")] public void Translation_Assert([ValueSource(nameof(TranslationTests.Samples))] string text) { // act Translation translation = new Translation("ModName", "pt-BR", "key", text); // assert if (translation.HasValue()) Assert.That(() => translation.Assert(), Throws.Nothing, "The assert unexpected threw an exception for a valid input."); else Assert.That(() => translation.Assert(), Throws.Exception.TypeOf<KeyNotFoundException>(), "The assert didn't throw an exception for invalid input."); }
0
4. Example
Project: LinqToExcel
Source File: ExcelQueryFactoryTests.cs
Source File: ExcelQueryFactoryTests.cs
[Test] public void GetWorksheetNames_throws_exception_when_filename_not_set() { var factory = new ExcelQueryFactory(new LogManagerFactory()); Assert.That(() => factory.GetWorksheetNames(), Throws.TypeOf<NullReferenceException>(), "FileName property is not set"); }
0
5. Example
Project: LinqToExcel
Source File: ExcelQueryFactoryTests.cs
Source File: ExcelQueryFactoryTests.cs
[Test] public void GetColumnNames_throws_exception_when_filename_not_set() { var factory = new ExcelQueryFactory(new LogManagerFactory()); Assert.That(() => factory.GetColumnNames(""), Throws.TypeOf<NullReferenceException>(), "FileName property is not set"); }
0
6. Example
Project: LinqToExcel
Source File: ExcelQueryFactoryTests.cs
Source File: ExcelQueryFactoryTests.cs
[Test] public void StrictMapping_ClassStrict_throws_StrictMappingException_when_property_is_not_mapped_to_column() { var excel = new ExcelQueryFactory(_excelFileName, new LogManagerFactory()); excel.StrictMapping = StrictMappingType.ClassStrict; var companies = (from x in excel.Worksheet<CompanyWithCity>() select x); Assert.That(() => companies.ToList(), Throws.TypeOf<StrictMappingException>(), "'City' property is not mapped to a column"); }
0
7. Example
Project: LinqToExcel
Source File: ExcelQueryFactoryTests.cs
Source File: ExcelQueryFactoryTests.cs
[Test] public void StrictMapping_WorksheetStrict_throws_StrictMappingException_when_column_is_not_mapped_to_property() { var excel = new ExcelQueryFactory(_excelFileName, new LogManagerFactory()); excel.StrictMapping = StrictMappingType.WorksheetStrict; var companies = (from x in excel.Worksheet<Company>("Null Dates") select x); Assert.That(() => companies.ToList(), Throws.TypeOf<StrictMappingException>(), "'City' column is not mapped to a property"); }
0
8. Example
Project: LinqToExcel
Source File: ExcelQueryFactoryTests.cs
Source File: ExcelQueryFactoryTests.cs
[Test] public void StrictMapping_Both_throws_StrictMappingException_when_property_is_not_mapped_to_column() { var excel = new ExcelQueryFactory(_excelFileName, new LogManagerFactory()); excel.StrictMapping = StrictMappingType.Both; var companies = (from x in excel.Worksheet<CompanyWithCity>() select x); Assert.That(() => companies.ToList(), Throws.TypeOf<StrictMappingException>(), "'City' column is not mapped to a property"); }
0
9. Example
Project: LinqToExcel
Source File: ExcelQueryFactoryTests.cs
Source File: ExcelQueryFactoryTests.cs
[Test] public void StrictMapping_Both_throws_StrictMappingException_when_column_is_not_mapped_to_property() { var excel = new ExcelQueryFactory(_excelFileName, new LogManagerFactory()); excel.StrictMapping = StrictMappingType.Both; var companies = (from x in excel.Worksheet<Company>("Null Dates") select x); Assert.That(() => companies.ToList(), Throws.TypeOf<StrictMappingException>(), "'City' column is not mapped to a property"); }
0
10. Example
Project: LinqToExcel
Source File: InvalidColumnNamesUsed.cs
Source File: InvalidColumnNamesUsed.cs
[Test] public void bad_column_in_orderby_clause() { var list = (from x in ExcelQueryFactory.Worksheet<CompanyWithCity>("Sheet1", _excelFileName, new LogManagerFactory()) select x) .OrderBy(x => x.City); Assert.That(() => list.ToList(), Throws.TypeOf<DataException>(), "'City' is not a valid column name. " + "Valid column names are: 'Name', 'CEO', 'EmployeeCount', 'StartDate'"); }
0
11. Example
Project: LinqToExcel
Source File: NoHeader_SQLStatements_UnitTests.cs
Source File: NoHeader_SQLStatements_UnitTests.cs
[Test] public void range_csv_file_throws_exception() { var csvFile = @"C:\ExcelFiles\NoHeaderRange.csv"; var excel = new ExcelQueryFactory(csvFile, new LogManagerFactory()); Assert.That(() => (from c in excel.WorksheetRangeNoHeader("B9", "E15") select c), Throws.TypeOf<ArgumentException>(), "Cannot use WorksheetRangeNoHeader on csv files"); }
0
12. Example
Project: LinqToExcel
Source File: Range_SQLStatements_UnitTests.cs
Source File: Range_SQLStatements_UnitTests.cs
[Test] public void Throws_argument_exception_if_startRange_is_incorrect_format() { try { Assert.That(() => from c in _factory.WorksheetRange("22", "D4") select c, Throws.TypeOf<ArgumentException>(), "StartRange argument '22' is invalid format for cell name"); } catch (OleDbException) { } }
0
13. Example
Project: LinqToExcel
Source File: Range_SQLStatements_UnitTests.cs
Source File: Range_SQLStatements_UnitTests.cs
[Test] public void Throws_argument_exception_if_endRange_is_incorrect_format() { try { Assert.That(() => from c in _factory.WorksheetRange("B2", "DD") select c, Throws.TypeOf<ArgumentException>(), "EndRange argument 'DD' is invalid format for cell name"); } catch (OleDbException) { } }
0
14. Example
Project: LinqToExcel
Source File: RowTest.cs
Source File: RowTest.cs
[Test] public void invalid_column_name_index_throws_argument_exception() { var newRow = new Row(_cells, _columnMappings); Assert.That(() => newRow["First Name"], Throws.TypeOf<ArgumentException>(), "'First Name' column name does not exist. Valid column names are 'Name', 'Favorite Sport', 'Age'"); }
0
15. Example
Project: LinqToExcel
Source File: Row_SQLStatement_UnitTests.cs
Source File: Row_SQLStatement_UnitTests.cs
[Test] public void argument_exception_thrown_when_column_indexes_used_in_worksheet_where_clause() { var companies = from c in ExcelQueryFactory.Worksheet("", "", null, new LogManagerFactory()) where c[0] == "Omaha" select c; try { Assert.That(() => companies.GetEnumerator(), Throws.TypeOf<ArgumentException>(), "Can only use column indexes in WHERE clause when using WorksheetNoHeader"); } catch (OleDbException) { } }
0
16. Example
Project: LinqToExcel
Source File: UnSupportedMethods.cs
Source File: UnSupportedMethods.cs
[Test] public void default_if_empty() { var companies = (from c in ExcelQueryFactory.Worksheet<Company>(null, "", null, new LogManagerFactory()) select c).DefaultIfEmpty(); Assert.That(() => companies.ToList(), Throws.TypeOf<NotSupportedException>(), "LinqToExcel does not provide support for the DefaultIfEmpty()"); }
0
17. Example
Project: LinqToExcel
Source File: UnSupportedMethods.cs
Source File: UnSupportedMethods.cs
[Test] public void group() { var companies = from c in ExcelQueryFactory.Worksheet<Company>(null, "", null, new LogManagerFactory()) group c by c.CEO into g select g; try { Assert.That(() => companies.ToList(), Throws.TypeOf<NotSupportedException>(), "LinqToExcel does not provide support for the Group() method"); } catch (OleDbException) { } }
0
18. Example
Project: LinqToExcel
Source File: UnSupportedMethods.cs
Source File: UnSupportedMethods.cs
[Test] public void distinct_on_no_header() { var excel = new ExcelQueryFactory("", new LogManagerFactory()); Assert.That(() => (from c in excel.WorksheetNoHeader() select c).Distinct().ToList(), Throws.TypeOf<NotSupportedException>(), "LinqToExcel only provides support for the Distinct() method when it's mapped to a class and a single property is selected. [e.g. (from row in excel.Worksheet<Person>() select row.FirstName).Distinct()]"); }
0
19. Example
Project: LinqToExcel
Source File: UnSupportedMethods.cs
Source File: UnSupportedMethods.cs
[Test] public void distinct_on_no_header_with_selected_column() { var excel = new ExcelQueryFactory("", new LogManagerFactory()); Assert.That(() => (from c in excel.WorksheetNoHeader() select c[0]).Distinct().ToList(), Throws.TypeOf<NotSupportedException>(), "LinqToExcel only provides support for the Distinct() method when it's mapped to a class and a single property is selected. [e.g. (from row in excel.Worksheet<Person>() select row.FirstName).Distinct()]"); }
0
20. Example
Project: LinqToExcel
Source File: UnSupportedMethods.cs
Source File: UnSupportedMethods.cs
[Test] public void distinct_on_row() { var excel = new ExcelQueryFactory("", new LogManagerFactory()); Assert.That(() => (from c in excel.Worksheet() select c).Distinct().ToList(), Throws.TypeOf<NotSupportedException>(), "LinqToExcel only provides support for the Distinct() method when it's mapped to a class and a single property is selected. [e.g. (from row in excel.Worksheet<Person>() select row.FirstName).Distinct()]"); }
0
21. Example
Project: LinqToExcel
Source File: UnSupportedMethods.cs
Source File: UnSupportedMethods.cs
[Test] public void distinct_on_row_with_selected_column() { var excel = new ExcelQueryFactory("", new LogManagerFactory()); Assert.That(() => (from c in excel.Worksheet() select c["Name"]).Distinct().ToList(), Throws.TypeOf<NotSupportedException>(), "LinqToExcel only provides support for the Distinct() method when it's mapped to a class and a single property is selected. [e.g. (from row in excel.Worksheet<Person>() select row.FirstName).Distinct()]"); }
0
22. Example
Project: nhibernate-core
Source File: FixtureByCode.cs
Source File: FixtureByCode.cs
[Test] public async Task SessionIsDirtyShouldNotFailForNewManyToOneObjectAsync() { using (var session = OpenSession()) using (session.BeginTransaction()) { var parent = await (GetParentAsync(session)); //parent.Child entity is not cascaded, I want to save it explictilty later parent.Child = new EntityChild { Name = "NewManyToOneChild" }; var isDirty = false; Assert.That(async () => isDirty = await (session.IsDirtyAsync()), Throws.Nothing, "ISession.IsDirty() call should not fail for transient many-to-one object referenced in session."); Assert.That(isDirty, "ISession.IsDirty() call should return true."); } }
0
23. Example
Project: nhibernate-core
Source File: FixtureByCode.cs
Source File: FixtureByCode.cs
[Test] public async Task SessionIsDirtyShouldNotFailForNewManyToOneObjectWithAssignedIdAsync() { using (var session = OpenSession()) using (session.BeginTransaction()) { var parent = await (GetParentAsync(session)); //parent.ChildAssigned entity is not cascaded, I want to save it explictilty later parent.ChildAssigned = new EntityChildAssigned { Id = 2, Name = "NewManyToOneChildAssignedId" }; var isDirty = false; Assert.That(async () => isDirty = await (session.IsDirtyAsync()), Throws.Nothing, "ISession.IsDirty() call should not fail for transient many-to-one object referenced in session."); Assert.That(isDirty, "ISession.IsDirty() call should return true."); } }
0
24. Example
Project: nhibernate-core
Source File: FixtureByCode.cs
Source File: FixtureByCode.cs
[Test] public void SessionIsDirtyShouldNotFailForNewManyToOneObject() { using (var session = OpenSession()) using (session.BeginTransaction()) { var parent = GetParent(session); //parent.Child entity is not cascaded, I want to save it explictilty later parent.Child = new EntityChild { Name = "NewManyToOneChild" }; var isDirty = false; Assert.That(() => isDirty = session.IsDirty(), Throws.Nothing, "ISession.IsDirty() call should not fail for transient many-to-one object referenced in session."); Assert.That(isDirty, "ISession.IsDirty() call should return true."); } }
0
25. Example
Project: nhibernate-core
Source File: FixtureByCode.cs
Source File: FixtureByCode.cs
[Test] public void SessionIsDirtyShouldNotFailForNewManyToOneObjectWithAssignedId() { using (var session = OpenSession()) using (session.BeginTransaction()) { var parent = GetParent(session); //parent.ChildAssigned entity is not cascaded, I want to save it explictilty later parent.ChildAssigned = new EntityChildAssigned { Id = 2, Name = "NewManyToOneChildAssignedId" }; var isDirty = false; Assert.That(() => isDirty = session.IsDirty(), Throws.Nothing, "ISession.IsDirty() call should not fail for transient many-to-one object referenced in session."); Assert.That(isDirty, "ISession.IsDirty() call should return true."); } }
0
26. Example
Project: nunit
Source File: AssertThatTests.cs
Source File: AssertThatTests.cs
[Test] public void FailureThrowsAssertionException_ActualLambdaAndConstraintWithMessage() { var ex = Assert.Throws<AssertionException>(() => Assert.That(() => 2 + 2, Is.EqualTo(5), "Error")); Assert.That(ex.Message, Does.Contain("Error")); }
0
27. Example
Project: nunit
Source File: AssertThatTests.cs
Source File: AssertThatTests.cs
[Test] public void FailureThrowsAssertionException_DelegateAndConstraintWithMessage() { var ex = Assert.Throws<AssertionException>(() => Assert.That(new ActualValueDelegate<int>(ReturnsFive), Is.EqualTo(4), "Error")); Assert.That(ex.Message, Does.Contain("Error")); }
0
28. Example
Project: EntityProfiler
Source File: QueryNotificationTest.cs
Source File: QueryNotificationTest.cs
[Test] public void QueryNotification_InsertQueryTest() { // given this._messageListener.Start(); TestDbContext dbContext = new TestDbContext(); // when dbContext.TestEntities.Add(SomeEntity.CreateNew()); dbContext.SaveChanges(); // then MessageEvent ev = this.GetMessageEvent(); Message msg = ev.Message; Assert.IsNull(ev.Exception, "Connection error occurred"); Assert.That(() => msg, Is.InstanceOf<DbReaderQueryMessage>(), "We expected DbReaderQueryMessage to be returned"); this._eventSubscriber.AssertNoFurtherMessagesReceived(); }
0
29. Example
Project: EntityProfiler
Source File: QueryNotificationTest.cs
Source File: QueryNotificationTest.cs
[Test] public void QueryNotification_CountQueryTest() { // given this._messageListener.Start(); TestDbContext dbContext = new TestDbContext(); // when int count = dbContext.TestEntities.Count(); // then MessageEvent ev = this.GetMessageEvent(); Message msg = ev.Message; Assert.IsNull(ev.Exception, "Connection error occurred"); Assert.That(() => msg, Is.InstanceOf<DbReaderQueryMessage>(), "We expected DbReaderQueryMessage to be returned"); this._eventSubscriber.AssertNoFurtherMessagesReceived(); }
0
30. Example
Project: BloomDesktop
Source File: NavigationIsolatorTests.cs
Source File: NavigationIsolatorTests.cs
[Test] public void SameBrowser_ReplacesPending() { var isolator = new NavigationIsolator(); var browser = new BrowserStub(); string target = "http://whatever"; isolator.Navigate(browser, target); var browser2 = new BrowserStub(); string target2A = "http://first"; isolator.Navigate(browser2, target2A); string target2B = "http://second"; isolator.Navigate(browser2, target2B); // Signal the first browser to finish. browser.NormalTermination(); Assert.That(() => browser2.NavigateTarget, Is.EqualTo(target2B), "Second navigation should have proceeded with its second choice"); // Signal the second browser to finish. browser2.NormalTermination(); Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed"); Assert.That(browser2.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed"); }
0
31. Example
Project: nmoneys
Source File: MoneyTester.Arithmetic.cs
Source File: MoneyTester.Arithmetic.cs
[Test] public void BeCarefulWithBigUInt64_CannotBeConvertedToInt64() { ulong max = ulong.MaxValue; long l = (long)max; Assert.That(l, Is.EqualTo(-1), "wat?!"); Assert.That(()=> Convert.ToInt64(max), Throws.InstanceOf<OverflowException>(), "FAIL!"); }
0
32. Example
Project: BloomDesktop
Source File: NavigationIsolatorTests.cs
Source File: NavigationIsolatorTests.cs
[Test] public void NoLongerBusy_EvenWithoutEvent_IsNoticed() { var browser = new BrowserStub(); string target = "http://any old web address"; var isolator = new NavigationIsolator(); isolator.Navigate(browser, target); Assert.That(browser.NavigateTarget, Is.EqualTo(target)); var browser2 = new BrowserStub(); string target2 = "http://some other web address"; isolator.Navigate(browser2, target2); Assert.That(browser.NavigateTarget, Is.EqualTo(target), "Second navigation should not have proceeded at once"); Assert.That(browser2.NavigateTarget, Is.EqualTo(null), "Second navigation should not have proceeded at once"); browser.IsBusy = false; // finished but did not raise event. var start = DateTime.Now; while (DateTime.Now - start < new TimeSpan(0, 0,0, 0, 150)) Application.DoEvents(); // allow timer to tick. Assert.That(() => browser2.NavigateTarget, Is.EqualTo(target2), "Second navigation should have proceeded soon after first no longer busy"); browser.NormalTermination(); browser2.NormalTermination(); Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed"); Assert.That(browser2.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed"); }
0
33. Example
Project: BloomDesktop
Source File: NavigationIsolatorTests.cs
Source File: NavigationIsolatorTests.cs
[Test] public void Isolation_AfterLongDelay_GivesUpAndMovesOn() { var browser = new BrowserStub(); string target = "http://any old web address"; var isolator = new NavigationIsolator(); isolator.Navigate(browser, target); Assert.That(browser.NavigateTarget, Is.EqualTo(target)); var browser2 = new BrowserStub(); string target2 = "http://some other web address"; isolator.Navigate(browser2, target2); var browser3 = new BrowserStub(); string target3 = "http://yet another web address"; isolator.Navigate(browser3, target3); Assert.That(browser.NavigateTarget, Is.EqualTo(target), "Second navigation should not have proceeded at once"); var start = DateTime.Now; while (DateTime.Now - start < new TimeSpan(0, 0, 0, 2, 300)) Application.DoEvents(); // allow timer to tick. Assert.That(() => browser2.NavigateTarget, Is.EqualTo(target2), "Second navigation should have proceeded eventually"); browser2.NormalTermination(); // the second request. Assert.That(() => browser3.NavigateTarget, Is.EqualTo(target3), "Third navigation should have proceeded when second finished"); browser3.NormalTermination(); // hopefully from the third. Assert.That(browser3.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed"); }
0
34. Example
Project: nhibernate-core
Source File: TransactionNotificationFixture.cs
Source File: TransactionNotificationFixture.cs
[Description("NH2128")] [Theory] public void ShouldNotifyAfterDistributedTransactionWithOwnConnection(bool doCommit) { // Note: For system transaction, calling Close() on the session isn't // supported, so we don't need to test that scenario. var interceptor = new RecordingInterceptor(); ISession s1; var ownConnection1 = Sfi.ConnectionProvider.GetConnection(); try { using (var tx = new TransactionScope()) { ownConnection1.EnlistTransaction(System.Transactions.Transaction.Current); using (s1 = Sfi.WithOptions().Connection(ownConnection1).Interceptor(interceptor).OpenSession()) { s1.CreateCriteria<object>().List(); } if (doCommit) tx.Complete(); } } finally { Sfi.ConnectionProvider.CloseConnection(ownConnection1); } // Transaction completion may happen asynchronously, so allow some delay. Odbc promotes // this test to distributed and have that delay, by example. Assert.That(() => s1.IsOpen, Is.False.After(500, 100), "Session not closed."); Assert.That(interceptor.afterTransactionCompletionCalled, Is.EqualTo(1)); }
0
35. Example
Project: BloomDesktop
Source File: NavigationIsolatorTests.cs
Source File: NavigationIsolatorTests.cs
[Test] public void SingleTask_AfterLongDelay_AllowsIdleNavigation() { var browser = new BrowserStub(); string target = "http://any old web address"; var isolator = new NavigationIsolator(); isolator.Navigate(browser, target); Assert.That(browser.NavigateTarget, Is.EqualTo(target)); string target2 = "http://some other web address"; var start = DateTime.Now; var success = false; while (!success && DateTime.Now - start < new TimeSpan(0, 0, 0, 2, 300)) { success = isolator.NavigateIfIdle(browser, target2); Application.DoEvents(); // allow timer to tick. } Assert.That(() => browser.NavigateTarget, Is.EqualTo(target2), "Idle navigation should have proceeded eventually"); Assert.That(success, "NavigateIfIdle should eventually succeed"); browser.NormalTermination(); // possibly the long-delayed notification of the first nav, but more likely the idle navigation. Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed"); }
0
36. Example
Project: memcache-driver
Source File: MemcacheNodeTests.cs
Source File: MemcacheNodeTests.cs
[TestCase(1)] [TestCase(2)] [Explicit] public void NodeWorkingTransportsTest/n ..... /n //View Source file for more details /n }
0
37. Example
Project: memcache-driver
Source File: MemcacheNodeTests.cs
Source File: MemcacheNodeTests.cs
[Test] public void ReceiveFailConsistency([Values(true, false)] bool failInBody) { /n ..... /n //View Source file for more details /n }
0
38. Example
Project: memcache-driver
Source File: TransportTest.cs
Source File: TransportTest.cs
[Test] public void AuthenticationFailed() { var sentMutex = new ManualRe/n ..... /n //View Source file for more details /n }