NUnit.Framework.Assert.That(object, NUnit.Framework.Constraints.IResolveConstraint)

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

200 Examples 7

1. Example

Project: Castle.Transactions
Source File: MyService.cs
View license
[Transaction(TransactionScopeOption.Suppress)]
		public virtual void VerifySupressed()
		{
			Assert.That(System.Transactions.Transaction.Current, Is.Null);
		}

2. Example

View license
[Test, Description("We are not in a distributed transaction if there is no transaction scope.")]
		public void NotUsingTransactionScope_IsNotDistributed_AboveNegated()
		{
			using (ITransaction tx = new FileTransaction("Not distributed transaction"))
			{
				Assert.That(System.Transactions.Transaction.Current, Is.Null);
				tx.Complete();
			}
		}

3. Example

View license
public static void ShouldBeTrue(this bool value)
		{
			Assert.That(value, Is.True);
		}

4. Example

View license
public static bool ShouldBeFalse(this bool value)
		{
			Assert.That(value, Is.False);
			return false;
		}

5. Example

Project: tesseract
Source File: EngineTests.cs
View license
[Test]
        public void CanGetStringVariableThatDoesNotExist()
        {
            using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) {
                String result;
                Boolean success = engine.TryGetStringVariable("illegal-variable", out result);
                Assert.That(success, Is.False);
                Assert.That(result, Is.Null);
            }
        }

6. Example

View license
[Test]
        public void EdgeNonEdge()
        {
            var connections = new[]
            {
                new ConnectionPoint(new Point(0, 0), "a", ConnectionFlags.Edge | ConnectionFlags.Vertical),
                new ConnectionPoint(new Point(0, 0), "a", ConnectionFlags.Horizontal),
            };

            bool visualise = connectionVisualiser.VisualiseConnections(connections);
            Assert.That(visualise, Is.True);
        }

7. Example

View license
[Test]
        public void TwoEdges()
        {
            var connections = new[]
            {
                new ConnectionPoint(new Point(0, 0), "a", ConnectionFlags.Edge | ConnectionFlags.Vertical),
                new ConnectionPoint(new Point(0, 0), "a", ConnectionFlags.Edge | ConnectionFlags.Horizontal),
            };

            bool visualise = connectionVisualiser.VisualiseConnections(connections);
            Assert.That(visualise, Is.False);
        }

8. Example

View license
[Test]
        public void ThreeEdges()
        {
            var connections = new[]
            {
                new ConnectionPoint(new Point(0, 0), "a", ConnectionFlags.Edge | ConnectionFlags.Vertical),
                new ConnectionPoint(new Point(0, 0), "a", ConnectionFlags.Edge | ConnectionFlags.Horizontal),
                new ConnectionPoint(new Point(0, 0), "a", ConnectionFlags.Edge | ConnectionFlags.Horizontal),
            };

            bool visualise = connectionVisualiser.VisualiseConnections(connections);
            Assert.That(visualise, Is.True);
        }

9. Example

View license
[Test]
        public void Single()
        {
            var connections = new[]
            {
                new ConnectionPoint(new Point(0, 0), "a", ConnectionFlags.Edge | ConnectionFlags.Vertical),
            };

            bool visualise = connectionVisualiser.VisualiseConnections(connections);
            Assert.That(visualise, Is.False);
        }

10. Example

Project: AliaSQL
Source File: EnumerableAssert.cs
View license
public static void That<T>(IEnumerable<T> enumerable, Constraint constraint)
		{
			Assert.That(new List<T>(enumerable), constraint);
		}

11. Example

Project: XSerializer
Source File: JsonObjectTests.cs
View license
[Test]
        public void DecryptDoesNothingIfTheValueIsNull()
        {
            var encryptionMechanism = new Base64EncryptionMechanism();

            dynamic foo =
                new JsonObject(encryptionMechanism:encryptionMechanism)
                {
                    { "bar", null },
                };

            object bar1 = foo.bar;
            Assert.That(bar1, Is.Null);

            foo.Decrypt("bar");

            object bar2 = foo.bar;
            Assert.That(bar2, Is.Null);
        }

12. Example

Project: XSerializer
Source File: JsonArrayTests.cs
View license
[Test]
        public void CanConvertToNullableBooleanArray()
        {
            var foo = new JsonArray
            {
                true, null
            };

            bool?[] fooConverted = foo;

            var bar = fooConverted[0];
            var baz = fooConverted[1];

            Assert.That(bar, Is.True);
            Assert.That(baz, Is.Null);
        }

13. Example

