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

View license
[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");
        }

2. Example

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

3. Example

View license
[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");
        }

4. Example

View license
[Test]
        public void OperatorGreaterThanOrEqual_EqualTicks_IsTrue()
        {
            Assert.True(one >= onePrime, "1 >= 1 (different objects)");
        }

5. Example

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

6. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
View license
[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
        }

7. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
View license
[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");
        }

8. Example

View license
[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
        }

9. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
View license
[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");
        }

10. Example

View license
[Test]
        public void OperatorEquals_WithEqualTicks_IsTrue()
        {
            Assert.True(one == onePrime, "1 == 1 (different objects)");
        }

11. Example

View license
[Test]
        public void OperatorLessThanOrEqual_EqualTicks_IsTrue()
        {
            Assert.True(one <= onePrime, "1 <= 1 (different objects)");
        }

12. Example

View license
[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");
        }

13. Example

View license
[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");
        }

14. Example

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

15. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
View license
[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");
        }

16. Example

View license
[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: InstantTest.Operators.cs
View license
[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");
        }

18. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
View license
[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");
        }

19. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
View license
[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
        }

20. Example

View license
[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

View license
[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");
        }

22. Example

Project: NodaTime
Source File: InstantTest.Operators.cs
View license
[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
        }

23. Example

Project: SampleMvcWebApp
Source File: ExtendAsserts.cs
View license
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
View license
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
View license
internal static void ShouldNotEqual(this string actualValue, string expectedValue, string errorMessage = null)
        {
            Assert.True(expectedValue != actualValue, errorMessage);
        }

26. Example

Project: NFig
Source File: PrimitiveTests.cs
View license
[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");
        }

27. Example

Project: NFig
Source File: EnumTests.cs
View license
[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");
        }

28. Example

Project: pMixins
Source File: OnProjectItemRemovedTest.cs
View license
[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");
        }

29. Example

View license
[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");
            
        }

30. Example

View license
[Test]
        public void InterceptorSuppressesMethodException()
        {
            Assert.True(target.Method() == "Intercepted", "Exception in method should be suppressed");
        }

31. Example

View license
public override void MainSetup()
        {
            base.MainSetup();

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

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

32. Example

View license
public override void MainSetup()
        {
            base.MainSetup();

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

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

            TargetType = targetInstance.GetType();
        }

33. Example

Project: pMixins
Source File: MockSolutionCommonTests.cs
View license
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));
        }

34. Example

View license
[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");
        }

35. Example

View license
[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); 
        }

36. Example

View license
[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.");
        }

37. Example

Project: pMixins
Source File: OnProjectItemRemovedTest.cs
View license
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
            });
        }

38. Example

View license
[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.");


        }

39. Example

View license
[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");
        }

40. Example

View license
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
                });
        }

41. Example

View license
[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); 
        }

42. Example

Project: pMixins
Source File: MixinIsInternalType.cs
View license
[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();
        }

43. Example

Project: pMixins
Source File: OnItemSaveForDependency.cs
View license
[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); 
        }

44. Example

View license
[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");
        }

45. Example

View license
[Test]
        public void InterceptorSuppressesPropertyException()
        {
            Assert.True(target.Property == "Intercepted", "Exception in property should be suppressed");
        }

46. Example

View license
[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));
        }

47. Example

Project: pMixins
Source File: SolutionFactoryTest.cs
View license
[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)");
        }

48. Example

View license
[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");
            
        }

49. Example

View license
[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

View license
private void SetupReversalFactoriesAndRepositories()
		{
			Assert.True(Cache != null, "No cache yet!?");
			m_revIndexEntryFactory = Cache.ServiceLocator.GetInstance<IReversalIndexEntryFactory>();
			m_revIndexFactory = Cache.ServiceLocator.GetInstance<IReversalIndexFactory>();
			m_revIndexRepo = Cache.ServiceLocator.GetInstance<IReversalIndexRepository>();
		}