Skip to content

Commit

Permalink
Changed Model load/save method
Browse files Browse the repository at this point in the history
  • Loading branch information
cuhsat committed Jun 4, 2022
1 parent 9705152 commit 45ec41b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Caliban.Nano/Caliban.Nano.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Company>Caliban.Nano</Company>
<PackageTags>caliban;nano;wpf;mvvm;framework;dependency-injection;event-aggregation;service-locator;automatic-binding</PackageTags>
<VersionPrefix>1.5.1</VersionPrefix>
<VersionPrefix>1.5.2</VersionPrefix>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DocumentationFile>..\..\docs\api.xml</DocumentationFile>
</PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/Caliban.Nano/Contracts/IModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public interface IModel : INotifyPropertyChanged
/// <summary>
/// (Awaitable) Loads the model and resets changed state.
/// </summary>
/// <returns>An asynchronous task.</returns>
Task Load();
/// <returns>True if loading was successful; otherwise false.</returns>
Task<bool> Load();

/// <summary>
/// (Awaitable) Saves the model and resets changed state.
/// </summary>
/// <returns>An asynchronous task.</returns>
Task Save();
/// <returns>True if saving was successful; otherwise false.</returns>
Task<bool> Save();
}
}
8 changes: 4 additions & 4 deletions src/Caliban.Nano/Data/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public Model()
}

/// <inheritdoc />
public virtual Task Load()
public virtual Task<bool> Load()
{
return Task.Run(() => HasChanged = false);
return Task.Run(() => !(HasChanged = false));
}

/// <inheritdoc />
public virtual Task Save()
public virtual Task<bool> Save()
{
return Task.Run(() => HasChanged = false);
return Task.Run(() => !(HasChanged = false));
}

/// <summary>
Expand Down
8 changes: 2 additions & 6 deletions tests/Caliban.Nano.Tests/Data/ModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ public async Task LoadTest()
mock.SetHasChanged(true);

Assert.IsTrue(mock.HasChanged);

await mock.Load();

Assert.IsTrue(await mock.Load());
Assert.IsFalse(mock.HasChanged);
}

Expand All @@ -67,9 +65,7 @@ public async Task SaveTest()
mock.SetHasChanged(true);

Assert.IsTrue(mock.HasChanged);

await mock.Save();

Assert.IsTrue(await mock.Save());
Assert.IsFalse(mock.HasChanged);
}

Expand Down

0 comments on commit 45ec41b

Please sign in to comment.