NUnit.Framework.Assert.True(bool, string)

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

200 Examples 7

1. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
[Test]
        public void OperatorEquals_ToSelf_IsTrue()
        {
            // Warning CS1718: Comparison made to same variable; did you mean to compare something else?
            // This is intentional for testing
#pragma warning disable 1718
            Assert.True(one == one, "1 == 1 (same object)");
#pragma warning restore 1718
        }

2. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
[Test]
        public void OperatorEquals_WithEqualTicks_IsTrue()
        {
            Assert.True(one == onePrime, "1 == 1 (different objects)");
        }

3. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
[Test]
        public void OperatorNotEquals_WithDifferentTicks_IsTrue()
        {
            Assert.True(one != negativeOne, "1 != -1");
            Assert.True(one != threeMillion, "1 != 3,000,000");
            Assert.True(one != negativeFiftyMillion, "1 != -50,000,000");
            Assert.True(Instant.MinValue != Instant.MaxValue, "MinValue != MaxValue");
        }

4. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
[Test]
        public void OperatorLessThan_MoreTicks_IsTrue()
        {
            Assert.True(one < threeMillion, "1 < 3,000,000");
            Assert.True(negativeFiftyMillion < negativeOne, "-50,000,000 < -1");
            Assert.True(Instant.MinValue < Instant.MaxValue, "MinValue < MaxValue");
        }

5. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
[Test]
        public void OperatorLessThanOrEqual_Self_IsTrue()
        {
            // Warning CS1718: Comparison made to same variable; did you mean to compare something else?
            // This is intentional for testing
#pragma warning disable 1718
            Assert.True(one <= one, "1 <= 1 (same object)");
#pragma warning restore 1718
        }

6. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
[Test]
        public void OperatorLessThanOrEqual_EqualTicks_IsTrue()
        {
            Assert.True(one <= onePrime, "1 <= 1 (different objects)");
        }

7. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
[Test]
        public void OperatorLessThanOrEqual_MoreTicks_IsTrue()
        {
            Assert.True(one <= threeMillion, "1 <= 3,000,000");
            Assert.True(negativeFiftyMillion <= negativeOne, "-50,000,000 <= -1");
            Assert.True(Instant.MinValue <= Instant.MaxValue, "MinValue <= MaxValue");
        }

8. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
[Test]
        public void OperatorGreaterThan_LessTicks_IsTrue()
        {
            Assert.True(threeMillion > one, "3,000,000 > 1");
            Assert.True(negativeOne > negativeFiftyMillion, "-1 > -50,000,000");
            Assert.True(Instant.MaxValue > Instant.MinValue, "MaxValue > MinValue");
        }

9. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
[Test]
        public void OperatorGreaterThanOrEqual_Self_IsTrue()
        {
            // Warning CS1718: Comparison made to same variable; did you mean to compare something else?
            // This is intentional for testing
#pragma warning disable 1718
            Assert.True(one >= one, "1 >= 1 (same object)");
#pragma warning restore 1718
        }

10. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
[Test]
        public void OperatorGreaterThanOrEqual_EqualTicks_IsTrue()
        {
            Assert.True(one >= onePrime, "1 >= 1 (different objects)");
        }

11. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
[Test]
        public void OperatorGreaterThanOrEqual_LessTicks_IsTrue()
        {
            Assert.True(threeMillion >= one, "3,000,000 >= 1");
            Assert.True(negativeOne >= negativeFiftyMillion, "-1 >= -50,000,000");
            Assert.True(Instant.MaxValue >= Instant.MinValue, "MaxValue >= MinValue");
        }

12. Example

Project: NodaTime
Source File: LocalInstantTest.Operators.cs
[Test]
        public void OperatorEquals_ToSelf_IsTrue()
        {
            // Warning CS1718: Comparison made to same variable; did you mean to compare something else?
            // This is intentional for testing
#pragma warning disable 1718
            Assert.True(one == one, "1 == 1 (same object)");
#pragma warning restore 1718
        }

