public virtual async void TestBulkInsert()
        {
            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;

            var model = new ApiTeacherTeacherSkillClientRequestModel();

            model.SetProperties(1, 1);
            var model2 = new ApiTeacherTeacherSkillClientRequestModel();

            model2.SetProperties(1, 1);
            var request = new List <ApiTeacherTeacherSkillClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiTeacherTeacherSkillClientResponseModel> > result = await client.TeacherTeacherSkillBulkInsertAsync(request);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();

            context.Set <TeacherTeacherSkill>().ToList()[1].TeacherId.Should().Be(1);
            context.Set <TeacherTeacherSkill>().ToList()[1].TeacherSkillId.Should().Be(1);

            context.Set <TeacherTeacherSkill>().ToList()[2].TeacherId.Should().Be(1);
            context.Set <TeacherTeacherSkill>().ToList()[2].TeacherSkillId.Should().Be(1);
        }
        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 ApiTeacherTeacherSkillServerModelMapper();
            ApplicationDbContext        context             = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            ITeacherTeacherSkillService service             = testServer.Host.Services.GetService(typeof(ITeacherTeacherSkillService)) as ITeacherTeacherSkillService;
            ApiTeacherTeacherSkillServerResponseModel model = await service.Get(1);

            ApiTeacherTeacherSkillClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(1, 1);

            UpdateResponse <ApiTeacherTeacherSkillClientResponseModel> updateResponse = await client.TeacherTeacherSkillUpdateAsync(model.Id, request);

            context.Entry(context.Set <TeacherTeacherSkill>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <TeacherTeacherSkill>().ToList()[0].TeacherId.Should().Be(1);
            context.Set <TeacherTeacherSkill>().ToList()[0].TeacherSkillId.Should().Be(1);

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.TeacherId.Should().Be(1);
            updateResponse.Record.TeacherSkillId.Should().Be(1);
        }
Exemple #3
0
        public virtual ApiTeacherTeacherSkillClientRequestModel MapServerResponseToClientRequest(
            ApiTeacherTeacherSkillServerResponseModel response)
        {
            var request = new ApiTeacherTeacherSkillClientRequestModel();

            request.SetProperties(
                response.TeacherId,
                response.TeacherSkillId);
            return(request);
        }
        public void MapClientResponseToRequest()
        {
            var mapper = new ApiTeacherTeacherSkillModelMapper();
            var model  = new ApiTeacherTeacherSkillClientResponseModel();

            model.SetProperties(1, 1, 1);
            ApiTeacherTeacherSkillClientRequestModel response = mapper.MapClientResponseToRequest(model);

            response.Should().NotBeNull();
            response.TeacherId.Should().Be(1);
            response.TeacherSkillId.Should().Be(1);
        }