CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
ChildUpdateTests.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="DataPortalChildTests.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>no summary</summary>
7//-----------------------------------------------------------------------
8
9using Csla.TestHelpers;
10using Microsoft.VisualStudio.TestTools.UnitTesting;
11#if !NUNIT
12
13#else
14using NUnit.Framework;
15using TestClass = NUnit.Framework.TestFixtureAttribute;
16using TestInitialize = NUnit.Framework.SetUpAttribute;
17using TestCleanup = NUnit.Framework.TearDownAttribute;
18using TestMethod = NUnit.Framework.TestAttribute;
19#endif
20
22{
23 [TestClass()]
24 public class ChildUpdateTests
25 {
26 private static TestDIContext _testDIContext;
27
29 public static void ClassInitialize(TestContext context)
30 {
31 _testDIContext = TestDIContextFactory.CreateDefaultContext();
32 }
33
34 [TestMethod]
35 public void FetchAndSaveChild()
36 {
37 IChildDataPortal<Child> childDataPortal = _testDIContext.CreateChildDataPortal<Child>();
38 IDataPortal<Root> dataPortal = _testDIContext.CreateDataPortal<Root>();
39
40 Root root = dataPortal.Create();
41 root.FetchChild(childDataPortal);
42
43 Assert.IsFalse(root.Child.IsDirty, "Child should not be dirty");
44 Assert.AreEqual("Fetched", root.Child.Status, "Child status incorrect after fetch");
45
46 root = root.Save();
47
48 Assert.AreEqual("Fetched", root.Child.Status, "Child status incorrect after Save");
49 }
50
51 [TestMethod]
53 {
54 IChildDataPortal<Child> childDataPortal = _testDIContext.CreateChildDataPortal<Child>();
55 IDataPortal<RootUpdateAllChildren> dataPortal = _testDIContext.CreateDataPortal<RootUpdateAllChildren>();
56
57 var root = dataPortal.Create();
58 root.FetchChild(childDataPortal);
59
60 Assert.IsFalse(root.Child.IsDirty, "Child should not be dirty");
61 Assert.AreEqual("Fetched", root.Child.Status, "Child status incorrect after fetch");
62
63 root = root.Save();
64
65 Assert.AreEqual("Updated", root.Child.Status, "Child status incorrect after Save");
66 }
67
68 }
69}
static void ClassInitialize(TestContext context)
void Create([Inject] IChildDataPortal< Child > childDataPortal, [Inject]IChildDataPortal< ChildList > childListDataPortal)
Type to carry context information for DI in unit tests
Interface defining the members of the child data portal type.
Interface defining the members of the data portal type.
Definition: IDataPortalT.cs:17