13. Example

Project: NodaTime
Source File: LocalInstantTest.Operators.cs
[Test]
        public void OperatorEquals_WithEqualTicks_IsTrue()
        {
            Assert.True(one == onePrime, "1 == 1 (different objects)");
        }

14. Example

Project: NodaTime
Source File: LocalInstantTest.Operators.cs
[Test]
        public void OperatorNotEquals_WithDifferentTicks_IsTrue()
        {
            Assert.True(one != negativeOne, "1 != -1");
            Assert.True(one != threeMillion, "1 != 3,000,000");
            Assert.True(one != negativeFiftyMillion, "1 != -50,000,000");
            Assert.True(LocalInstant.MinValue != LocalInstant.MaxValue, "MinValue != MaxValue");
        }

15. Example

Project: NodaTime
Source File: LocalInstantTest.Operators.cs
[Test]
        public void OperatorLessThan_MoreTicks_IsTrue()
        {
            Assert.True(one < threeMillion, "1 < 3,000,000");
            Assert.True(negativeFiftyMillion < negativeOne, "-50,000,000 < -1");
            Assert.True(LocalInstant.MinValue < LocalInstant.MaxValue, "MinValue < MaxValue");
        }

16. Example

Project: NodaTime
Source File: LocalInstantTest.Operators.cs
[Test]
        public void OperatorLessThanOrEqual_Self_IsTrue()
        {
            // Warning CS1718: Comparison made to same variable; did you mean to compare something else?
            // This is intentional for testing
#pragma warning disable 1718
            Assert.True(one <= one, "1 <= 1 (same object)");
#pragma warning restore 1718
        }

17. Example

Project: NodaTime
Source File: LocalInstantTest.Operators.cs
[Test]
        public void OperatorLessThanOrEqual_EqualTicks_IsTrue()
        {
            Assert.True(one <= onePrime, "1 <= 1 (different objects)");
        }

18. Example

Project: NodaTime
Source File: LocalInstantTest.Operators.cs
[Test]
        public void OperatorLessThanOrEqual_MoreTicks_IsTrue()
        {
            Assert.True(one <= threeMillion, "1 <= 3,000,000");
            Assert.True(negativeFiftyMillion <= negativeOne, "-50,000,000 <= -1");
            Assert.True(LocalInstant.MinValue <= LocalInstant.MaxValue, "MinValue <= MaxValue");
        }

19. Example

Project: NodaTime
Source File: LocalInstantTest.Operators.cs
[Test]
        public void OperatorGreaterThan_LessTicks_IsTrue()
        {
            Assert.True(threeMillion > one, "3,000,000 > 1");
            Assert.True(negativeOne > negativeFiftyMillion, "-1 > -50,000,000");
            Assert.True(LocalInstant.MaxValue > LocalInstant.MinValue, "MaxValue > MinValue");
        }

20. Example

Project: NodaTime
Source File: LocalInstantTest.Operators.cs
[Test]
        public void OperatorGreaterThanOrEqual_Self_IsTrue()
        {
            // Warning CS1718: Comparison made to same variable; did you mean to compare something else?
            // This is intentional for testing
#pragma warning disable 1718
            Assert.True(one >= one, "1 >= 1 (same object)");
#pragma warning restore 1718
        }

21. Example

Project: NodaTime
Source File: LocalInstantTest.Operators.cs
[Test]
        public void OperatorGreaterThanOrEqual_EqualTicks_IsTrue()
        {
            Assert.True(one >= onePrime, "1 >= 1 (different objects)");
        }

22. Example

Project: NodaTime
Source File: LocalInstantTest.Operators.cs
[Test]
        public void OperatorGreaterThanOrEqual_LessTicks_IsTrue()
        {
            Assert.True(threeMillion >= one, "3,000,000 >= 1");
            Assert.True(negativeOne >= negativeFiftyMillion, "-1 >= -50,000,000");
            Assert.True(LocalInstant.MaxValue >= LocalInstant.MinValue, "MaxValue >= MinValue");
        }

23. Example

Project: SampleMvcWebApp
Source File: ExtendAsserts.cs
internal static void ShouldNotEqual(this string actualValue, string expectedValue, string errorMessage = null)
        {
            Assert.True(expectedValue != actualValue, errorMessage);
        }

24. Example

Project: EfSchemaCompare
Source File: ExtendAsserts.cs
internal static void ShouldNotEqual(this string actualValue, string expectedValue, string errorMessage = null)
        {
            Assert.True(expectedValue != actualValue, errorMessage);
        }

25. Example

Project: GenericServices
Source File: ExtendAsserts.cs
internal static void ShouldNotEqual(this string actualValue, string expectedValue, string errorMessage = null)
        {
            Assert.True(expectedValue != actualValue, errorMessage);
        }

26. Example

Project: NFig
Source File: EnumTests.cs
[Test]
        public void EnumTest()
        {
            var factory = Utils.CreateFactory<EnumSettings>();
            var s = factory.GetSettings();

            Assert.True(s.First == TestEnum.Zero, "First");
            Assert.True(s.Second == TestEnum.One, "Second");
            Assert.True(s.Third == TestEnum.Two, "Third");
            Assert.True(s.Fourth == TestEnum.Three, "Fourth");
        }

27. Example

Project: NFig
Source File: PrimitiveTests.cs
[Test]
        public void PrimitivesTest()
        {
            var factory = Utils.CreateFactory<PrimitiveSettings>();
            var s = factory.GetSettings();

            Assert.True(s.Bool == true, "Bool");
            Assert.True(s.Byte == 128, "Byte");
            Assert.True(s.Short == -1200, "Short");
            Assert.True(s.UShort == 1200, "UShort");
            Assert.True(s.Int == -85000, "Int");
            Assert.True(s.UInt == 85000, "UInt");
            Assert.True(s.Long == -8000000000, "Long");
            Assert.True(s.ULong == 8000000000, "ULong");
            Assert.True(s.Float == 3.14f, "Float");
            Assert.True(s.Double == 2.737, "Double");
            Assert.True(s.String == "hey", "String");
            Assert.True(s.Char == 'c', "Char");
            Assert.True(s.Decimal == 0.2m, "Decimal");
        }

28. Example

Project: pMixins
Source File: MixinCodeBehindFileIsRecreatedOnItmeSave.cs
public override void MainSetup()
        {
            base.MainSetup();

            //Simulate a Delete on mixin code behind.
            var codeBehind = _MockSolution.AllMockFiles().FirstOrDefault(x => x.FileName.EndsWith(".mixin.cs"));

            Assert.True(null != codeBehind, "Code Behind File was not generated!");

            EventProxy.FireOnProjectItemRemoved(this, 
                new ProjectItemRemovedEventArgs
                {
                    ClassFullPath = codeBehind.FileName,
                    ProjectFullPath = _MockSolution.Projects[0].FileName
                });

            //Simulate Item Saved
            EventProxy.FireOnProjectItemSaved(this,
                new ProjectItemSavedEventArgs
                {
                    ClassFullPath = _sourceFile.FileName,
                    ProjectFullPath = _MockSolution.Projects[0].FileName
                });
        }

29. Example

Project: pMixins
Source File: NewDependenciesAreDiscoveredTest.cs
[Test]
        public void CodeBehindFileIsGeneratedAndCompiles()
        {
            Assert.True(
                _MockSolution.AllMockFiles().Any(x => x.FileName.EndsWith("mixin.cs")),
                "Found a mixin.cs code behind file.");

            var compilerResults =
                AssertProjectCompiles(_MockSolution.Projects[1]);

            compilerResults
                .ExecuteMethod<int>(
                    "Testing.Target",
                    "NumberMethod")
                .ShouldEqual(42); 
        }

30. Example

