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());
            ApiLinkStatusClientResponseModel response = await client.ByLinkStatusByName("A");

            response.Should().NotBeNull();

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Exemplo n.º 2
0
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiClaspClientResponseModel> response = await client.ClaspAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].Id.Should().Be(1);
            response[0].NextChainId.Should().Be(1);
            response[0].PreviousChainId.Should().Be(1);
        }
        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;

            ApiChainStatusClientResponseModel response = await client.ChainStatusGetAsync(1);

            response.Should().NotBeNull();
            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Exemplo n.º 4
0
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiLinkLogClientResponseModel> response = await client.LinkLogAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].DateEntered.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response[0].Id.Should().Be(1);
            response[0].LinkId.Should().Be(1);
            response[0].Log.Should().Be("A");
        }
Exemplo 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 ApiLinkClientRequestModel();

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

            result.Success.Should().BeTrue();
            result.Record.Should().NotBeNull();
            context.Set <Link>().ToList()[1].AssignedMachineId.Should().Be(1);
            context.Set <Link>().ToList()[1].ChainId.Should().Be(1);
            context.Set <Link>().ToList()[1].DateCompleted.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Link>().ToList()[1].DateStarted.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            context.Set <Link>().ToList()[1].DynamicParameters.Should().Be("B");
            context.Set <Link>().ToList()[1].ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            context.Set <Link>().ToList()[1].LinkStatusId.Should().Be(1);
            context.Set <Link>().ToList()[1].Name.Should().Be("B");
            context.Set <Link>().ToList()[1].Order.Should().Be(2);
            context.Set <Link>().ToList()[1].Response.Should().Be("B");
            context.Set <Link>().ToList()[1].StaticParameters.Should().Be("B");
            context.Set <Link>().ToList()[1].TimeoutInSeconds.Should().Be(2);

            result.Record.AssignedMachineId.Should().Be(1);
            result.Record.ChainId.Should().Be(1);
            result.Record.DateCompleted.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            result.Record.DateStarted.Should().Be(DateTime.Parse("1/1/1988 12:00:00 AM"));
            result.Record.DynamicParameters.Should().Be("B");
            result.Record.ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            result.Record.LinkStatusId.Should().Be(1);
            result.Record.Name.Should().Be("B");
            result.Record.Order.Should().Be(2);
            result.Record.Response.Should().Be("B");
            result.Record.StaticParameters.Should().Be("B");
            result.Record.TimeoutInSeconds.Should().Be(2);
        }
Exemplo n.º 6
0
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiChainClientResponseModel> response = await client.ChainAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].ChainStatusId.Should().Be(1);
            response[0].ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response[0].Id.Should().Be(1);
            response[0].Name.Should().Be("A");
            response[0].TeamId.Should().Be(1);
        }
Exemplo n.º 7
0
        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;

            ApiLinkLogClientResponseModel response = await client.LinkLogGetAsync(1);

            response.Should().NotBeNull();
            response.DateEntered.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.Id.Should().Be(1);
            response.LinkId.Should().Be(1);
            response.Log.Should().Be("A");
        }
Exemplo n.º 8
0
        public virtual async void TestAll()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

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

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            List <ApiMachineClientResponseModel> response = await client.MachineAllAsync();

            response.Count.Should().BeGreaterThan(0);
            response[0].Description.Should().Be("A");
            response[0].Id.Should().Be(1);
            response[0].JwtKey.Should().Be("A");
            response[0].LastIpAddress.Should().Be("A");
            response[0].MachineGuid.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response[0].Name.Should().Be("A");
        }
        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 ApiChainStatusClientRequestModel();

            model.SetProperties("B");
            CreateResponse <ApiChainStatusClientResponseModel> result = await client.ChainStatusCreateAsync(model);

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

            result.Record.Name.Should().Be("B");
        }
Exemplo n.º 10
0
        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 ApiMachineClientRequestModel();

            model.SetProperties("B", "B", "B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B");
            var model2 = new ApiMachineClientRequestModel();

            model2.SetProperties("C", "C", "C", Guid.Parse("8d721ec8-4c9d-632f-6f06-7f89cc14862c"), "C");
            var request = new List <ApiMachineClientRequestModel>()
            {
                model, model2
            };
            CreateResponse <List <ApiMachineClientResponseModel> > result = await client.MachineBulkInsertAsync(request);

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

            context.Set <Machine>().ToList()[1].Description.Should().Be("B");
            context.Set <Machine>().ToList()[1].JwtKey.Should().Be("B");
            context.Set <Machine>().ToList()[1].LastIpAddress.Should().Be("B");
            context.Set <Machine>().ToList()[1].MachineGuid.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            context.Set <Machine>().ToList()[1].Name.Should().Be("B");

            context.Set <Machine>().ToList()[2].Description.Should().Be("C");
            context.Set <Machine>().ToList()[2].JwtKey.Should().Be("C");
            context.Set <Machine>().ToList()[2].LastIpAddress.Should().Be("C");
            context.Set <Machine>().ToList()[2].MachineGuid.Should().Be(Guid.Parse("8d721ec8-4c9d-632f-6f06-7f89cc14862c"));
            context.Set <Machine>().ToList()[2].Name.Should().Be("C");
        }
Exemplo n.º 11
0
        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;

            ApiMachineClientResponseModel response = await client.MachineGetAsync(1);

            response.Should().NotBeNull();
            response.Description.Should().Be("A");
            response.Id.Should().Be(1);
            response.JwtKey.Should().Be("A");
            response.LastIpAddress.Should().Be("A");
            response.MachineGuid.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.Name.Should().Be("A");
        }
Exemplo n.º 12
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 ApiMachineServerModelMapper();
            ApplicationDbContext          context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
            IMachineService               service = testServer.Host.Services.GetService(typeof(IMachineService)) as IMachineService;
            ApiMachineServerResponseModel model   = await service.Get(1);

            ApiMachineClientRequestModel request = mapper.MapServerResponseToClientRequest(model);

            request.SetProperties("B", "B", "B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B");

            UpdateResponse <ApiMachineClientResponseModel> updateResponse = await client.MachineUpdateAsync(model.Id, request);

            context.Entry(context.Set <Machine>().ToList()[0]).Reload();
            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
            updateResponse.Record.Id.Should().Be(1);
            context.Set <Machine>().ToList()[0].Description.Should().Be("B");
            context.Set <Machine>().ToList()[0].JwtKey.Should().Be("B");
            context.Set <Machine>().ToList()[0].LastIpAddress.Should().Be("B");
            context.Set <Machine>().ToList()[0].MachineGuid.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            context.Set <Machine>().ToList()[0].Name.Should().Be("B");

            updateResponse.Record.Id.Should().Be(1);
            updateResponse.Record.Description.Should().Be("B");
            updateResponse.Record.JwtKey.Should().Be("B");
            updateResponse.Record.LastIpAddress.Should().Be("B");
            updateResponse.Record.MachineGuid.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            updateResponse.Record.Name.Should().Be("B");
        }