public SandboxEnvironmentService(LangboxDbContext context)
 {
     _dbContext = context;
 }
Example #2
0
 public ChallengeService(LangboxDbContext context)
 {
     _dbContext = context;
 }
Example #3
0
        private static void SeedDatabase(LangboxDbContext context)
        {
            // Seed the database with sandbox environments.
            context.Add(new SandboxEnvironment
            {
                TemplateName    = "C# (MSUnit)",
                Language        = "csharp",
                MainFileName    = "Main.cs",
                TestFileName    = "Test.cs",
                MainBoilerplate = "namespace Challenge\n{\n\tpublic class ChallengeClass\n\t{\n\t\t\n\t}\n}",
                TestBoilerplate = "using Microsoft.VisualStudio.TestTools.UnitTesting;\n\nusing Challenge;\n\nnamespace ChallengeTests\n{\n\t[TestClass]\n\tpublic class ChallengeTest\n\t{\n\t\t[TestMethod]\n\t\tpublic void Test()\n\t\t{\n\t\t\t\n\t\t}\n\t}\n}",
                DockerImage     = "lgbox/csharp-msunit-template:0.1.0",
                DockerCommand   = "python main.py",
                DockerMainPath  = "/app/Lgbox-CSharp-MSUnit/Main.cs",
                DockerTestPath  = "/app/Lgbox-CSharp-MSUnit-Tests/Test.cs"
            });

            context.Add(new SandboxEnvironment
            {
                TemplateName    = "Java (JUnit)",
                Language        = "java",
                MainFileName    = "Main.java",
                TestFileName    = "Test.java",
                MainBoilerplate =
                    @"public class Main {

}",
                TestBoilerplate =
                    @"import org.junit.Assert;

public class Test {

    @org.junit.Test
    public void exampleTest() {
        Assert.assertTrue(""Should be true"", 1 == 1);
    }
}",
                DockerImage    = "lgbox/java-junit-template:0.1.0",
                DockerCommand  = "python main.py",
                DockerMainPath = "/app/src/main/java/Main.java",
                DockerTestPath = "/app/src/test/java/Test.java"
            });

            // Seed the database with challenges.
            context.Add(new Challenge
            {
                Title        = "One & Two",
                Instructions =
                    @"Your task is to fulfill class method implementations, according to the return types.

Example:

- Method `One` should return `1`.

- Method `Two` should return `""2""`.",
                MainContent =
                    @"namespace Example
{
    public class ExampleClass
    {
        public static int One()
        {
            return 0;
        }

        public static string Two()
        {
            return """";
        }
    }
}",
                TestContent =
                    @"using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace ExampleTests
{
    [TestClass]
    public class ExampleClassTest
    {
        [TestMethod]
        public void One_Implementation_Is_Correct()
        {
            Assert.AreEqual(Example.ExampleClass.One(), 1);
        }

        [TestMethod]
        public void Two_Implementation_Is_Correct()
        {
            Assert.AreEqual(Example.ExampleClass.Two(), ""2"");   
        }
    }
}",
                SandboxEnvironmentId = "C# (MSUnit)"
            });

            context.Add(new Challenge
            {
                Title        = "Three & Four",
                Instructions =
                    @"Your task is to fulfill class method implementations, according to the return types.

Example:

- Method `three` should return `3`.

- Method `four` should return `""4""`.",
                MainContent =
                    @"public class Main {
    public static int three() {
        return 0;
    }
    
    public static String four() {
        return ""0"";
    }
}",
                TestContent =
                    @"import org.junit.Assert;

public class Test {

    @org.junit.Test
    public void shouldReturnCorrectValues() {
        Assert.assertTrue(Main.three() == 3);
        Assert.assertTrue(Main.four() == ""4"");
    }
}",
                SandboxEnvironmentId = "Java (JUnit)"
            });

            context.SaveChanges();
        }