public void CheckMethodReceivesCorrectParameters()
        {
            var checker = new CSharpCodeChecker();

            checker.SetParameter(@"
                using OJS.Workers.Common;
                public class MyChecker : IChecker
                {
                    public CheckerResult Check(string inputData, string receivedOutput, string expectedOutput, bool isTrialTest)
                    {
                        bool isCorrect = true;

                        if (inputData != ""One"") isCorrect = false;
                        if (receivedOutput != ""Two"") isCorrect = false;
                        if (expectedOutput != ""Three"") isCorrect = false;

                        return new CheckerResult
                                    {
                                        IsCorrect = isCorrect,
                                        ResultType = CheckerResultType.Ok,
                                        CheckerDetails = """",
                                    };
                    }
                    public void SetParameter(string parameter)
                    {
                    }
                }");

            var checkerResult = checker.Check("One", "Two", "Three", false);

            Assert.IsNotNull(checkerResult);
            Assert.IsTrue(checkerResult.IsCorrect);
        }
        public void CheckMethodWorksCorrectlyWithSomeCheckerCode()
        {
            var checker = new CSharpCodeChecker();

            checker.SetParameter(@"
                using OJS.Workers.Common;
                public class MyChecker : IChecker
                {
                    public CheckerResult Check(string inputData, string receivedOutput, string expectedOutput, bool isTrialTest)
                    {
                        return new CheckerResult
                                    {
                                        IsCorrect = true,
                                        ResultType = CheckerResultType.Ok,
                                        CheckerDetails = ""It was me"",
                                    };
                    }
                    public void SetParameter(string parameter)
                    {
                    }
                }");

            var checkerResult = checker.Check(string.Empty, string.Empty, string.Empty, false);

            Assert.IsNotNull(checkerResult);
            Assert.IsTrue(checkerResult.IsCorrect);
            Assert.AreEqual("It was me", checkerResult.CheckerDetails);
        }
        public void CheckMethodWorksCorrectlyWithSomeCheckerCode()
        {
            var checker = new CSharpCodeChecker();
            checker.SetParameter(@"
                using OJS.Workers.Common;
                public class MyChecker : IChecker
                {
                    public CheckerResult Check(string inputData, string receivedOutput, string expectedOutput, bool isTrialTest)
                    {
                        return new CheckerResult
                                    {
                                        IsCorrect = true,
                                        ResultType = CheckerResultType.Ok,
                                        CheckerDetails = ""It was me"",
                                    };
                    }
                    public void SetParameter(string parameter)
                    {
                    }
                }");

            var checkerResult = checker.Check(string.Empty, string.Empty, string.Empty, false);

            Assert.IsNotNull(checkerResult);
            Assert.IsTrue(checkerResult.IsCorrect);
            Assert.AreEqual("It was me", checkerResult.CheckerDetails);
        }
        public void CheckMethodReceivesCorrectParameters()
        {
            var checker = new CSharpCodeChecker();
            checker.SetParameter(@"
                using OJS.Workers.Common;
                public class MyChecker : IChecker
                {
                    public CheckerResult Check(string inputData, string receivedOutput, string expectedOutput, bool isTrialTest)
                    {
                        bool isCorrect = true;

                        if (inputData != ""One"") isCorrect = false;
                        if (receivedOutput != ""Two"") isCorrect = false;
                        if (expectedOutput != ""Three"") isCorrect = false;

                        return new CheckerResult
                                    {
                                        IsCorrect = isCorrect,
                                        ResultType = CheckerResultType.Ok,
                                        CheckerDetails = """",
                                    };
                    }
                    public void SetParameter(string parameter)
                    {
                    }
                }");

            var checkerResult = checker.Check("One", "Two", "Three", false);

            Assert.IsNotNull(checkerResult);
            Assert.IsTrue(checkerResult.IsCorrect);
        }
예제 #5
0
        public void CallingCheckMethodBeforeSetParameterShouldThrowAnException()
        {
            // Arrange
            var    checker = new CSharpCodeChecker();
            string expectedErrorMessage = "Please call SetParameter first with non-null string.";

            // Act
            var exception = Assert.Throws <InvalidOperationException>(() => checker.Check(string.Empty, string.Empty, string.Empty, false));

            // Assert
            Assert.AreEqual(expectedErrorMessage, exception.Message);
        }
        public void CallingCheckMethodBeforeSetParameterShouldThrowAnException()
        {
            var checker = new CSharpCodeChecker();

            checker.Check(string.Empty, string.Empty, string.Empty, false);
        }
 public void CallingCheckMethodBeforeSetParameterShouldThrowAnException()
 {
     var checker = new CSharpCodeChecker();
     checker.Check(string.Empty, string.Empty, string.Empty, false);
 }