Skip to content

Commit

Permalink
#1814 add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Nov 11, 2024
1 parent 6ada1a1 commit 0184abe
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Immutable;
using System.IO;
using System.Reflection;
using System.Text.Json;
using starsky.foundation.storage.Storage;
using starskytest.FakeMocks;

namespace starskytest.FakeCreateAn.CreateAnImageLongDescriptionTitle;

public class CreateAnImageLongDescriptionTitle
{
public readonly ImmutableArray<byte> Bytes = [..Array.Empty<byte>()];

public CreateAnImageLongDescriptionTitle()
{
var dirName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if ( string.IsNullOrEmpty(dirName) )
{
return;
}

var path = Path.Combine(dirName, "FakeCreateAn",
"CreateAnImageLongDescriptionTitle", "CreateAnImageLongDescriptionTitle.jpg");

Bytes = [..StreamToBytes(path)];
ReadAndSetJson(dirName);
}

public CreateAnImageLongDescriptionTitleExampleDataModel? JsonExpectData { get; set; }

private void ReadAndSetJson(string dirName)
{
var jsonPath = Path.Combine(dirName, "FakeCreateAn",
"CreateAnImageLongDescriptionTitle", "CreateAnImageLongDescriptionTitle.json");
var json = File.ReadAllText(jsonPath);
JsonExpectData =
JsonSerializer.Deserialize<CreateAnImageLongDescriptionTitleExampleDataModel>(json);
}

private static byte[] StreamToBytes(string path)
{
var input = new StorageHostFullPathFilesystem(new FakeIWebLogger()).ReadStream(path);
using var ms = new MemoryStream();
input.CopyTo(ms);
input.Dispose();
return ms.ToArray();
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Tags": "Pieterpad, hiking in the Netherlands, long-distance hiking, Dutch countryside, travel experiences, nature photography, personal growth journey, trail tips, walking holidays, outdoor adventure, trail reviews, backpacking tips, Dutch landscapes, cultural experiences, best hiking trails, Dutch history, scenic trails, nature conservation, eco-friendly travel, regional food and drinks, local wildlife, mindfulness in nature, rural villages, historic landmarks, Netherlands travel blog, fitness and wellness, gear recommendations, hiking with friends, solo hiking, seasonal hiking advice, trail safety tips",
"Title": "Embarking on the Ultimate Adventure Across the Netherlands: A Complete Guide to Hiking the Legendary Pieterpad Trail from the Northern Village of Pieterburen to the Southern Hills of Sint Pietersberg – Including Essential Tips, Scenic Highlights, Personal Stories, Practical Advice on Gear and Accommodations, Dutch Cultural Experiences, Local Food Discoveries, and Inspiring Insights for an Unforgettable Journey Through Diverse Landscapes, Historical Towns, and Hidden Gems Along the Way",
"Description": "Explore the captivating journey along the Pieterpad, a legendary 500-kilometer walking trail that takes you from the quiet, rustic village of Pieterburen in the north to the dramatic, limestone hills near Sint Pietersberg in the south. This extensive path is not only a physical journey across the length of the Netherlands but also a mental and emotional experience that challenges, rejuvenates, and brings hikers closer to nature, culture, and themselves. Along the Pieterpad, you’ll witness a beautiful mosaic of Dutch landscapes: from vibrant green pastures, tranquil forests, and charming cobblestone streets to fields dotted with traditional windmills and quaint, cozy inns offering a warm local welcome.Each stage of the Pieterpad has its own unique appeal, from the wild beauty of Groningen's northern wetlands to the historical heartlands of Drenthe, where ancient dolmens (hunebedden) tell the story of early inhabitants, and finally, to the scenic Limburg hills that offer some of the most breathtaking views in the country. This blog delves into the highlights of each stage, sharing practical tips for beginners and seasoned hikers alike, whether it’s selecting the right footwear for varied terrain, packing the essentials, finding peaceful overnight stays, or capturing the best nature photography spots along the way.Hiking the Pieterpad is also a journey into Dutch culture and history, revealing unique customs, regional delicacies, and local hospitality that enrich every step. Discover traditional Dutch snacks like poffertjes and erwtensoep, savor regional specialties, and learn about each town’s unique heritage, from the peat bogs of Drenthe to the castles of Gelderland. My blog offers insights on how to travel sustainably, practice mindfulness in nature, and respect the environment to help preserve these landscapes for future generations.Whether you're looking for a scenic route to challenge yourself physically, searching for moments of solitude and reflection, or hoping to connect with fellow hikers, my Pieterpad journey blog brings you inspiring stories, gear recommendations, and essential trail tips. Dive into tales of adventure, unexpected encounters, moments of solitude, and personal growth as I guide you through each step of the Pieterpad, encouraging you to embark on your own unforgettable adventure through the Netherlands’ most treasured hiking trail"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace starskytest.FakeCreateAn.CreateAnImageLongDescriptionTitle;

public class CreateAnImageLongDescriptionTitleExampleDataModel
{
public string? Title { get; set; }
public string? Description { get; set; }
public string? Tags { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using starskytest.FakeCreateAn;
using starskytest.FakeCreateAn.CreateAnImageA330Raw;
using starskytest.FakeCreateAn.CreateAnImageA6600Raw;
using starskytest.FakeCreateAn.CreateAnImageLongDescriptionTitle;
using starskytest.FakeMocks;
using XmpCore;
using XmpCore.Impl;
Expand Down Expand Up @@ -336,6 +337,23 @@ public void ExifRead_ReadExifFromFileTest()
Assert.AreEqual(ImageStabilisationType.Unknown, item.ImageStabilisation);
}

[TestMethod]
public void ExifRead_ReadExifFromFileTest_LongDescriptionTitle()
{
var newImage = new CreateAnImageLongDescriptionTitle();
var imageBytes = newImage.Bytes.ToArray();
var fakeStorage = new FakeIStorage(new List<string> { "/" },
new List<string> { "/test.jpg" }, new List<byte[]> { imageBytes });

var item =
new ReadMetaExif(fakeStorage, null!, new FakeIWebLogger()).ReadExifFromFile(
"/test.jpg");

Assert.AreEqual(newImage.JsonExpectData?.Description, item.Description);
Assert.AreEqual(newImage.JsonExpectData?.Tags, item.Tags);
Assert.AreEqual(newImage.JsonExpectData?.Title, item.Title);
}

[TestMethod]
public void ExifRead_CreateAnImageA6600Raw_ReadExifFromFileTest()
{
Expand Down
12 changes: 10 additions & 2 deletions starsky/starskytest/starskytest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,17 @@
<Content Include="FakeCreateAn\CreateAnImageA6600Raw\head_part.arw">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Remove="FakeCreateAn\CreateAnImageA330Raw\head_part.arw" />
<None Remove="FakeCreateAn\CreateAnImageA330Raw\head_part.arw"/>
<Content Include="FakeCreateAn\CreateAnImageA330Raw\head_part.arw">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Remove="FakeCreateAn\CreateAnImageLongDescriptionTitle\CreateAnImageLongDescriptionTitle.jpg"/>
<Content Include="FakeCreateAn\CreateAnImageLongDescriptionTitle\CreateAnImageLongDescriptionTitle.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Remove="FakeCreateAn\CreateAnImageLongDescriptionTitle\CreateAnImageLongDescriptionTitle.json"/>
<Content Include="FakeCreateAn\CreateAnImageLongDescriptionTitle\CreateAnImageLongDescriptionTitle.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

Expand Down

0 comments on commit 0184abe

Please sign in to comment.