コード例 #1
0
        public void RandomizerTest2()
        {
            // Test needs to run in parallel to RandomizerTest
            // Checks that Parallel test runs don't share randomizer seeds

            for (int i = 0; i < 10; i++)
            {
                var randomizedObject = new
                {
                    String   = PseudoRandom.String(),
                    Int      = PseudoRandom.Int(),
                    DateTime = PseudoRandom.DateTime()
                };

                DiskAssert.Matches(randomizedObject, $"RandomizedObj_{i}");

                Thread.Sleep(1000);
            }
        }
コード例 #2
0
        public void ReachAllFieldsOfAllTypes()
        {
            //  # Arrange.
            var     pr  = new PseudoRandom(nameof(ReachAllFieldsOfAllTypes));
            dynamic sut = new ReachIn(typeof(MyStaticBaseClassWithTypes));

            //  #   Act and Assert.
            var anyIntValue = pr.Int();

            sut._myPrivateStaticIntField = anyIntValue;
            // We have a problem here with FluentAssertions where it, runtime, throws an exception even though the parameters are equal.
            //sut._myPrivateStaticIntField.Should().be(anyIntValue);
            Assert.Equal(anyIntValue, sut._myPrivateStaticIntField);

            var anyStringValue = pr.String();

            sut._myPrivateStaticStringField = anyStringValue;
            // We have a problem here with FluentAssertions where it, runtime, throws an exception even though the parameters are equal.
            //sut._myPrivateStaticStringField.Should().Be(anyStringValue);
            Assert.Equal(anyStringValue, sut._myPrivateStaticStringField);

            var anyLongValue = pr.PositiveLong();

            sut._myPrivateStaticLongField = anyLongValue;
            // We have a problem here with FluentAssertions where it, runtime, throws an exception even though the parameters are equal.
            //sut._myPrivateStaticLongField.Should().be(anyLongValue);
            Assert.Equal(anyLongValue, sut._myPrivateStaticLongField);

            var anyObject =
                new
            {
                FieldOne = pr.Int(),
            };

            sut._myPrivateStaticObjectField = anyObject;
            // We have a problem here with FluentAssertions where it, runtime, throws an exception even though the parameters are equal.
            //sut._myPrivateStaticObjectField.FieldOne.Should().Be(anyObject.FieldOne);
            Assert.Equal(anyObject.FieldOne, sut._myPrivateStaticObjectField.FieldOne);

            // If there is any other type to test, this is the place to add.
        }
コード例 #3
0
 internal Dto WithRandomisedNonPublic(PseudoRandom pr)
 {
     return(SetNonPublic(pr.String(), pr.String(), pr.String()));
 }
コード例 #4
0
 internal static Dto CreateRandomised(PseudoRandom pr)
 {
     return(CreateSetAllProperties(pr.String(), pr.String(), pr.String(), pr.String(), pr.Int()));
 }
コード例 #5
0
 /// <summary>This helper method returns an "any" director name
 /// which is a (determinastically) randomised string.
 /// The length 12 just happens to be any length.
 /// </summary>
 /// <returns></returns>
 internal static string AnyDirectoryName(PseudoRandom pr)
 {
     return(pr.String(12));
 }
コード例 #6
0
 /// <summary>This helper method returns an "any" filename
 /// which is a (determinastically) randomised string.
 /// The length 14 just happens to be any length
 /// and the filename lacks suffix as the test is not affected by suffix or not.
 /// </summary>
 /// <returns></returns>
 internal static string AnyFilename(PseudoRandom pr)
 {
     return(pr.String(14));
 }