Skip to content

Commit

Permalink
chore: Add unit tests for BasicObject, DeepObject, and TemplateFact c…
Browse files Browse the repository at this point in the history
…lasses
  • Loading branch information
github-actions[bot] committed Dec 1, 2024
1 parent f0e7eaf commit bf5aac8
Show file tree
Hide file tree
Showing 9 changed files with 430 additions and 463 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ obj

# Styles Generated Code
*.scss.ts
**/*.DotSettings.user
**/*.DotSettings.user

# JetBrains
.idea
77 changes: 77 additions & 0 deletions AzureLiquid.Tests/Arrangement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// <copyright file="Arrangement.cs">
// Licensed under the open source Apache License, Version 2.0.
// Project: AzureLiquid.Tests
// Created: 2022-10-18 07:46
// </copyright>

using AzureLiquid.Tests.Resources;

namespace AzureLiquid.Tests;

/// <summary>
/// Contains arranged values used for testing, containing mock instances and expected return values.
/// </summary>
public class Arrangement
{
/// <summary>
/// Initializes a new instance of the <see cref="Arrangement"/> class.
/// </summary>
public Arrangement()
{
Basic = new BasicObject("John Doe");
Deep = new TemplateFact<DeepObject>
{
Content = new DeepObject("Jane Doe"),
Template = "<p>{{content.nested.title}}</p>",
Expected = "<p>Jane Doe</p>"
};

var simple = "Simple Template";
SimpleTemplate = new TemplateFact<BasicObject>
{
Content = new BasicObject(simple),
Template = Templates.SimpleTemplate,
Expected = Templates.SimpleResult
};

Event = new TemplateFact<string>
{
Content = Templates.EventContent,
Template = Templates.EventTemplate,
Expected = Templates.EventResult
};

Albums = new TemplateFact<string>
{
Content = Templates.AlbumsContent,
Template = Templates.AlbumsTemplate,
Expected = Templates.AlbumsResult
};
}

/// <summary>
/// Gets the albums fact.
/// </summary>
public TemplateFact<string> Albums { get; }

/// <summary>
/// Gets the event fact.
/// </summary>
public TemplateFact<string> Event { get; }

/// <summary>
/// Gets the simple template fact.
/// </summary>
public TemplateFact<BasicObject> SimpleTemplate { get; }

/// <summary>
/// Gets the deep object fact.
/// </summary>
public TemplateFact<DeepObject> Deep { get; }

/// <summary>
/// Gets the basic object fact.
/// </summary>
public BasicObject Basic { get; }

}

Check warning on line 77 in AzureLiquid.Tests/Arrangement.cs

View workflow job for this annotation

GitHub Actions / Publish

Check warning on line 77 in AzureLiquid.Tests/Arrangement.cs

View workflow job for this annotation

GitHub Actions / Publish

Check warning on line 77 in AzureLiquid.Tests/Arrangement.cs

View workflow job for this annotation

GitHub Actions / Publish

Check warning on line 77 in AzureLiquid.Tests/Arrangement.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Check warning on line 77 in AzureLiquid.Tests/Arrangement.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Check warning on line 77 in AzureLiquid.Tests/Arrangement.cs

View workflow job for this annotation

GitHub Actions / Unit Tests / Build and Test

Check warning on line 77 in AzureLiquid.Tests/Arrangement.cs

View workflow job for this annotation

GitHub Actions / Unit Tests / Build and Test

Check warning on line 77 in AzureLiquid.Tests/Arrangement.cs

View workflow job for this annotation

GitHub Actions / Unit Tests / Build and Test

25 changes: 25 additions & 0 deletions AzureLiquid.Tests/BasicObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// <copyright file="BasicObject.cs">
// Licensed under the open source Apache License, Version 2.0.
// Project: AzureLiquid.Tests
// Created: 2022-10-18 07:46
// </copyright>

namespace AzureLiquid.Tests;

/// <summary>
/// Basic test of an object to serialize and render.
/// </summary>
/// <remarks>
/// Initializes a new instance of the <see cref="BasicObject"/> class.
/// </remarks>
/// <param name="title">The title.</param>
public class BasicObject(string title)
{
/// <summary>
/// Gets the title.
/// </summary>
/// <value>
/// The title.
/// </value>
public string Title { get; } = title;
}
25 changes: 25 additions & 0 deletions AzureLiquid.Tests/DeepObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// <copyright file="DeepObject.cs">
// Licensed under the open source Apache License, Version 2.0.
// Project: AzureLiquid.Tests
// Created: 2022-10-18 07:46
// </copyright>

namespace AzureLiquid.Tests;

/// <summary>
/// Test sample for an object with nested types, ensure that deeper accessors are valid.
/// </summary>
/// <remarks>
/// Initializes a new instance of the <see cref="DeepObject"/> class.
/// </remarks>
/// <param name="title">The title.</param>
public class DeepObject(string title)
{
/// <summary>
/// Gets the nested object.
/// </summary>
/// <value>
/// The nested object.
/// </value>
public BasicObject Nested { get; } = new BasicObject(title);
}
159 changes: 0 additions & 159 deletions AzureLiquid.Tests/LiquidParserTests.Arrangement.cs

This file was deleted.

Loading

0 comments on commit bf5aac8

Please sign in to comment.