|
| 1 | +using NUnit.Framework; |
| 2 | + |
| 3 | +using FluentAssertions; |
| 4 | + |
| 5 | +using Queo.Commons.Builders.Model.Examples; |
| 6 | +using Queo.Commons.Builders.Model.Examples.Relations; |
| 7 | + |
| 8 | +namespace Queo.Commons.Builders.Model.Tests.AfterModel; |
| 9 | + |
| 10 | +[TestFixture] |
| 11 | +public class AfterModelTests |
| 12 | +{ |
| 13 | + [Test] |
| 14 | + public void CreateCountry_WithPresident() |
| 15 | + { |
| 16 | + Country c = Create.Country().WithName("USA") |
| 17 | + .WithPresident(p => p.WithName("Roosevelt")); |
| 18 | + |
| 19 | + c.Name.Should().Be("USA"); |
| 20 | + c.President?.Name.Should().Be("Roosevelt"); |
| 21 | + c.Should().Be(c.President?.Country); |
| 22 | + } |
| 23 | + |
| 24 | + [Test] |
| 25 | + public void CreatePresident_WithCountry() |
| 26 | + { |
| 27 | + President p = Create.President().WithName("Roosevelt") |
| 28 | + .WithCountry(c => c.WithName("USA")); |
| 29 | + |
| 30 | + p.Name.Should().Be("Roosevelt"); |
| 31 | + p.Country.Name.Should().Be("USA"); |
| 32 | + p.Country.President.Should().Be(p); |
| 33 | + } |
| 34 | + |
| 35 | + [Test] |
| 36 | + public void CreateUser_WithOrg() |
| 37 | + { |
| 38 | + User u = Create.User().WithName("George") |
| 39 | + .WithOrg(o => o.WithName("GOrg")); |
| 40 | + |
| 41 | + u.Name.Should().Be("George"); |
| 42 | + u.Org?.Name.Should().Be("GOrg"); |
| 43 | + u.Org?.Members.Should().Contain(u); |
| 44 | + } |
| 45 | + |
| 46 | + [Test] |
| 47 | + public void CreateOrg_WithUsers() |
| 48 | + { |
| 49 | + Org o = Create.Org().WithName("GOrg") |
| 50 | + .WithAdmin(u => u.WithName("George")) |
| 51 | + .AddMember(u => u.WithName("Other")); |
| 52 | + |
| 53 | + o.Name.Should().Be("GOrg"); |
| 54 | + o.Admin.Name.Should().Be("George"); |
| 55 | + o.Admin.Org.Should().Be(o); |
| 56 | + o.Members.Should().Contain(m => m.Name.Equals("Other")); |
| 57 | + o.Members.Should().Contain(m => m.Name.Equals("George")); |
| 58 | + } |
| 59 | +} |
0 commit comments