Пример #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 ApiPenServerModelMapper();
            ApplicationDbContext      context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IPenService               service = testServer.Host.Services.GetService(typeof(IPenService)) as IPenService;
            ApiPenServerResponseModel model   = await service.Get(1);

            ApiPenClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties("B");

            UpdateResponse <ApiPenClientResponseModel> updateResponse = await client.PenUpdateAsync(model.Id, request);

            context.Entry(context.Set <Pen>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Pen>().ToList()[0].Name.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Name.Should().Be("B");
        }
Пример #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;

            IPenService service = testServer.Host.Services.GetService(typeof(IPenService)) as IPenService;
            var         model   = new ApiPenServerRequestModel();

            model.SetProperties("B");
            CreateResponse <ApiPenServerResponseModel> createdResponse = await service.Create(model);

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

            ActionResponse deleteResult = await client.PenDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
Пример #3
0
 public void SetUp()
 {
     SetupAutoMapper();
     SetUpListOfPens();
     SetUpCommonMocks();
     _penService = new PenService(_mockPenRepository, _bus, _mapper);
 }
Пример #4
0
 public AbstractPenController(
     ApiSettings settings,
     ILogger <AbstractPenController> logger,
     ITransactionCoordinator transactionCoordinator,
     IPenService penService,
     IApiPenModelMapper penModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.PenService     = penService;
     this.PenModelMapper = penModelMapper;
 }
Пример #5
0
 public PenController(
     ApiSettings settings,
     ILogger <PenController> logger,
     ITransactionCoordinator transactionCoordinator,
     IPenService penService,
     IApiPenServerModelMapper penModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.PenService      = penService;
     this.PenModelMapper  = penModelMapper;
     this.BulkInsertLimit = 250;
     this.MaxLimit        = 1000;
     this.DefaultLimit    = 250;
 }
Пример #6
0
 public PenAdminController(IPenService penService)
 {
     _penService = penService;
 }