Esempio n. 1
0
        public virtual async void TestByNameFound()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            ApiBucketClientResponseModel response = await client.ByBucketByName("A");

            response.Should().NotBeNull();

            response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
        public virtual async void TestGetFound()
        {
            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;

            ApiFileTypeClientResponseModel response = await client.FileTypeGetAsync(1);

            response.Should().NotBeNull();
            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Esempio n. 3
0
        public virtual async void TestCreate()
        {
            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 ApiFileClientRequestModel();

            model.SetProperties(1, DateTime.Parse("1/1/1988 12:00:00 AM"), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), "B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), 2m, 1, "B", "B", "B");
            CreateResponse <ApiFileClientResponseModel> result = await client.FileCreateAsync(model);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();
            context.Set <File>().ToList()[1].BucketId.Should().Be(1);
            context.Set <File>().ToList()[1].DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <File>().ToList()[1].Description.Should().Be("B");
            context.Set <File>().ToList()[1].Expiration.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <File>().ToList()[1].Extension.Should().Be("B");
            context.Set <File>().ToList()[1].ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            context.Set <File>().ToList()[1].FileSizeInByte.Should().Be(2m);
            context.Set <File>().ToList()[1].FileTypeId.Should().Be(1);
            context.Set <File>().ToList()[1].Location.Should().Be("B");
            context.Set <File>().ToList()[1].PrivateKey.Should().Be("B");
            context.Set <File>().ToList()[1].PublicKey.Should().Be("B");

            result.Record.BucketId.Should().Be(1);
            result.Record.DateCreated.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            result.Record.Description.Should().Be("B");
            result.Record.Expiration.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            result.Record.Extension.Should().Be("B");
            result.Record.ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            result.Record.FileSizeInByte.Should().Be(2m);
            result.Record.FileTypeId.Should().Be(1);
            result.Record.Location.Should().Be("B");
            result.Record.PrivateKey.Should().Be("B");
            result.Record.PublicKey.Should().Be("B");
        }
        public virtual async void TestCreate()
        {
            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 ApiFileTypeClientRequestModel();

            model.SetProperties("B");
            CreateResponse <ApiFileTypeClientResponseModel> result = await client.FileTypeCreateAsync(model);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();
            context.Set <FileType>().ToList()[1].Name.Should().Be("B");

            result.Record.Name.Should().Be("B");
        }
Esempio n. 5
0
        public virtual async void TestCreate()
        {
            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 ApiBucketClientRequestModel();

            model.SetProperties(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B");
            CreateResponse <ApiBucketClientResponseModel> result = await client.BucketCreateAsync(model);

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();
            context.Set <Bucket>().ToList()[1].ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            context.Set <Bucket>().ToList()[1].Name.Should().Be("B");

            result.Record.ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            result.Record.Name.Should().Be("B");
        }