Project: XSerializer
Source File: JsonArrayTests.cs
View license
[Test]
        public void CanConvertToJsonObjectArray()
        {
            var foo = new JsonArray
            {
                new JsonObject
                {
                    { "foo", true }
                }
            };

            JsonObject[] fooConverted = foo;

            var bar = fooConverted[0];

            Assert.That(bar["foo"], Is.True);
        }

14. Example

Project: XSerializer
Source File: JsonArrayTests.cs
View license
[Test]
        public void DecryptDoesNothingIfTheItemIsNull()
        {
            var encryptionMechanism = new Base64EncryptionMechanism();

            dynamic foo =
                new JsonArray(encryptionMechanism:encryptionMechanism)
                {
                    null,
                };

            object bar1 = foo[0];
            Assert.That(bar1, Is.Null);

            foo.Decrypt(0);

            object bar2 = foo[0];
            Assert.That(bar2, Is.Null);
        }

15. Example

Project: XSerializer
Source File: JsonArrayTests.cs
View license
[Test]
        public void CanConvertToBooleanArray()
        {
            var foo = new JsonArray
            {
                true,
            };

            bool[] fooConverted = foo;

            var bar = fooConverted[0];

            Assert.That(bar, Is.True);
        }

16. Example

Project: atata
Source File: TriggerTests.cs
View license
[Test]
        public void Trigger_Add_ToPageObject()
        {
            bool isDeInitInvoked = false;

            page.Triggers.Add(new InvokeDelegateAttribute(() => isDeInitInvoked = true, TriggerEvents.DeInit));

            page.GoTo1.ClickAndGo();

            Assert.That(isDeInitInvoked, Is.True);
        }

17. Example

Project: Fizzler
Source File: NamespacePrefixTests.cs
View license
[Test]
        public void HashCode()
        {
            var foo = new NamespacePrefix("foo");
            var bar = new NamespacePrefix("bar");
            Assert.That(foo.GetHashCode() == bar.GetHashCode(), Is.False);
        }

18. Example

Project: XmlDoc2CmdletDoc
Source File: AcceptanceTests.cs
View license
[Test]
        public void Command_ForTestMamlElements()
        {
            Assert.That(testMamlElementsCommandElement, Is.Not.Null);
        }

19. Example

Project: XmlDoc2CmdletDoc
Source File: AcceptanceTests.cs
View license
[Test]
        public void Command_ForTestManualElements()
        {
            Assert.That(testManualElementsCommandElement, Is.Not.Null);
        }

20. Example

View license
[Test]
		public void listener_mapped_with_type_is_triggered_by_correct_typed_event()
		{
			eventMap.MapListener(eventDispatcher, CustomEvent.Type.STARTED, (Action<IEvent>)listener, typeof(CustomEvent));
			eventDispatcher.Dispatch(new CustomEvent(CustomEvent.Type.STARTED));
			Assert.That(listenerExecuted, Is.True);
		}

21. Example

View license
[Test]
		public void detains_command()
		{
			object command = new object();
			bool wasDetained = false;
			context.Detained += delegate(object obj)
			{
				wasDetained = true;
			};
			subject.Detain(command);

			Assert.That(wasDetained, Is.True);
		}

22. Example

View license
[Test]
		public void Test_Failure_Seen()
		{
			Assert.That (true, Is.True);
		}

23. Example

View license
[Test]
		public void adding_BeforeInitializing_handler_after_initialization_catches_error()
		{
			bool caught = false;
			context.ERROR += delegate(Exception obj) {
				caught = true;
			};
			context.Initialize();
			context.BeforeInitializing(nop);
			Assert.That (caught, Is.True);
		}

24. Example

View license
[Test]
		public void suspend_causes_no_handlers_to_fire()
		{
			eventMap.MapListener(eventDispatcher, CustomEvent.Type.STARTED, (Action<IEvent>)listener);
			eventMap.MapListener(eventDispatcher, EventType.COMPLETE, (Action<IEvent>)listener);
			eventMap.MapListener(eventDispatcher, EventType.CHANGE, (Action<IEvent>)listener);
			eventMap.Suspend();
			eventDispatcher.Dispatch(new CustomEvent(CustomEvent.Type.STARTED));
			eventDispatcher.Dispatch(new Event(EventType.COMPLETE));
			eventDispatcher.Dispatch(new Event(EventType.CHANGE));
			Assert.That(listenerExecuted, Is.False);
		}

25. Example

