Пример #1
0
        public virtual async void TestUpdate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            var mapper = new ApiEventStudentServerModelMapper();
            ApplicationDbContext context             = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IEventStudentService service             = testServer.Host.Services.GetService(typeof(IEventStudentService)) as IEventStudentService;
            ApiEventStudentServerResponseModel model = await service.Get(1);

            ApiEventStudentClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(1, 1);

            UpdateResponse <ApiEventStudentClientResponseModel> updateResponse = await client.EventStudentUpdateAsync(model.Id, request);

            context.Entry(context.Set <EventStudent>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <EventStudent>().ToList()[0].EventId.Should().Be(1);
            context.Set <EventStudent>().ToList()[0].StudentId.Should().Be(1);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.EventId.Should().Be(1);
            updateResponse.Record.StudentId.Should().Be(1);
        }
Пример #2
0
        public virtual async void TestDelete()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);
            var        client     = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;

            IEventStudentService service = testServer.Host.Services.GetService(typeof(IEventStudentService)) as IEventStudentService;
            var model = new ApiEventStudentServerRequestModel();

            model.SetProperties(1, 1);
            CreateResponse <ApiEventStudentServerResponseModel> createdResponse = await service.Create(model);

            createdResponse.Success.Should().BeTrue();

            ActionResponse deleteResult = await client.EventStudentDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();
            ApiEventStudentServerResponseModel verifyResponse = await service.Get(2);

            verifyResponse.Should().BeNull();
        }
Пример #3
0
 public EventStudentController(
     ApiSettings settings,
     ILogger <EventStudentController> logger,
     ITransactionCoordinator transactionCoordinator,
     IEventStudentService eventStudentService,
     IApiEventStudentServerModelMapper eventStudentModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.EventStudentService     = eventStudentService;
     this.EventStudentModelMapper = eventStudentModelMapper;
     this.BulkInsertLimit         = 250;
     this.MaxLimit     = 1000;
     this.DefaultLimit = 250;
 }