Project: pMixins
Source File: OnItemSaveForDependency.cs
[Test]
        public void CodeBehindFileIsGeneratedAndCompiles()
        {
            Assert.True(
                _MockSolution.AllMockFiles().Any(x => x.FileName.EndsWith("mixin.cs")),
                "Found a mixin.cs code behind file.");

            _MockCodeBehindFileHelper.AssertWasCalled(
                x => x.GetOrAddCodeBehindFile(Arg<string>.Is.Equal(_targetSourceFile.FileName)),
                options => options.Repeat.Once());

            _MockFileWrapper.AssertWasCalled(
                x => x.WriteAllText(Arg<string>.Is.Equal(_targetSourceFile.FileName), Arg<string>.Is.Anything),
                options => options.Repeat.Once());

            var compilerResults =
               AssertProjectCompiles(_MockSolution.Projects[1]);

            compilerResults
               .ExecuteMethod<int>(
                   "Testing.Target",
                   "AMethod")
               .ShouldEqual(1); 
        }

31. Example

Project: pMixins
Source File: OnItemSaveForNonPMixinFile.cs
[Test]
        public void CodeBehindFileIsNotGenerated()
        {
            Assert.True(
                _MockSolution.AllMockFiles().All(x => !x.FileName.EndsWith("mixin.cs")),
                "Found a mixin.cs code behind file.");

            _MockCodeBehindFileHelper.AssertWasNotCalled(
                x => x.GetOrAddCodeBehindFile(Arg<string>.Is.Anything));

            _MockFileWrapper.AssertWasNotCalled(
                x => x.WriteAllText(Arg<string>.Is.Anything, Arg<string>.Is.Anything));
        }

32. Example

Project: pMixins
Source File: OnItemSaveForPMixinFileWithNoDependencies.cs
[Test]
        public void CodeBehindFileIsGeneratedAndCompiles()
        {
            Assert.True(
                _MockSolution.AllMockFiles().Any(x => x.FileName.EndsWith("mixin.cs")),
                "Found a mixin.cs code behind file.");

            _MockCodeBehindFileHelper.AssertWasCalled(
                x => x.GetOrAddCodeBehindFile(Arg<string>.Is.Equal(_sourceFile.FileName)),
                options => options.Repeat.AtLeastOnce());

            var mixinFileName = _sourceFile.FileName.Replace(".cs", ".mixin.cs");

            _MockFileWrapper.AssertWasCalled(
                x => x.WriteAllText(Arg<string>.Is.Equal(mixinFileName), Arg<string>.Is.Anything),
                options => options.Repeat.AtLeastOnce());

            var compilerResults =
              AssertProjectCompiles(_MockSolution.Projects[0]);

            compilerResults
               .ExecuteMethod<int>(
                   "Testing.Target",
                   "AMethod")
               .ShouldEqual(1); 
        }

33. Example

Project: pMixins
Source File: SolutionFactoryTest.cs
[Test]
        public void CanLoadSolutionFile()
        {
            var solution = Kernel.Get<ISolutionFactory>().BuildCurrentSolution();

            Assert.True(null != solution, "Solution is null after LoadSolution");

            Assert.True(null != solution.Projects, "Solution.Projects is null after LoadSolution");

            Assert.True(solution.Projects.Count > 2, "Solution.Projects is less than expected (2)");
        }

34. Example

Project: pMixins
Source File: OnProjectItemRemovedTest.cs
public override void MainSetup()
        {
            base.MainSetup();

            // Set Initial Solution State
            _MockSolution.Projects.Add(new MockProject
            {
                MockSourceFiles = { _sourceFile }
            });
            
            //Warm Caches by loading solution.
            var solution = TestSpecificKernel.Get<ISolutionFactory>().BuildCurrentSolution();

            //Ensure Basic Class is in the solution
            Assert.True(null != solution.FindCSharpFileByFileName(_sourceFile.FileName),
                "Basic File was not found in Solution.  Test Environment is not valid.");

            //Simulate Project Item Removed (Basic Class)
            _MockSolution.Projects[0].MockSourceFiles.Clear();
            
            //Fire Project Item Event
            EventProxy.FireOnProjectItemRemoved(this, new ProjectItemRemovedEventArgs
            {
                ClassFullPath = _sourceFile.FileName,
                ProjectFullPath = _MockSolution.Projects[0].FileName
            });
        }

