示例#1
0
        public static void SettingArgDisplayNamesAfterSettingNameThrowsInvalidOperationException()
        {
            var caseData = new TestCaseData(42).SetName("Name");

            Assert.That(() => caseData.SetArgDisplayNames("42"), Throws.InvalidOperationException);

            var fixtureData = new TestCaseData(42).SetName("Name");

            Assert.That(() => fixtureData.SetArgDisplayNames("42"), Throws.InvalidOperationException);
        }
示例#2
0
        public static void ArgDisplayNamesCanBeReset()
        {
            var caseData = new TestCaseData(42).SetArgDisplayNames("42");

            caseData.SetArgDisplayNames(null);
            Assert.That(caseData.ArgDisplayNames, Is.Null);

            var fixtureData = new TestFixtureData(42).SetArgDisplayNames("42");

            fixtureData.SetArgDisplayNames(null);
            Assert.That(fixtureData.ArgDisplayNames, Is.Null);
        }
示例#3
0
        public static void ResettingArgDisplayNamesAfterSettingNameIsNoOp()
        {
            var caseData = new TestCaseData(42).SetName("Name");

            caseData.SetArgDisplayNames(null);
            Assert.That(caseData.TestName, Is.EqualTo("Name"));

            var fixtureData = new TestCaseData(42).SetName("Name");

            fixtureData.SetArgDisplayNames(null);
            Assert.That(fixtureData.TestName, Is.EqualTo("Name"));
        }
    public static IEnumerable <TestCaseData> GetAssertParams()
    {
        List <TestCaseData> returnData = new List <TestCaseData>();

        foreach (var e in listOfEnumsWithArgumentsAmount)
        {
            Array enumFields = Enum.GetValues(e);
            foreach (var enumField in enumFields)
            {
                foreach (var arguments in GetListOfArguments((Enum)enumField))
                {
                    var testCaseData = new TestCaseData(enumField, arguments);
                    testCaseData.SetArgDisplayNames(FormatTestArguments(enumField, arguments));
                    returnData.Add(testCaseData);
                }
            }
        }
        foreach (var returnedTestCaseData in returnData)
        {
            yield return(returnedTestCaseData);
        }
    }
 public static TestCaseData WithArgsDisplayName(
     this TestCaseData data,
     string name)
 {
     return(data.SetArgDisplayNames(CompatibleDisplayName(name)));
 }
示例#6
0
        //---------------------------------------------------------------------
        private static IEnumerable <TestCaseData> Correct_status_TestCases()
        {
            // Cases based on https://github.com/dotnet/corefx/issues/42245#issuecomment-548359376

            // D1
            bool            isFinalBlock     = true;
            int             sourceLength     = 4;
            int             destLength       = 3;
            OperationStatus expectedStatus   = OperationStatus.Done;
            int             expectedConsumed = 4;
            int             expectedWritten  = 3;

            yield return(CreateTestCase());

            // D2
            sourceLength     = 5;
            destLength       = 100;
            expectedStatus   = OperationStatus.InvalidData;
            expectedConsumed = 4;
            expectedWritten  = 3;
            yield return(CreateTestCase());

            // D3
            sourceLength     = 4;
            destLength       = 2;
            expectedStatus   = OperationStatus.DestinationTooSmall;
            expectedConsumed = 0;
            expectedWritten  = 0;
            yield return(CreateTestCase());

            // D3
            sourceLength     = 8;
            destLength       = 5;
            expectedStatus   = OperationStatus.DestinationTooSmall;
            expectedConsumed = 4;
            expectedWritten  = 3;
            yield return(CreateTestCase());

            // D4
            sourceLength     = 9;
            destLength       = 6;
            expectedStatus   = OperationStatus.InvalidData;
            expectedConsumed = 8;
            expectedWritten  = 6;
            yield return(CreateTestCase());

            // D6
            isFinalBlock     = false;
            sourceLength     = 4;
            destLength       = 3;
            expectedStatus   = OperationStatus.Done;
            expectedConsumed = 4;
            expectedWritten  = 3;
            yield return(CreateTestCase());

            // D7
            sourceLength     = 5;
            destLength       = 3;
            expectedStatus   = OperationStatus.NeedMoreData;
            expectedConsumed = 4;
            expectedWritten  = 3;
            yield return(CreateTestCase());

            // D8
            sourceLength     = 8;
            destLength       = 5;
            expectedStatus   = OperationStatus.DestinationTooSmall;
            expectedConsumed = 4;
            expectedWritten  = 3;
            yield return(CreateTestCase());

            // D9
            sourceLength     = 9;
            destLength       = 5;
            expectedStatus   = OperationStatus.DestinationTooSmall;
            expectedConsumed = 4;
            expectedWritten  = 3;
            yield return(CreateTestCase());

            //-----------------------------------------------------------------
            TestCaseData CreateTestCase()
            {
                var testCaseData = new TestCaseData(isFinalBlock, sourceLength, destLength, expectedStatus, expectedConsumed, expectedWritten);

                testCaseData.SetArgDisplayNames(
                    $"isFinalBlock={isFinalBlock.ToString().ToLower()}",
                    $"source={sourceLength}",
                    $"dest={destLength}",
                    $"status={expectedStatus}",
                    $"consumed={expectedConsumed}",
                    $"written={expectedWritten}"
                    );

                return(testCaseData);
            }
        }