View license
[Test]
		public void listeners_added_while_suspended_dont_fire()
		{
			eventMap.Suspend();
			eventMap.MapListener(eventDispatcher, CustomEvent.Type.STARTED, (Action<IEvent>)listener);
			eventMap.MapListener(eventDispatcher, EventType.COMPLETE, (Action<IEvent>)listener);
			eventMap.MapListener(eventDispatcher, EventType.CHANGE, (Action<IEvent>)listener);
			eventDispatcher.Dispatch(new CustomEvent(CustomEvent.Type.STARTED));
			eventDispatcher.Dispatch(new Event(EventType.COMPLETE));
			eventDispatcher.Dispatch(new Event(EventType.CHANGE));
			Assert.That(listenerExecuted, Is.False);
		}

26. Example

View license
[Test]
		public void unmapListeners_causes_no_handlers_to_fire()
		{
			eventMap.MapListener(eventDispatcher, CustomEvent.Type.STARTED, (Action<IEvent>)listener);
			eventMap.MapListener(eventDispatcher, EventType.COMPLETE, (Action<IEvent>)listener);
			eventMap.MapListener(eventDispatcher, EventType.CHANGE, (Action<IEvent>)listener);
			eventMap.UnmapListeners();
			eventDispatcher.Dispatch(new CustomEvent(CustomEvent.Type.STARTED));
			eventDispatcher.Dispatch(new Event(EventType.COMPLETE));
			eventDispatcher.Dispatch(new Event(EventType.CHANGE));
			Assert.That(listenerExecuted, Is.False);
		}

27. Example

View license
[Test]
		public void listener_mapped_without_type_and_unmapped_with_type_fires_in_response_to_plain_event()
		{
			eventMap.MapListener(eventDispatcher, CustomEvent.Type.STARTED, (Action<IEvent>)listener);
			eventMap.UnmapListener(eventDispatcher, CustomEvent.Type.STARTED, (Action<IEvent>)listener, typeof(CustomEvent));
			eventDispatcher.Dispatch(new Event(CustomEvent.Type.STARTED));
			Assert.That(listenerExecuted, Is.True);
		}

28. Example

View license
[Test]
		public void Allows_Communication_From_Parent_To_Child()
		{
			parentConnector.OnDefaultChannel()
				.RelayEvent(SupportEvent.Type.TYPE1);
			childAConnector.OnDefaultChannel()
				.ReceiveEvent(SupportEvent.Type.TYPE1);

			bool wasCalled = false;
			childADispatcher.AddEventListener(SupportEvent.Type.TYPE1, delegate(IEvent obj) {
				wasCalled = true;
			});

			parentDispatcher.Dispatch(new SupportEvent(SupportEvent.Type.TYPE1));

			Assert.That(wasCalled, Is.True);
		}

29. Example

View license
[Test]
		public void ViewStateWatcher_Hears_When_View_Is_Removed()
		{
			bool heardEvent = false;
			context.Configure (new ContextView (contextViewObject));
			IViewStateWatcher actual = context.injector.GetInstance<IViewStateWatcher>() as IViewStateWatcher;
			actual.removed += delegate(object obj) {
				heardEvent = true;
			};
			contextViewObject.RemoveThisView ();

			Assert.That (heardEvent, Is.True);
		}

30. Example

View license
[Test]
		public void Allows_Communication_From_Child_To_Parent()
		{
			parentConnector.OnDefaultChannel()
				.ReceiveEvent(SupportEvent.Type.TYPE1);
			childAConnector.OnDefaultChannel()
				.RelayEvent(SupportEvent.Type.TYPE1);

			bool wasCalled = false;
			parentDispatcher.AddEventListener(SupportEvent.Type.TYPE1, delegate(IEvent evt) {
				wasCalled = true;
			});

			childADispatcher.Dispatch(new SupportEvent(SupportEvent.Type.TYPE1));

			Assert.That (wasCalled, Is.True);
		}

31. Example

View license
[Test]
		public void configs_are_installed()
		{
			bool installed = false;
			IConfig config = new CallbackConfig(
				delegate() {
					installed = true;
				});
			context.Configure(config);
			context.Initialize();
			Assert.That(installed, Is.True);
		}

32. Example

View license
[Test]
		public void listener_mapped_and_unmapped_without_type_doesnt_fire_in_response_to_typed_or_plain_event()
		{
			eventMap.MapListener(eventDispatcher, CustomEvent.Type.STARTED, (Action<IEvent>)listener);
			eventMap.UnmapListener(eventDispatcher, CustomEvent.Type.STARTED, (Action<IEvent>)listener);
			eventDispatcher.Dispatch(new Event(CustomEvent.Type.STARTED));
			eventDispatcher.Dispatch(new CustomEvent(CustomEvent.Type.STARTED));
			Assert.That(listenerExecuted, Is.False);
		}

