Browse Source

Fix trailing newlines, more unit tests

pull/240/head
Ionite 1 year ago
parent
commit
3469f29228
No known key found for this signature in database
  1. 4
      StabilityMatrix.Core/Models/GenerationParameters.cs
  2. 23
      StabilityMatrix.Tests/Models/GenerationParametersTests.cs

4
StabilityMatrix.Core/Models/GenerationParameters.cs

@ -54,8 +54,8 @@ public record GenerationParameters
var splitFirstPart = joinedLines.Split("Negative prompt: ", 2); var splitFirstPart = joinedLines.Split("Negative prompt: ", 2);
var positivePrompt = splitFirstPart.ElementAtOrDefault(0); var positivePrompt = splitFirstPart.ElementAtOrDefault(0)?.Trim();
var negativePrompt = splitFirstPart.ElementAtOrDefault(1); var negativePrompt = splitFirstPart.ElementAtOrDefault(1)?.Trim();
// Parse last line // Parse last line
var lineFields = ParseLine(lastLine); var lineFields = ParseLine(lastLine);

23
StabilityMatrix.Tests/Models/GenerationParametersTests.cs

@ -5,6 +5,29 @@ namespace StabilityMatrix.Tests.Models;
[TestClass] [TestClass]
public class GenerationParametersTests public class GenerationParametersTests
{ {
[TestMethod]
public void TestParse()
{
const string data = """
test123
Negative prompt: test, easy negative
Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 3589107295, Size: 1024x1028, Model hash: 9aa0c3e54d, Model: nightvisionXL_v0770_BakedVAE, VAE hash: 235745af8d, VAE: sdxl_vae.safetensors, Style Selector Enabled: True, Style Selector Randomize: False, Style Selector Style: base, Version: 1.6.0
""";
Assert.IsTrue(GenerationParameters.TryParse(data, out var result));
Assert.AreEqual("test123", result.PositivePrompt);
Assert.AreEqual("test, easy negative", result.NegativePrompt);
Assert.AreEqual(20, result.Steps);
Assert.AreEqual("Euler a", result.Sampler);
Assert.AreEqual(7, result.CfgScale);
Assert.AreEqual(3589107295, result.Seed);
Assert.AreEqual(1024, result.Width);
Assert.AreEqual(1028, result.Height);
Assert.AreEqual("9aa0c3e54d", result.ModelHash);
Assert.AreEqual("nightvisionXL_v0770_BakedVAE", result.ModelName);
}
[TestMethod] [TestMethod]
public void TestParse_NoNegative() public void TestParse_NoNegative()
{ {

Loading…
Cancel
Save