35. Example

Project: pMixins
Source File: OnProjectItemRemovedTest.cs
[Test]
        public void FileShouldBeLoadedIntoSolution()
        {
            var solution = TestSpecificKernel.Get<ISolutionFactory>().BuildCurrentSolution();

            Assert.True(null != solution, "BuildCurrentSolution() returned a null solution.");

            var csharpBasicFile = solution.FindCSharpFileByFileName(_sourceFile.FileName);

            Assert.True(null == csharpBasicFile, "Solution contained Basic Class File");
        }

36. Example

Project: pMixins
Source File: MockSolutionCommonTests.cs
public static void AssertCodeBehindFileWasNotGenerated(this MockSolutionTestBase mockSolutionTest)
        {
            Assert.True(
                mockSolutionTest._MockSolution.AllMockFiles().All(x => !x.FileName.Extension.Equals("mixin.cs")),
                "Found a mixin.cs code behind file.");

            mockSolutionTest._MockCodeBehindFileHelper.AssertWasNotCalled(
                x => x.GetOrAddCodeBehindFile(Arg<FilePath>.Is.Anything));

            mockSolutionTest._MockFileWrapper.AssertWasNotCalled(
                x => x.WriteAllText(Arg<FilePath>.Is.Anything, Arg<string>.Is.Anything));
        }

37. Example

Project: pMixins
Source File: MixinIsInternalType.cs
[Test]
        public void InternalMethodShouldHaveCorrectModifier()
        {
            var target = CompilerResults.TryLoadCompiledType("Test.Target");

            var method = target.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
                .FirstOrDefault(m => m.Name == "InternalMethod");

            Assert.True(null != method, "Couldn't load method definition");

            method.IsPublic.ShouldBeFalse();
        }

38. Example

Project: pMixins
Source File: MixinAttributesAreInjectedIntoTarget.cs
public override void MainSetup()
        {
            base.MainSetup();

            var targetInstance = CompilerResults.TryLoadCompiledType("Test.Target");

            Assert.True(null != targetInstance, "Failed to get Target instance");

            TargetType = targetInstance.GetType();
        }

39. Example

Project: pMixins
Source File: MixinConstDataMembersAreInjectedIntoTarget.cs
[Test]
        public void CanNotSetDataMemberValue()
        {
            var targetInstance =
                CompilerResults.TryLoadCompiledType("Test.Target");

            Assert.True(null != targetInstance,
                "Could not load Target instance");

            var dataMemberProperty =
                targetInstance.GetType().GetProperty("DataMember");

            Assert.True(null != dataMemberProperty,
                "Could not load Data Member Property");

            Assert.True(false == dataMemberProperty.CanWrite,
                "Data Member property Can Write - but should not have a setter");
            
        }

40. Example

Project: pMixins
Source File: MixinGenericMembersAreInjectedIntoTarget.cs
[Test]
        public void CanCallProperty()
        {
            var testList = new List<int>{42};

            dynamic target = CompilerResults.TryLoadCompiledType("Test.Target");

            target.GenericProperty = testList;

            Assert.True(target.GenericProperty.Contains(42), "Property get/set failed.");


        }

41. Example

Project: pMixins
Source File: MixinReadonlyDataMembersAreInjectedIntoTarget.cs
[Test]
        public void CanNotSetDataMemberValue()
        {
            var targetInstance =
                CompilerResults.TryLoadCompiledType("Test.Target");

            Assert.True(null != targetInstance,
                "Could not load Target instance");

            var dataMemberProperty =
                targetInstance.GetType().GetProperty("DataMember");

            Assert.True(null != dataMemberProperty,
                "Could not load Data Member Property");

            Assert.True(false == dataMemberProperty.CanWrite,
                "Data Member property Can Write - but should not have a setter");
            
        }

