예제 #1
0
 public async Task Assert_Optional_Value()
 {
     var dtoJob = new DtoJob {
         Id = 123
     };
     await Job.MapAsync()
     .OptionalAssert((int id) => dtoJob.Id == id);
 }
예제 #2
0
 public async Task Throw_On_Missing_Required_Field()
 {
     var dtoJob = new DtoJob {
         Title = "Empty"
     };
     await Job.MapAsync()
     .Required((string nonExistingField) => dtoJob.Title);
 }
예제 #3
0
 public async Task Assert_Required_Value()
 {
     var dtoJob = new DtoJob {
         Id = 123
     };
     await Job.MapAsync()
     .RequiredAssert((int id) => dtoJob.Id == id);
 }
예제 #4
0
 public async Task Throw_On_Type_Mistmatch()
 {
     var dtoJob = new DtoJob {
         Title = "Empty"
     };
     await Job.MapAsync()
     .Optional((int title) => dtoJob.Title);
 }
예제 #5
0
 public async Task Throw_On_RequiredAssert_Mistmatch()
 {
     var dtoJob = new DtoJob {
         Id = 33
     };
     await Job.MapAsync()
     .RequiredAssert((int id) => dtoJob.Id == id);
 }
예제 #6
0
        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);
        }
예제 #7
0
        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());
        }
예제 #8
0
        public async Task Map_Scalar()
        {
            var dtoJob = new DtoJob {
                Title = "Empty"
            };
            await Job.MapAsync()
            .Optional((string title) => dtoJob.Title);

            Assert.AreEqual("tester", dtoJob.Title);
        }
예제 #9
0
 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));
 }
예제 #10
0
 public async Task Skip_OptionalAssert_For_Omitted_Field()
 {
     var dtoJob = new DtoJob();
     await Job.MapAsync()
     .OptionalAssert((int nonExistingField) => dtoJob.Id == nonExistingField);
 }