33. Example

View license
[Test]
		public void Allows_Communication_Amongst_Children()
		{
			childAConnector.OnDefaultChannel()
				.RelayEvent(SupportEvent.Type.TYPE1);
			childBConnector.OnDefaultChannel()
				.ReceiveEvent(SupportEvent.Type.TYPE1);

			bool wasCalled = false;
			childBDispatcher.AddEventListener(SupportEvent.Type.TYPE1, delegate(IEvent evt) {
				wasCalled = true;
			});

			childADispatcher.Dispatch(new SupportEvent(SupportEvent.Type.TYPE1));

			Assert.That (wasCalled, Is.True);
		}

34. Example

View license
[Test]
		public void invalidTransition_is_passed_to_callback_when_errorListener_is_attached()
		{
			object actual = null;
			lifecycle.ERROR += delegate(Exception error){
			};
			transition.FromStates(LifecycleState.DESTROYING).Enter(delegate(Exception error){
				actual = error;
			});
			Assert.That (actual, Is.Not.Null);
		}

35. Example

View license
[Test]
		public void stateChange_triggers_event()
		{
			bool fired = false;
			lifecycle.STATE_CHANGE += delegate() {
				fired = true;
			};
			lifecycle.Initialize();
			Assert.That(fired, Is.True);
		}

36. Example

View license
[Test]
		public void ViewStateWatcher_Hears_When_View_Is_Disabled()
		{
			bool heardEvent = false;
			context.Configure (new ContextView (contextViewObject));
			IViewStateWatcher actual = context.injector.GetInstance<IViewStateWatcher>() as IViewStateWatcher;
			actual.disabled += delegate(object obj) {
				heardEvent = true;
			};
			contextViewObject.Disable ();

			Assert.That (heardEvent, Is.True);
		}

37. Example

View license
[Test]
		public void releases_command()
		{
			object command = new object();
			bool wasReleased = false;
			context.Released += delegate (object obj) {
				wasReleased = true;
			};
			subject.Detain(command);

			subject.Release(command);

			Assert.That(wasReleased, Is.True);
		}

38. Example

View license
[Test]
		public void ViewStateWatcher_Hears_When_View_Is_Added()
		{
			bool heardEvent = false;
			context.Configure (new ContextView (contextViewObject));
			IViewStateWatcher actual = context.injector.GetInstance<IViewStateWatcher>() as IViewStateWatcher;
			actual.added += delegate(object obj) {
				heardEvent = true;
			};
			contextViewObject.AddThisView ();

			Assert.That (heardEvent, Is.True);
		}

39. Example

View license
[Test]
		public void adding_after_initializing_hander_during_configure_is_allowed()
		{
			bool hasDoneCallback = false;
			context.Configure(new CallbackConfig(delegate {
				context.AfterInitializing(delegate {
					hasDoneCallback = true;
				});
			}));
			context.Initialize ();
			Assert.That(hasDoneCallback, Is.True);
		}

40. Example

View license
[Test]
		public void Dispatch_DispatchesEvent_On_The_EventDisaptcher()
		{
			bool called = false;
			eventDispatcher.AddEventListener (SupportEvent.Type.TYPE1, (Action)delegate {
				called = true;
			});
			instance.Try_dispatch(new SupportEvent(SupportEvent.Type.TYPE1));
			Assert.That (called, Is.True);
		}

41. Example

View license
[Test]
		public void lifecycleStateChangeEvent_is_propagated()
		{
			bool called = false;
			context.STATE_CHANGE += delegate() {
				called = true;
			};
			context.Initialize();
			Assert.That(called, Is.True);
		}

42. Example

View license
[Test] //TODO: Make this unit test work
		public void commands_mapped_during_execution_are_not_executed()
		{
			injector.Map(typeof(IEventCommandMap)).ToValue(subject);	
			injector.Map(typeof(Type), "nestedCommand").ToValue(typeof(ClassReportingCallbackCommand));
			subject.Map(SupportEvent.Type.TYPE1, typeof(IEvent))
				.ToCommand<CommandMappingCommand>().Once();
			dispatcher.Dispatch(new SupportEvent(SupportEvent.Type.TYPE1));
			Assert.That(reportedExecutions, Is.Empty);
		}

43. Example

