Skip to content

Commit

Permalink
Remove settings
Browse files Browse the repository at this point in the history
  • Loading branch information
lesaltzm committed Apr 17, 2024
1 parent aeb8cbb commit 734c9bd
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 77 deletions.
2 changes: 0 additions & 2 deletions src/Persistence.Tests/Yaml/DeserializerValidAppTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ namespace Persistence.Tests.Yaml;
public class DeserializerValidAppTests : TestBase
{
[TestMethod]
[DataRow(@"_TestData/ValidYaml{0}/App/with-settings.pa.yaml", true, typeof(App), "http://microsoft.com/appmagic/appinfo", "App", 0, 0, 1)]
[DataRow(@"_TestData/ValidYaml{0}/App/with-settings.pa.yaml", false, typeof(App), "http://microsoft.com/appmagic/appinfo", "App", 0, 0, 1)]
[DataRow(@"_TestData/ValidYaml{0}/App/with-screens.pa.yaml", true, typeof(App), "http://microsoft.com/appmagic/appinfo", "App", 2, 0, 1)]
[DataRow(@"_TestData/ValidYaml{0}/App/with-screens.pa.yaml", false, typeof(App), "http://microsoft.com/appmagic/appinfo", "App", 2, 0, 1)]
public void Deserialize_App_Should_Succeed(string path, bool isControlIdentifiers, Type expectedType, string expectedTemplateId,
Expand Down
22 changes: 0 additions & 22 deletions src/Persistence.Tests/Yaml/DeserializerValidTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,28 +277,6 @@ public void Deserialize_App_ShouldSucceed(string path, bool isControlIdentifiers
app.Properties.Should().NotBeNull().And.HaveCount(propertiesCount);
}


[TestMethod]
[DataRow(@"_TestData/ValidYaml{0}/App-with-settings.pa.yaml", true, "Test App Name", 1)]
[DataRow(@"_TestData/ValidYaml{0}/App-with-settings.pa.yaml", false, "Test App Name", 1)]
public void Deserialize_App_WithSettings_ShouldSucceed(string path, bool isControlIdentifiers, string expectedName, int propertiesCount)
{
// Arrange
var deserializer = CreateDeserializer(isControlIdentifiers);
using var yamlStream = File.OpenRead(GetTestFilePath(path, isControlIdentifiers));
using var yamlReader = new StreamReader(yamlStream);

// Act
var app = deserializer.Deserialize<App>(yamlReader);
if (app == null)
throw new InvalidOperationException(nameof(app));

app.Settings.Should().NotBeNull();
app.Settings!.Name.Should().NotBeNull().And.Be(expectedName);
app.Settings!.Layout.Should().Be(Settings.AppLayout.Landscape);
app.Properties.Should().NotBeNull().And.HaveCount(propertiesCount);
}

[TestMethod]
[DataRow(@"_TestData/ValidYaml{0}/Screen-with-unmatched-field.pa.yaml", true)]
[DataRow(@"_TestData/ValidYaml{0}/Screen-with-unmatched-field.pa.yaml", false)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
App:
Settings:
Name: Test App Name
Layout: Landscape
Properties:
OnStart: =Set(foo, 123)
Control: App
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
App:
Settings:
Name: Test App Name
Layout: Landscape
App:
Properties:
OnStart: =Set(foo, 123)
Screens:
Expand Down

This file was deleted.

5 changes: 0 additions & 5 deletions src/Persistence/Models/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,8 @@ public App(string name, string variant, IControlTemplateStore controlTemplateSto
[YamlIgnore]
public IList<Screen> Screens { get; set; } = new List<Screen>();

public Settings Settings { get; set; } = new Settings();

internal override void AfterCreate(Dictionary<string, object?> controlDefinition)
{
if (controlDefinition.TryGetValue<Settings>(nameof(Settings), out var settings) && settings != null)
Settings = settings;

if (controlDefinition.TryGetValue<List<Screen>>(nameof(Screens), out var screens))
{
if (screens != null)
Expand Down
16 changes: 0 additions & 16 deletions src/Persistence/Models/Settings.cs

This file was deleted.

12 changes: 0 additions & 12 deletions src/Persistence/Yaml/AppConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ public override void OnWriteAfterName(IEmitter emitter, Control value)

var app = (App)value;

if (app.Settings != null)
{
emitter.Emit(new YamlDotNet.Core.Events.Scalar(nameof(App.Settings)));
ValueSerializer!.SerializeValue(emitter, app.Settings, typeof(Models.Settings));
}

if (app.Screens != null)
{
emitter.Emit(new YamlDotNet.Core.Events.Scalar(nameof(App.Screens)));
Expand All @@ -43,12 +37,6 @@ public override void OnWriteAfterName(IEmitter emitter, Control value)

public override object? ReadKey(IParser parser, string key)
{
if (key == nameof(App.Settings))
{
using var serializerState = new SerializerState();
return ValueDeserializer!.DeserializeValue(parser, typeof(Models.Settings), serializerState, ValueDeserializer);
}

if (key == nameof(App.Screens))
{
using var serializerState = new SerializerState();
Expand Down

0 comments on commit 734c9bd

Please sign in to comment.