42. Example

Project: pMixins
Source File: CancellationInterceptorTest.cs
[Test]
        public void InterceptorCanceledMethodInvocation()
        {
            dynamic target = CompilerResults.TryLoadCompiledType("Test.Target");

            Assert.True(target.Method() == "Interceptor", "Method() should be intercepted");

            Assert.True(target.WasMethodCalled == false, "WasMethodCalled should be false");
        }

43. Example

Project: pMixins
Source File: InterceptorSuppressesException.cs
public override void MainSetup()
        {
            base.MainSetup();

            target = CompilerResults.TryLoadCompiledType("Test.Target");

            Assert.True(null != target, "Failed to load Target");
        }

44. Example

Project: pMixins
Source File: InterceptorSuppressesException.cs
[Test]
        public void InterceptorSuppressesMethodException()
        {
            Assert.True(target.Method() == "Intercepted", "Exception in method should be suppressed");
        }

45. Example

Project: pMixins
Source File: InterceptorSuppressesException.cs
[Test]
        public void InterceptorSuppressesPropertyException()
        {
            Assert.True(target.Property == "Intercepted", "Exception in property should be suppressed");
        }

46. Example

Project: pMixins
Source File: InterceptorWithMixinRequirementTest.cs
[Test]
        public void MixinRequiredByInterceptorIsMixedIntoTarget()
        {
            dynamic target = CompilerResults.TryLoadCompiledType("Test.Target");

            target.AddLogMessage("Test");

            Assert.True(target.Messages.Count > 0, "No evidence Mixin method AddLogMessage was called.");
        }

47. Example

Project: pMixins
Source File: InterceptorWithMixinRequirementTest.cs
[Test]
        public void InterceptorManipulatedMethodReturnValue()
        {
            dynamic target = CompilerResults.TryLoadCompiledType("Test.Target");
            
            Assert.True(target.Method() == "Mixin", "Method() should return correct value");

            Assert.True(target.Messages.Count > 1, "No evidence Mixin method AddLogMessage was called.");

            Assert.True(target.Messages.Contains("OnBeforeMethod: Method"), "OnBeforeMethod event was not logged");

            Assert.True(target.Messages.Contains("OnAfterMethod: Method"), "OnAfterMethod event was not logged");
        }

48. Example

Project: pMixins
Source File: ManipulateReturnValueInterceptorTest.cs
[Test]
        public void InterceptorManipulatedMethodReturnValue()
        {
            dynamic target = CompilerResults.TryLoadCompiledType("Test.Target");

            Assert.True(target.Method() == "Mixin_Interceptor", "Method() should be intercepted and return value manipulated");

            Assert.True(target.WasMethodCalled == true, "WasMethodCalled should be true");
        }

49. Example

Project: NServiceBus.MongoDB
Source File: When_starting_an_endpoint_with_a_saga.cs
[Test]
        public async Task Should_autoSubscribe_the_saga_messageHandler_by_default()
        {
            var context = await Scenario.Define<Context>()
                .WithEndpoint<Subscriber>()
                .Done(c => c.EventsSubscribedTo.Count >= 2)
                .Run();

            Assert.True(context.EventsSubscribedTo.Contains(typeof(MyEvent)), "Events only handled by sagas should be auto subscribed");
            Assert.True(context.EventsSubscribedTo.Contains(typeof(MyEventBase)), "Sagas should be auto subscribed even when handling a base class event");
        }

50. Example

Project: FieldWorks
Source File: FirstBetaMigratorTests.cs
[Test]
		public void MigrateFrom83Alpha_SenseVariantListTypeOptionsAreMigrated()
		{
			var alphaVar/n ..... /n //View Source file for more details /n }