public async Task Assert_Optional_Value() { var dtoJob = new DtoJob { Id = 123 }; await Job.MapAsync() .OptionalAssert((int id) => dtoJob.Id == id); }
public async Task Throw_On_Missing_Required_Field() { var dtoJob = new DtoJob { Title = "Empty" }; await Job.MapAsync() .Required((string nonExistingField) => dtoJob.Title); }
public async Task Assert_Required_Value() { var dtoJob = new DtoJob { Id = 123 }; await Job.MapAsync() .RequiredAssert((int id) => dtoJob.Id == id); }
public async Task Throw_On_Type_Mistmatch() { var dtoJob = new DtoJob { Title = "Empty" }; await Job.MapAsync() .Optional((int title) => dtoJob.Title); }
public async Task Throw_On_RequiredAssert_Mistmatch() { var dtoJob = new DtoJob { Id = 33 }; await Job.MapAsync() .RequiredAssert((int id) => dtoJob.Id == id); }
public async Task Skip_Omitted_Fields() { var dtoJob = new DtoJob { Title = "Empty" }; await Job.MapAsync() .Optional((int nonExistingField) => dtoJob.Title); Assert.AreEqual("Empty", dtoJob.Title); }
public async Task Map_Array() { var dtoJob = new DtoJob { Types = new[] { "Remote" } }; await Job.MapAsync() .Optional((string[] types) => dtoJob.Types); CollectionAssert.AreEqual(new[] { "Full-Time", "Part-Time" }, dtoJob.Types.ToList()); }
public async Task Map_Scalar() { var dtoJob = new DtoJob { Title = "Empty" }; await Job.MapAsync() .Optional((string title) => dtoJob.Title); Assert.AreEqual("tester", dtoJob.Title); }
public async Task CopyAsync(JObject job, DtoJob dtoJob) { await job.MapAsync() .RequiredAssert((int id) => id == dtoJob.Id) .Optional((string title) => dtoJob.Title) .Optional((JObject company) => dtoJob.Company, (company, dtoCompany) => company .Optional((string name) => dtoCompany.Name) .Optional((int size) => dtoCompany.Size) .Optional((JObject[] industries) => dtoCompany.Industries, industry => IndustryReader.ReadIndustryAsync(industry.Id()))) .Optional((string[] types) => dtoJob.Types) .Optional((JObject[] locations) => dtoJob.Locations, (location, dtoLocation) => location .Required((string city) => dtoLocation.City) .Required((string country) => dtoLocation.Country)); }
public async Task Skip_OptionalAssert_For_Omitted_Field() { var dtoJob = new DtoJob(); await Job.MapAsync() .OptionalAssert((int nonExistingField) => dtoJob.Id == nonExistingField); }