View license
[Test]
		public void listener_mapped_with_type_and_unmapped_without_type_fires_in_response_to_typed_event()
		{
			eventMap.MapListener(eventDispatcher, CustomEvent.Type.STARTED, (Action<IEvent>)listener, typeof(CustomEvent));
			eventMap.UnmapListener(eventDispatcher, CustomEvent.Type.STARTED, (Action<IEvent>)listener);
			eventDispatcher.Dispatch(new CustomEvent(CustomEvent.Type.STARTED));
			Assert.That(listenerExecuted, Is.True);
		}

44. Example

View license
[Test]
		public void plain_config_object_added_before_initializiation_is_not_injected_into()
		{
			PlainConfig expected = new PlainConfig();
			object actual = null;
			injector.Map(typeof(Action<PlainConfig>), "callback").ToValue((Action<PlainConfig>)delegate(PlainConfig config) {
				actual = config;
			});

			configManager.AddConfig(expected);

			Assert.That(actual, Is.Null);
		}

45. Example

View license
[Test]
		public void Channels_Are_Isolated()
		{
			parentConnector.OnDefaultChannel()
				.RelayEvent(SupportEvent.Type.TYPE1);
			childAConnector.OnChannel("other-channel")
				.ReceiveEvent(SupportEvent.Type.TYPE1);

			bool wasCalled =false;
			childADispatcher.AddEventListener(SupportEvent.Type.TYPE1, delegate(IEvent evt) {
				wasCalled = true;
			});

			parentDispatcher.Dispatch(new SupportEvent(SupportEvent.Type.TYPE1));

			Assert.That (wasCalled, Is.False);
		}

46. Example

View license
[Test]
		public void Extension_Logs_Error_When_Context_Initialized_With_No_ContextView()
		{
			bool errorLogged = false;
			CallbackLogTarget logTarget = new CallbackLogTarget(delegate (LogParams result) {
				if(result.level == LogLevel.ERROR && result.source.GetType() == typeof(ModularityExtension))
					errorLogged = true;
				});
			childContext.Install(typeof(ModularityExtension)).Install(typeof(SupportParentFinderExtension));
			childContext.AddLogTarget(logTarget);
			childContext.Initialize();
			Assert.That (errorLogged, Is.True);
		}

47. Example

View license
[Test]
		public void extension_logs_error_when_context_initialized_with_no_contextView()
		{
			bool errorLogged = false;
			CallbackLogTarget logTarget= new CallbackLogTarget(delegate(LogParams log) {
				if (log.source is ContextViewExtension && log.level == LogLevel.ERROR)
				{
					errorLogged = true;
				}
			});
			context.Install<ContextViewExtension>();
			context.AddLogTarget(logTarget);
			context.Initialize();
			Assert.That(errorLogged, Is.True);
		}

48. Example

View license
[Test]
		public void listener_mapped_without_type_is_triggered_by_correct_typed_event()
		{
			eventMap.MapListener(eventDispatcher, CustomEvent.Type.STARTED, (Action<IEvent>)listener);
			eventDispatcher.Dispatch(new CustomEvent(CustomEvent.Type.STARTED));
			Assert.That(listenerExecuted, Is.True);
		}

49. Example

View license
[Test]
		public void listener_mapped_and_unmapped_with_type_doesnt_fire_in_response_to_typed_or_plain_event()
		{
			eventMap.MapListener(eventDispatcher, CustomEvent.Type.STARTED, (Action<IEvent>)listener, typeof(CustomEvent));
			eventMap.UnmapListener(eventDispatcher, CustomEvent.Type.STARTED, (Action<IEvent>)listener, typeof(CustomEvent));
			eventDispatcher.Dispatch(new Event(CustomEvent.Type.STARTED));
			eventDispatcher.Dispatch(new CustomEvent(CustomEvent.Type.STARTED));
			Assert.That(listenerExecuted, Is.False);
		}

50. Example

View license
[Test]
		public void all_listeners_can_be_unmapped_while_suspended()
		{
			eventMap.MapListener(eventDispatcher, CustomEvent.Type.STARTED, (Action<IEvent>)listener);
			eventMap.MapListener(eventDispatcher, EventType.COMPLETE, (Action<IEvent>)listener);
			eventMap.MapListener(eventDispatcher, EventType.CHANGE, (Action<IEvent>)listener);
			eventMap.Suspend();
			eventMap.UnmapListeners();
			eventMap.Resume();
			eventDispatcher.Dispatch(new CustomEvent(CustomEvent.Type.STARTED));
			eventDispatcher.Dispatch(new Event(EventType.COMPLETE));
			eventDispatcher.Dispatch(new Event(EventType.CHANGE));
			Assert.That(listenerExecuted, Is.False);
		}