Ejemplo n.º 1
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;

            ITestAllFieldTypesNullableService service = testServer.Host.Services.GetService(typeof(ITestAllFieldTypesNullableService)) as ITestAllFieldTypesNullableService;
            var model = new ApiTestAllFieldTypesNullableServerRequestModel();

            model.SetProperties(2, BitConverter.GetBytes(2), true, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), 2m, 2, BitConverter.GetBytes(2), 2m, "B", "B", 2m, "B", 2m, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, 2m, "B", TimeSpan.Parse("02:00:00"), BitConverter.GetBytes(2), 2, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), BitConverter.GetBytes(2), "B", "B");
            CreateResponse <ApiTestAllFieldTypesNullableServerResponseModel> createdResponse = await service.Create(model);

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

            ActionResponse deleteResult = await client.TestAllFieldTypesNullableDeleteAsync(2);

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

            verifyResponse.Should().BeNull();
        }
 public AbstractTestAllFieldTypesNullableController(
     ApiSettings settings,
     ILogger <AbstractTestAllFieldTypesNullableController> logger,
     ITransactionCoordinator transactionCoordinator,
     ITestAllFieldTypesNullableService testAllFieldTypesNullableService,
     IApiTestAllFieldTypesNullableModelMapper testAllFieldTypesNullableModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.TestAllFieldTypesNullableService     = testAllFieldTypesNullableService;
     this.TestAllFieldTypesNullableModelMapper = testAllFieldTypesNullableModelMapper;
 }
Ejemplo n.º 3
0
 public TestAllFieldTypesNullableController(
     ApiSettings settings,
     ILogger <TestAllFieldTypesNullableController> logger,
     ITransactionCoordinator transactionCoordinator,
     ITestAllFieldTypesNullableService testAllFieldTypesNullableService,
     IApiTestAllFieldTypesNullableServerModelMapper testAllFieldTypesNullableModelMapper
     )
     : base(settings, logger, transactionCoordinator)
 {
     this.TestAllFieldTypesNullableService     = testAllFieldTypesNullableService;
     this.TestAllFieldTypesNullableModelMapper = testAllFieldTypesNullableModelMapper;
     this.BulkInsertLimit = 250;
     this.MaxLimit        = 1000;
     this.DefaultLimit    = 250;
 }
Ejemplo n.º 4
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 ApiTestAllFieldTypesNullableServerModelMapper();
            ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            ITestAllFieldTypesNullableService service             = testServer.Host.Services.GetService(typeof(ITestAllFieldTypesNullableService)) as ITestAllFieldTypesNullableService;
            ApiTestAllFieldTypesNullableServerResponseModel model = await service.Get(1);

            ApiTestAllFieldTypesNullableClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties(2, BitConverter.GetBytes(2), true, "B", DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM"), DateTimeOffset.Parse("1/1/1988 12:00:00 AM"), 2m, 2, BitConverter.GetBytes(2), 2m, "B", "B", 2m, "B", 2m, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, 2m, "B", TimeSpan.Parse("02:00:00"), BitConverter.GetBytes(2), 2, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), BitConverter.GetBytes(2), "B", "B");

            UpdateResponse <ApiTestAllFieldTypesNullableClientResponseModel> updateResponse = await client.TestAllFieldTypesNullableUpdateAsync(model.Id, request);

            context.Entry(context.Set <TestAllFieldTypesNullable>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldBigInt.Should().Be(2);
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldBinary.Should().BeEquivalentTo(BitConverter.GetBytes(2));
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldBit.Should().Be(true);
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldChar.Should().Be("B");
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldDateTime.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldDateTime2.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldDateTimeOffset.Should().Be(DateTimeOffset.Parse("1/1/1988 12:00:00 AM"));
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldDecimal.Should().Be(2m);
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldFloat.Should().Be(2);
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldImage.Should().BeEquivalentTo(BitConverter.GetBytes(2));
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldMoney.Should().Be(2m);
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldNChar.Should().Be("B");
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldNText.Should().Be("B");
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldNumeric.Should().Be(2m);
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldNVarchar.Should().Be("B");
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldReal.Should().Be(2m);
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldSmallDateTime.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldSmallInt.Should().Be(2);
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldSmallMoney.Should().Be(2m);
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldText.Should().Be("B");
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldTime.Should().Be(TimeSpan.Parse("02:00:00"));
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldTimestamp.Should().BeEquivalentTo(BitConverter.GetBytes(2));
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldTinyInt.Should().Be(2);
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldUniqueIdentifier.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldVarBinary.Should().BeEquivalentTo(BitConverter.GetBytes(2));
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldVarchar.Should().Be("B");
            context.Set <TestAllFieldTypesNullable>().ToList()[0].FieldXML.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.FieldBigInt.Should().Be(2);
            updateResponse.Record.FieldBinary.Should().BeEquivalentTo(BitConverter.GetBytes(2));
            updateResponse.Record.FieldBit.Should().Be(true);
            updateResponse.Record.FieldChar.Should().Be("B");
            updateResponse.Record.FieldDate.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.FieldDateTime.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.FieldDateTime2.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.FieldDateTimeOffset.Should().Be(DateTimeOffset.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.FieldDecimal.Should().Be(2m);
            updateResponse.Record.FieldFloat.Should().Be(2);
            updateResponse.Record.FieldImage.Should().BeEquivalentTo(BitConverter.GetBytes(2));
            updateResponse.Record.FieldMoney.Should().Be(2m);
            updateResponse.Record.FieldNChar.Should().Be("B");
            updateResponse.Record.FieldNText.Should().Be("B");
            updateResponse.Record.FieldNumeric.Should().Be(2m);
            updateResponse.Record.FieldNVarchar.Should().Be("B");
            updateResponse.Record.FieldReal.Should().Be(2m);
            updateResponse.Record.FieldSmallDateTime.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            updateResponse.Record.FieldSmallInt.Should().Be(2);
            updateResponse.Record.FieldSmallMoney.Should().Be(2m);
            updateResponse.Record.FieldText.Should().Be("B");
            updateResponse.Record.FieldTime.Should().Be(TimeSpan.Parse("02:00:00"));
            updateResponse.Record.FieldTimestamp.Should().BeEquivalentTo(BitConverter.GetBytes(2));
            updateResponse.Record.FieldTinyInt.Should().Be(2);
            updateResponse.Record.FieldUniqueIdentifier.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            updateResponse.Record.FieldVarBinary.Should().BeEquivalentTo(BitConverter.GetBytes(2));
            updateResponse.Record.FieldVarchar.Should().Be("B");
            updateResponse.Record.FieldXML.Should().Be("B");
        }