-
Notifications
You must be signed in to change notification settings - Fork 95
/
TestNestedInDtosIssue13.cs
49 lines (44 loc) · 1.62 KB
/
TestNestedInDtosIssue13.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2021 Jon P Smith, GitHub: JonPSmith, web: http://www.thereformedprogrammer.net/
// Licensed under MIT license. See License.txt in the project root for license information.
using System.Linq;
using GenericServices.PublicButHidden;
using GenericServices.Setup;
using Tests.Dtos;
using Tests.EfCode;
using TestSupport.EfHelpers;
using Xunit;
using Xunit.Extensions.AssertExtensions;
namespace Tests.UnitTests.GenericServicesPublic
{
public class TestNestedInDtosIssue13
{
[Fact]
public void TestInDtosNestedOk()
{
//SETUP
var options = SqliteInMemory.CreateOptions<TestDbContext>();
using (var context = new TestDbContext(options))
{
context.Database.EnsureCreated();
var utData = context.SetupSingleDtoAndEntities<InContactAddressDto>();
utData.AddSingleDto<InAddressDto>();
var service = new CrudServices(context, utData.ConfigAndMapper);
//ATTEMPT
var dto = new InContactAddressDto
{
Name = "test",
Addess = new InAddressDto
{
Address1 = "some street"
}
};
service.CreateAndSave(dto);
//VERIFY
service.IsValid.ShouldBeTrue(service.GetAllErrors());
var contact = context.ContactAddresses.SingleOrDefault();
contact.Name.ShouldEqual("test");
contact.Address.Address1.ShouldEqual("some street");
}
}
}
}