public void CompilesTemplate() { TemplateService.Setup(x => x.Compile(TemplateString, typeof(object), CacheName)); _template.SetupGet(x => x.Meta).Returns(new OdfMetadata(typeof(object))); _template.SetupGet(x => x.Content).Returns(TemplateString); _sut.Compile(_template.Object, CacheName); TemplateService.Verify(x => x.Compile(TemplateString, typeof(object), CacheName)); }
//[Test] public void IntegrationTest() { const string templatePath = @"..\..\Test Templates\Modeled Basic Template.odt"; const string reportPath = @"..\..\Generated Reports\Very Basic Report.odt"; const string expectedReportPath = @"..\..\Expected Report Outputs\Very Basic Report.odt"; var templateFactory = new TemplateFactory(); var zipFactory = new ZipFactory(); var readerFactory = new StreamReaderWrapperFactory(); var zipHandlerService = new ZipHandlerService(readerFactory); var buildOdfMetadataService = new BuildOdfMetadataService(); var xmlNamespaceService = new XmlNamespaceService(); var xDocumentParserService = new XDocumentParserService(); var odfHandlerService = new OdfHandlerService(zipFactory, zipHandlerService, buildOdfMetadataService, xmlNamespaceService, xDocumentParserService); var templateService = new TemplateBuilderService(templateFactory, odfHandlerService, xmlNamespaceService, xDocumentParserService); var document = File.ReadAllBytes(templatePath); var template = templateService.BuildTemplate(document); var razorTemplateService = new TemplateService(); var compileService = new CompileService(razorTemplateService); compileService.Compile(template, "Template 1"); var reportService = new ReportGeneratorService(new ZipFactory(), razorTemplateService); using (var report = new FileStream(reportPath, FileMode.Create)) { reportService.BuildReport(template, new BasicModel { Name = "Fancypants McSnooterson" }, report); } var diffs = GetDifferences(expectedReportPath, reportPath); var thereAreDifferences = diffs.HasDifferences(); Assert.That(!thereAreDifferences); }
public void CorrectSourceCSCompileTest() { var actualResult = CompileService.Compile( this.correctCsSourceCode, CSLanguageType, this.emptyInput, this.emptyOutput, Timelimit, Memorylimit); Assert.AreEqual(AcceptedTestResult, actualResult); }
public void CompileServiceTest() { var compileService = new CompileService(); var source = CompileServiceLanguageSourceCode.CPPCorrectSourceCode; const string Language = "CPP8"; var input = new string[0]; var output = new string[0]; var inputStrings = new[] { "1 2" }; var outputStrings = new[] { "12" }; string expected; // compile with incorrect language parameter try { expected = compileService.Compile(source, "IncorrectLanguageName", input, output, 100, 100); Assert.AreEqual(false, true); } catch (Exception) { Assert.AreEqual(true, true); } try { expected = compileService.Compile(source, string.Empty, input, output, 100, 100); Assert.AreEqual(false, true); } catch (Exception) { Assert.AreEqual(true, true); } // compile with incorrect timelimit parameter try { expected = compileService.Compile(source, Language, inputStrings, outputStrings, -5, 100); Assert.AreEqual(false, true); } catch (Exception) { Assert.AreEqual(true, true); } // compile with incorrect memorylimit parameter try { expected = compileService.Compile(source, Language, inputStrings, outputStrings, 100, -5); Assert.AreEqual(false, true); } catch (Exception) { Assert.AreEqual(true, true); } // compile with correct parameters try { input = new[] { "2 5", "7 5" }; output = new[] { "25", "75" }; expected = compileService.Compile(source, Language, input, output, 1000, 1000); Assert.AreEqual(expected, "Accepted"); } catch (Exception) { Assert.AreEqual(false, true); } }