public void GetTemplates_ExistingTemplateName_OK() { var timestamp1 = MockData.Timestamp(1); repository.Setup(r => r.GetTemplateVersions("T01")).Returns(new List <TemplateContentSummary>() { new TemplateContentSummary() { Name = "T01_V01", TemplateName = "T01", TemplateVersion = "V01", FileName = "T01A.docx", Path = "/files/T01A.docx", Size = 42, Timestamp = timestamp1 }, new TemplateContentSummary() { Name = "T01_V02", TemplateName = "T01", TemplateVersion = "V02", FileName = "T01B.docx", Path = "/files/T01B.docx", Size = 43, Timestamp = MockData.Timestamp(2) }, }); var result = processor.GetTemplates("T01"); Assert.Equal(2, result.Count()); var t1 = result.First(); Assert.Equal("T01", t1.TemplateName); Assert.Equal("T01A.docx", t1.FileName); Assert.Equal("V01", t1.Version); Assert.Equal(timestamp1, t1.Timestamp); Assert.Equal(42, t1.Size); }
public void GetTemplate_TemplateNameAndVersion_OK() { repository.Setup(r => r.GetTemplate("T01", "V01")).Returns(new TemplateContent() { Name = "T01_V01", TemplateName = "T01", TemplateVersion = "V01", FileName = "T01A.docx", Path = "/files/T01A.docx", Size = 42, Timestamp = MockData.Timestamp(1), Buffer = new MemoryStream(Resources.find_template_fields001_docx) }); var result = processor.GetTemplate("T01", "V01"); Assert.NotNull(result); Assert.Equal("T01", result.TemplateName); Assert.Equal("T01A.docx", result.FileName); Assert.Equal("V01", result.Version); Assert.Equal(MockData.Timestamp(1), result.Timestamp); Assert.Equal(42, result.Size); Assert.NotEqual(0, result.Buffer.Length); Assert.NotEmpty(result.Fields); }
public async Task CreateTemplate_OK() { var templateData = new TemplateData() { TemplateName = "T01" }; repository.Setup(r => r.CreateTemplate("T01", It.IsAny <Stream>())).Returns((string _, Stream bytes) => Task.FromResult(new TemplateContent() { Name = "T01_V01", TemplateName = "T01", TemplateVersion = "V01", FileName = "T01A.docx", Path = "/files/T01A.docx", Size = 42, Timestamp = MockData.Timestamp(1), Buffer = bytes })); var result = await processor.CreateTemplate(templateData, new MemoryStream(Resources.find_template_fields001_docx)); Assert.NotNull(result); Assert.Equal("T01", result.TemplateName); Assert.Equal("T01A.docx", result.FileName); Assert.Equal("V01", result.Version); Assert.Equal(MockData.Timestamp(1), result.Timestamp); Assert.Equal(42, result.Size); Assert.NotEqual(0, result.Buffer.Length); Assert.NotEmpty(result.Fields); }
public void GetMappings_TemplateNameAndVersion_OK() { repository.Setup(r => r.GetMappings("T01", "V01", null)).Returns(new List <MappingContentSummary>() { new MappingContentSummary() { Name = "T01_V01_M01_V03", TemplateName = "T01", TemplateVersion = "V01", MappingName = "M01", MappingVersion = "V01", FileName = "T01_V01_M01_V03.xlsm", Path = "/files/T01_V01_M01_V03.xlsm", Size = 42, Timestamp = MockData.Timestamp(1) }, new MappingContentSummary() { Name = "T02_V02_M02_V03", TemplateName = "T02", TemplateVersion = "V02", MappingName = "M02", MappingVersion = "V03", FileName = "T02_V02_M02_V03.xlsm", Path = "/files/T02_V02_M02_V03.xlsm", Size = 43, Timestamp = MockData.Timestamp(2) }, }); var result = processor.GetMappings("T01", "V01"); Assert.NotEmpty(result); AssertMappingProperties(result.First()); }