Advertisement
Guest User

Untitled

a guest
Feb 27th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. using System.Linq;
  2. using ETR.S7.Groups.AgentRequests.Dal;
  3. using Microsoft.EntityFrameworkCore;
  4. using Newtonsoft.Json;
  5. using Xunit;
  6. using Xunit.Abstractions;
  7.  
  8. namespace ETR.S7.Groups.AgentRequests.Infrastructure.Tests
  9. {
  10.     public class Test1
  11.     {
  12.         public Test1(ITestOutputHelper output)
  13.         {
  14.             _output = output;
  15.         }
  16.  
  17.         private readonly ITestOutputHelper _output;
  18.  
  19.         private int Count(int? num)
  20.         {
  21.             return num.Value + 100;
  22.         }
  23.  
  24.         [Fact]
  25.         public void Play()
  26.         {
  27.             var options = new DbContextOptionsBuilder()
  28.                 .UseSqlServer("Server=mssql;Database=AgentRequests;User=sa;Password=yourStrong(!)Password;")
  29.                 .Options;
  30.  
  31.             var appRepository = new AppRepository(options);
  32.             var agentRequests = appRepository.AgentRequests
  33.                 .Select(x => new {
  34.                     x.Route,
  35.                     Test = Count(x.Route.PaxCount)
  36.                 })
  37.                 .Where(x => x.Test > 10)
  38.                 .Where(x => x.Route.PaxCount > 10)
  39.                 .Select(x => new {
  40.                     x.Route.BookingNumber,
  41.                     Test = Count(x.Test)
  42.                 })
  43.                 .ToList();
  44.  
  45.             _output.WriteLine(JsonConvert.SerializeObject(agentRequests, Formatting.Indented));
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement