forked from MarimerLLC/csla
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added AddNewAsync() methods to lists with AddNew which are using IObs…
…ervableBindingList (MarimerLLC#3989) Co-authored-by: Rockford Lhotka <rocky@lhotka.net>
- Loading branch information
1 parent
14911b9
commit 2151a19
Showing
5 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="AddNewAsyncTests.cs" company="Marimer LLC"> | ||
// Copyright (c) Marimer LLC. All rights reserved. | ||
// Website: https://cslanet.com | ||
// </copyright> | ||
// <summary>no summary</summary> | ||
//----------------------------------------------------------------------- | ||
|
||
using Csla.TestHelpers; | ||
using FluentAssertions; | ||
using FluentAssertions.Execution; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Csla.Test.BusinessListBase | ||
{ | ||
[TestClass] | ||
public class AddNewAsyncTests | ||
{ | ||
private static TestDIContext _testDIContext; | ||
|
||
[ClassInitialize] | ||
public static void ClassInitialize(TestContext context) | ||
{ | ||
_testDIContext = TestDIContextFactory.CreateDefaultContext(); | ||
} | ||
|
||
[TestMethod] | ||
public async Task RootAddNewCoreAsync() | ||
{ | ||
bool changed = false; | ||
var obj = CreateRootList(); | ||
obj.CollectionChanged += (_, _) => | ||
{ | ||
changed = true; | ||
}; | ||
var child = await obj.AddNewAsync(); | ||
Assert.IsTrue(changed); | ||
Assert.AreEqual(child, obj[0]); | ||
} | ||
|
||
[TestMethod] | ||
public async Task ChildAddNewCoreAsync() | ||
{ | ||
bool childChanged = false; | ||
bool changed = false; | ||
var obj = CreateRoot(); | ||
obj.ChildChanged += (_, _) => | ||
{ | ||
childChanged = true; | ||
}; | ||
obj.Children.CollectionChanged += (_, _) => | ||
{ | ||
changed = true; | ||
}; | ||
var child = await obj.Children.AddNewAsync(); | ||
Assert.IsTrue(childChanged, "ChildChanged should be true"); | ||
Assert.IsTrue(changed, "Collection changed should be true"); | ||
Assert.AreEqual(child, obj.Children[0]); | ||
} | ||
|
||
private Root CreateRoot() | ||
{ | ||
IDataPortal<Root> dataPortal = _testDIContext.CreateDataPortal<Root>(); | ||
|
||
return dataPortal.Create(); | ||
} | ||
|
||
private RootList CreateRootList() | ||
{ | ||
IDataPortal<RootList> dataPortal = _testDIContext.CreateDataPortal<RootList>(); | ||
|
||
return dataPortal.Create(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters