Skip to content

Commit

Permalink
add unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
isdaniel committed Mar 23, 2024
1 parent 55b8ca7 commit b494b91
Show file tree
Hide file tree
Showing 6 changed files with 1,155 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/MiniWord/MiniWord.Implment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static void Generate(this OpenXmlElement xmlElement, WordprocessingDocum

foreach (Dictionary<string, object> es in list)
{
var dic = es.ToDictionary(key => $"{listKey}.{key}", item=>item.Value);
var dic = es.ToDictionary(e => $"{listKey}.{e.Key}", e => e.Value);
var newTr = tr.CloneNode(true);
ReplaceStatements(newTr, tags: dic);

Expand Down
9 changes: 5 additions & 4 deletions src/MiniWord/MiniWord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace MiniSoftware
using DocumentFormat.OpenXml.Office2013.Excel;
using MiniSoftware.Extensions;
using MiniSoftware.Utility;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Dynamic;
Expand Down Expand Up @@ -47,14 +48,14 @@ public static void SaveAsByTemplate(this Stream stream, byte[] templateBytes, ob

public static async Task SaveAsByTemplateAsync(string path, string templatePath, object value,CancellationToken token = default(CancellationToken))
{
using (var stream = FileHelper.CreateAsync(path))
await SaveAsByTemplateImplAsync(await stream, await GetByteAsync(templatePath), value.ToDictionary(),token);
using (var stream = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None, 4096, true))
await SaveAsByTemplateImplAsync(stream, await GetByteAsync(templatePath), value.ToDictionary(),token);
}

public static async Task SaveAsByTemplateAsync(string path, byte[] templateBytes, object value,CancellationToken token = default(CancellationToken))
{
using (var stream = FileHelper.CreateAsync(path))
await SaveAsByTemplateImplAsync(await stream, templateBytes, value.ToDictionary(),token);
using (var stream = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.None, 4096, true))
await SaveAsByTemplateImplAsync(stream, templateBytes, value.ToDictionary(),token);
}
}
}
14 changes: 0 additions & 14 deletions src/MiniWord/Utility/FileAyncExtension.cs

This file was deleted.

Loading

0 comments on commit b494b91

Please sign in to comment.